Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
modules/Campaigns/views/view.detail.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 class CampaignsViewDetail extends ViewDetail {
56 56
 
57
- 	function __construct(){
57
+ 	function __construct() {
58 58
 
59 59
         parent::__construct();
60 60
         //turn off normal display of subpanels
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
67 67
      */
68
-    function CampaignsViewDetail(){
68
+    function CampaignsViewDetail() {
69 69
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
70
-        if(isset($GLOBALS['log'])) {
70
+        if (isset($GLOBALS['log'])) {
71 71
             $GLOBALS['log']->deprecated($deprecatedMessage);
72 72
         }
73 73
         else {
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 
79 79
 
80 80
 
81
-    function preDisplay(){
81
+    function preDisplay() {
82 82
         global $mod_strings;
83
-        if (isset($this->bean->campaign_type) && strtolower($this->bean->campaign_type) == 'newsletter'){
83
+        if (isset($this->bean->campaign_type) && strtolower($this->bean->campaign_type) == 'newsletter') {
84 84
             $mod_strings['LBL_MODULE_NAME'] = $mod_strings['LBL_NEWSLETTERS'];
85 85
         }
86 86
         parent::preDisplay();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
  	    global $app_list_strings;
93 93
  	    $this->ss->assign('APP_LIST', $app_list_strings);
94 94
 
95
-        if (isset($_REQUEST['mode']) && $_REQUEST['mode']=='set_target'){
95
+        if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'set_target') {
96 96
             require_once('modules/Campaigns/utils.php');
97 97
             //call function to create campaign logs
98 98
             $mess = track_campaign_prospects($this->bean);
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
             window.setTimeout('ajax_C_LOG_Status.hideStatus()', 1500);
103 103
             window.setTimeout(\"ajax_C_LOG_Status.showStatus('".$mess."')\",2000);
104 104
             window.setTimeout('ajax_C_LOG_Status.hideStatus()', 5000); ";
105
-            $this->ss->assign("MSG_SCRIPT",$confirm_msg);
105
+            $this->ss->assign("MSG_SCRIPT", $confirm_msg);
106 106
 
107 107
         }
108 108
 
109
-	    if (($this->bean->campaign_type == 'Email') || ($this->bean->campaign_type == 'NewsLetter' )) {
109
+	    if (($this->bean->campaign_type == 'Email') || ($this->bean->campaign_type == 'NewsLetter')) {
110 110
 	    	$this->ss->assign("ADD_BUTTON_STATE", "submit");
111 111
 	        $this->ss->assign("TARGET_BUTTON_STATE", "hidden");
112 112
 	    } else {
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 	    }
117 117
 
118 118
 	    $currency = new Currency();
119
-	    if(isset($this->bean->currency_id) && !empty($this->bean->currency_id))
119
+	    if (isset($this->bean->currency_id) && !empty($this->bean->currency_id))
120 120
 	    {
121 121
 	    	$currency->retrieve($this->bean->currency_id);
122
-	    	if( $currency->deleted != 1){
123
-	    		$this->ss->assign('CURRENCY', $currency->iso4217 .' '.$currency->symbol);
124
-	    	}else {
125
-	    	    $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol());
122
+	    	if ($currency->deleted != 1) {
123
+	    		$this->ss->assign('CURRENCY', $currency->iso4217.' '.$currency->symbol);
124
+	    	} else {
125
+	    	    $this->ss->assign('CURRENCY', $currency->getDefaultISO4217().' '.$currency->getDefaultCurrencySymbol());
126 126
 	    	}
127
-	    }else{
128
-	    	$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol());
127
+	    } else {
128
+	    	$this->ss->assign('CURRENCY', $currency->getDefaultISO4217().' '.$currency->getDefaultCurrencySymbol());
129 129
 	    }
130 130
 
131 131
         parent::display();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
         require_once('include/SubPanel/SubPanelTiles.php');
137 137
         $subpanel = new SubPanelTiles($this->bean, $this->module);
138 138
         //get available list of subpanels
139
-        $alltabs=$subpanel->subpanel_definitions->get_available_tabs();
139
+        $alltabs = $subpanel->subpanel_definitions->get_available_tabs();
140 140
         if (!empty($alltabs)) {
141 141
             //iterate through list, and filter out all but 3 subpanels
142 142
             foreach ($alltabs as $key=>$name) {
143
-                if ($name != 'prospectlists' && $name!='emailmarketing' && $name != 'tracked_urls'
143
+                if ($name != 'prospectlists' && $name != 'emailmarketing' && $name != 'tracked_urls'
144 144
                 /* BEGIN - SECURITY GROUPS */
145 145
                 	&& $name != 'securitygroups'
146 146
                 /* END - SECURITY GROUPS */
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                 }
151 151
             }
152 152
             //only show email marketing subpanel for email/newsletter campaigns
153
-            if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter' ) {
153
+            if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter') {
154 154
                 //exclude emailmarketing subpanel if not on an email or newsletter campaign
155 155
                 $subpanel->subpanel_definitions->exclude_tab('emailmarketing');
156 156
                 // Bug #49893  - 20120120 - Captivea (ybi) - Remove trackers subpanels if not on an email/newsletter campaign (useless subpannl)
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 /*********************************************************************************
5 7
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -69,8 +71,7 @@  discard block
 block discarded – undo
69 71
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
70 72
         if(isset($GLOBALS['log'])) {
71 73
             $GLOBALS['log']->deprecated($deprecatedMessage);
72
-        }
73
-        else {
74
+        } else {
74 75
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
75 76
         }
76 77
         self::__construct();
@@ -121,10 +122,10 @@  discard block
 block discarded – undo
121 122
 	    	$currency->retrieve($this->bean->currency_id);
122 123
 	    	if( $currency->deleted != 1){
123 124
 	    		$this->ss->assign('CURRENCY', $currency->iso4217 .' '.$currency->symbol);
124
-	    	}else {
125
+	    	} else {
125 126
 	    	    $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol());
126 127
 	    	}
127
-	    }else{
128
+	    } else{
128 129
 	    	$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol());
129 130
 	    }
130 131
 
Please login to merge, or discard this patch.
modules/Campaigns/views/view.classic.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
53 53
      */
54
-    function CampaignsViewClassic(){
54
+    function CampaignsViewClassic() {
55 55
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
56
-        if(isset($GLOBALS['log'])) {
56
+        if (isset($GLOBALS['log'])) {
57 57
             $GLOBALS['log']->deprecated($deprecatedMessage);
58 58
         }
59 59
         else {
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 	{
71 71
  		// Call SugarController::getActionFilename to handle case sensitive file names
72 72
  		$file = SugarController::getActionFilename($this->action);
73
- 		if(file_exists('custom/modules/' . $this->module . '/'. $file . '.php')){
74
-			$this->includeClassicFile('custom/modules/'. $this->module . '/'. $file . '.php');
73
+ 		if (file_exists('custom/modules/'.$this->module.'/'.$file.'.php')) {
74
+			$this->includeClassicFile('custom/modules/'.$this->module.'/'.$file.'.php');
75 75
 			return true;
76
-		}elseif(file_exists('modules/' . $this->module . '/'. $file . '.php')){
77
-			$this->includeClassicFile('modules/'. $this->module . '/'. $file . '.php');
76
+		}elseif (file_exists('modules/'.$this->module.'/'.$file.'.php')) {
77
+			$this->includeClassicFile('modules/'.$this->module.'/'.$file.'.php');
78 78
 			return true;
79 79
 		}
80 80
 		return false;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	{
88 88
     	$params = array();
89 89
     	$params[] = $this->_getModuleTitleListParam($browserTitle);
90
-    	if (isset($this->action)){
91
-    		switch($_REQUEST['action']){
90
+    	if (isset($this->action)) {
91
+    		switch ($_REQUEST['action']) {
92 92
     				case 'WizardHome':
93
-				    	if(!empty($this->bean->id))
93
+				    	if (!empty($this->bean->id))
94 94
 				    	{
95 95
 				    		$params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->name."</a>";
96 96
 				    	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     					$params[] = $GLOBALS['mod_strings']['LBL_LEAD_FORM_WIZARD'];
101 101
     					break;
102 102
     				case 'WizardNewsletter':
103
-				    	if(!empty($this->bean->id))
103
+				    	if (!empty($this->bean->id))
104 104
 				    	{
105 105
 				    		$params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$GLOBALS['mod_strings']['LBL_NEWSLETTER_TITLE']."</a>";
106 106
 				    	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     					$params[] = $GLOBALS['mod_strings']['LBL_EMAIL_SETUP_WIZARD_TITLE'];
114 114
     					break;
115 115
     				case 'TrackDetailView':
116
-    					if(!empty($this->bean->id))
116
+    					if (!empty($this->bean->id))
117 117
     					{
118 118
 	    					$params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->name."</a>";
119 119
     					}
Please login to merge, or discard this patch.
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@  discard block
 block discarded – undo
55 55
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
56 56
         if(isset($GLOBALS['log'])) {
57 57
             $GLOBALS['log']->deprecated($deprecatedMessage);
58
-        }
59
-        else {
58
+        } else {
60 59
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
61 60
         }
62 61
         self::__construct();
@@ -73,7 +72,7 @@  discard block
 block discarded – undo
73 72
  		if(file_exists('custom/modules/' . $this->module . '/'. $file . '.php')){
74 73
 			$this->includeClassicFile('custom/modules/'. $this->module . '/'. $file . '.php');
75 74
 			return true;
76
-		}elseif(file_exists('modules/' . $this->module . '/'. $file . '.php')){
75
+		} elseif(file_exists('modules/' . $this->module . '/'. $file . '.php')){
77 76
 			$this->includeClassicFile('modules/'. $this->module . '/'. $file . '.php');
78 77
 			return true;
79 78
 		}
Please login to merge, or discard this patch.
modules/UpgradeWizard/SugarMerge/SugarMerge.php 3 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -58,27 +58,27 @@  discard block
 block discarded – undo
58 58
  *
59 59
  */
60 60
 class SugarMerge {
61
-	private $mergeMapping = array();
62
-	private $new_path = '';
63
-	private $custom_path = 'custom';
64
-	private $original_path = '';
65
-	private $merged = array();
66
-	private $fp = NULL;
67
-
68
-	function __construct($new_path='', $original_path='', $custom_path='custom') {
69
-
70
-		$this->new_path = empty($new_path) || preg_match('/[\/]$/', $new_path) ? $new_path : $new_path . '/';
71
-		$this->original_path = empty($original_path) || preg_match('/[\/]$/', $original_path) ? $original_path : $original_path . '/';
72
-		$this->custom_path = empty($custom_path) || preg_match('/[\/]$/', $custom_path) ? $custom_path : $custom_path . '/';
73
-
74
-		$this->mergeMapping = array(
75
-			'editviewdefs.php'=> new EditViewMerge(),
76
-			'detailviewdefs.php'=>new DetailViewMerge(),
77
-			'listviewdefs.php'=>new ListViewMerge(),
78
-			'searchdefs.php'=>new SearchMerge(),
79
-			'quickcreatedefs.php'=>new QuickCreateMerge(),
80
-		);
81
-	}
61
+    private $mergeMapping = array();
62
+    private $new_path = '';
63
+    private $custom_path = 'custom';
64
+    private $original_path = '';
65
+    private $merged = array();
66
+    private $fp = NULL;
67
+
68
+    function __construct($new_path='', $original_path='', $custom_path='custom') {
69
+
70
+        $this->new_path = empty($new_path) || preg_match('/[\/]$/', $new_path) ? $new_path : $new_path . '/';
71
+        $this->original_path = empty($original_path) || preg_match('/[\/]$/', $original_path) ? $original_path : $original_path . '/';
72
+        $this->custom_path = empty($custom_path) || preg_match('/[\/]$/', $custom_path) ? $custom_path : $custom_path . '/';
73
+
74
+        $this->mergeMapping = array(
75
+            'editviewdefs.php'=> new EditViewMerge(),
76
+            'detailviewdefs.php'=>new DetailViewMerge(),
77
+            'listviewdefs.php'=>new ListViewMerge(),
78
+            'searchdefs.php'=>new SearchMerge(),
79
+            'quickcreatedefs.php'=>new QuickCreateMerge(),
80
+        );
81
+    }
82 82
 
83 83
     /**
84 84
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
@@ -95,34 +95,34 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
 
98
-	function setLogFilePointer($fp){
99
-		$this->fp = $fp;
100
-	}
98
+    function setLogFilePointer($fp){
99
+        $this->fp = $fp;
100
+    }
101 101
 
102 102
 
103 103
 
104
-	/**
105
-	 * This will run through all the modules that may need merging and determine if there is anything to merge
106
-	 * if $merge is set to true it will perform the merge
107
-	 * if $merge and $save are set to true it will perform the merge and save the results in the custom directory
108
-	 *
109
-	 * @param BOOLEAN|ARRAY $merge - do we wish to perform the merge if false it will just return a list of files that can be merged.  If an array is passed, only those modules present in the array will be merged.
110
-	 * @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
111
-	 * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
112
-	 * @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
113
-	 */
114
-	function mergeAll($merge=true, $save=true, $logHistory=true){
115
-		$this->merged = array();
116
-		$searchDirectory = $this->custom_path;
117
-		if(!preg_match('/[\/]modules$/si', $searchDirectory)) {
118
-		   $searchDirectory .= preg_match('/[\/]$/', $this->custom_path) ? 'modules' : '/modules';
119
-		}
104
+    /**
105
+     * This will run through all the modules that may need merging and determine if there is anything to merge
106
+     * if $merge is set to true it will perform the merge
107
+     * if $merge and $save are set to true it will perform the merge and save the results in the custom directory
108
+     *
109
+     * @param BOOLEAN|ARRAY $merge - do we wish to perform the merge if false it will just return a list of files that can be merged.  If an array is passed, only those modules present in the array will be merged.
110
+     * @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
111
+     * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
112
+     * @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
113
+     */
114
+    function mergeAll($merge=true, $save=true, $logHistory=true){
115
+        $this->merged = array();
116
+        $searchDirectory = $this->custom_path;
117
+        if(!preg_match('/[\/]modules$/si', $searchDirectory)) {
118
+            $searchDirectory .= preg_match('/[\/]$/', $this->custom_path) ? 'modules' : '/modules';
119
+        }
120 120
 
121
-		if(file_exists($searchDirectory)){
122
-			$dir = dir($searchDirectory);
123
-			while($e = $dir->read()){
124
-				if(substr($e , 0, 1) != '.') {
125
-					if(is_dir("{$searchDirectory}/{$e}/metadata")){
121
+        if(file_exists($searchDirectory)){
122
+            $dir = dir($searchDirectory);
123
+            while($e = $dir->read()){
124
+                if(substr($e , 0, 1) != '.') {
125
+                    if(is_dir("{$searchDirectory}/{$e}/metadata")){
126 126
 
127 127
                         //lets make sure that the directory matches the case of the module before we pass it in
128 128
                         global $moduleList;
@@ -130,132 +130,132 @@  discard block
 block discarded – undo
130 130
                         $checkModList =  array_combine ($moduleList,$moduleList);
131 131
                         $checkModList = array_change_key_case($checkModList);
132 132
 
133
-  						//now lets compare with the current directory.  This accounts for cases in which the directory was created in lowercase
133
+                            //now lets compare with the current directory.  This accounts for cases in which the directory was created in lowercase
134 134
                         if(!empty($checkModList[strtolower($e)])){
135 135
                             //directory was lowercase, let's use the right module value
136
-							$e = $checkModList[strtolower($e)];
136
+                            $e = $checkModList[strtolower($e)];
137 137
                         }
138 138
 
139
-					    if( is_array($merge) )
140
-					    {
141
-					        if ( in_array($e,$merge) )
142
-					        	$this->merged[$e] = $this->mergeModule($e, TRUE, $save,$logHistory );
143
-					        else
144
-					        {
145
-					            $GLOBALS['log']->debug("SugarMerge is skipping $e module as filter array passed in but module not specified for merge.");
146
-					            continue;
147
-					        }
148
-					    }
149
-					    else
150
-						  $this->merged[$e] = $this->mergeModule($e, $merge, $save,$logHistory );
151
-					}
152
-				}
153
-			}
154
-		}
155
-		return $this->merged;
156
-	}
157
-
158
-
159
-
160
-
161
-	/**
162
-	 * This will merge any files that need merging for a given module
163
-	 * if $merge is set to true it will perform the merge
164
-	 * if $merge and $save are set to true it will perform the merge and save the results in the custom directory
165
-	 *
166
-	 * @param STRING $module - the name of the module to merge files for
167
-	 * @param BOOLEAN $merge - do we wish to perform the merge if false it will just return a list of files that can be merged
168
-	 * @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
169
-	 * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
170
-	 * @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
171
-	 */
172
-	function mergeModule($module, $merge = true, $save=true,$logHistory=true){
173
-		$merged = array();
174
-		$path = $this->original_path . 'modules/' . $module . '/metadata/';
175
-		$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
176
-		$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
177
-		foreach($this->mergeMapping as $file=>&$object){
178
-			if(file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
179
-				if($merge){
180
-					$merged[$file] = $this->mergeFile($module, $file, $save, $logHistory);
181
-				}else{
182
-					$merged[$file] = true;
183
-				}
184
-			}
185
-		}
186
-
187
-		return $merged;
188
-
189
-	}
190
-
191
-	/**
192
-	 * This function will merge a single file for a module
193
-	 *
194
-	 * @param STRING $module - name of the module
195
-	 * @param STRING $file - name of the file
196
-	 * @param STRING $save - should the merged file be saved to the custom directory
197
-	 * @return BOOLEAN - success or failure of the merge
198
-	 */
199
-	function mergeFile($module, $file, $save=true,$logHistory=true){
200
-		$path = $this->original_path . 'modules/' . $module . '/metadata/';
201
-		$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
202
-		$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
203
-		if($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
204
-		if(isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
205
-		    //Create a log entry of the custom file before it is merged
206
-		    if($logHistory && $save)
207
-		          $this->createHistoryLog($module, "{$custom_path}{$file}",$file);
139
+                        if( is_array($merge) )
140
+                        {
141
+                            if ( in_array($e,$merge) )
142
+                                $this->merged[$e] = $this->mergeModule($e, TRUE, $save,$logHistory );
143
+                            else
144
+                            {
145
+                                $GLOBALS['log']->debug("SugarMerge is skipping $e module as filter array passed in but module not specified for merge.");
146
+                                continue;
147
+                            }
148
+                        }
149
+                        else
150
+                            $this->merged[$e] = $this->mergeModule($e, $merge, $save,$logHistory );
151
+                    }
152
+                }
153
+            }
154
+        }
155
+        return $this->merged;
156
+    }
157
+
158
+
159
+
160
+
161
+    /**
162
+     * This will merge any files that need merging for a given module
163
+     * if $merge is set to true it will perform the merge
164
+     * if $merge and $save are set to true it will perform the merge and save the results in the custom directory
165
+     *
166
+     * @param STRING $module - the name of the module to merge files for
167
+     * @param BOOLEAN $merge - do we wish to perform the merge if false it will just return a list of files that can be merged
168
+     * @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
169
+     * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
170
+     * @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
171
+     */
172
+    function mergeModule($module, $merge = true, $save=true,$logHistory=true){
173
+        $merged = array();
174
+        $path = $this->original_path . 'modules/' . $module . '/metadata/';
175
+        $custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
176
+        $new_path = $this->new_path . 'modules/' . $module . '/metadata/';
177
+        foreach($this->mergeMapping as $file=>&$object){
178
+            if(file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
179
+                if($merge){
180
+                    $merged[$file] = $this->mergeFile($module, $file, $save, $logHistory);
181
+                }else{
182
+                    $merged[$file] = true;
183
+                }
184
+            }
185
+        }
186
+
187
+        return $merged;
188
+
189
+    }
190
+
191
+    /**
192
+     * This function will merge a single file for a module
193
+     *
194
+     * @param STRING $module - name of the module
195
+     * @param STRING $file - name of the file
196
+     * @param STRING $save - should the merged file be saved to the custom directory
197
+     * @return BOOLEAN - success or failure of the merge
198
+     */
199
+    function mergeFile($module, $file, $save=true,$logHistory=true){
200
+        $path = $this->original_path . 'modules/' . $module . '/metadata/';
201
+        $custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
202
+        $new_path = $this->new_path . 'modules/' . $module . '/metadata/';
203
+        if($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
204
+        if(isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
205
+            //Create a log entry of the custom file before it is merged
206
+            if($logHistory && $save)
207
+                    $this->createHistoryLog($module, "{$custom_path}{$file}",$file);
208 208
             $this->mergeMapping[$file]->sugarMerge = $this;
209
-		    return $this->mergeMapping[$file]->merge($module, "{$path}{$file}", "{$new_path}{$file}", "{$custom_path}{$file}", $save);
210
-		}
211
-		return false;
209
+            return $this->mergeMapping[$file]->merge($module, "{$path}{$file}", "{$new_path}{$file}", "{$custom_path}{$file}", $save);
210
+        }
211
+        return false;
212 212
 
213
-	}
213
+    }
214
+
215
+    /**
216
+     * Create a history copy of the custom file that will be merged so that it can be access through
217
+     * studio if admins wish to revert at a later date.
218
+     *
219
+     * @param STRING $module - name of the module
220
+     * @param STRING $file - name of the file
221
+     * @param STRING $customFile - Path to the custom file that will be merged
222
+     */
223
+    protected function createHistoryLog($module,$customFile,$file)
224
+    {
225
+        $historyPath = 'custom/' . MB_HISTORYMETADATALOCATION . "/modules/$module/metadata/$file";
226
+        $history = new History($historyPath);
227
+        $timeStamp = $history->append($customFile);
228
+        $GLOBALS['log']->debug("Created history file after merge with new file: " . $historyPath .'_'.$timeStamp);
229
+    }
214 230
 
215 231
     /**
216
-	 * Create a history copy of the custom file that will be merged so that it can be access through
217
-	 * studio if admins wish to revert at a later date.
218
-	 *
219
-	 * @param STRING $module - name of the module
220
-	 * @param STRING $file - name of the file
221
-	 * @param STRING $customFile - Path to the custom file that will be merged
222
-	 */
223
-	protected function createHistoryLog($module,$customFile,$file)
224
-	{
225
-	    $historyPath = 'custom/' . MB_HISTORYMETADATALOCATION . "/modules/$module/metadata/$file";
226
-	    $history = new History($historyPath);
227
-	    $timeStamp = $history->append($customFile);
228
-	    $GLOBALS['log']->debug("Created history file after merge with new file: " . $historyPath .'_'.$timeStamp);
229
-	}
230
-
231
-	/**
232
-	 * Return the custom modules path
233
-	 *
234
-	 * @return STRING directory where custom module files are located
235
-	 */
236
-	function getCustomPath() {
237
-		return $this->custom_path;
238
-	}
239
-
240
-
241
-	/**
242
-	 * Return the new upgrade modules path
243
-	 *
244
-	 * @return STRING directory where new module files are located
245
-	 */
246
-	function getNewPath() {
247
-		return $this->new_path;
248
-	}
249
-
250
-
251
-	/**
252
-	 * Return the original modules path
253
-	 *
254
-	 * @return STRING directory where new module files are located
255
-	 */
256
-	function getOriginalPath() {
257
-		return $this->original_path;
258
-	}
232
+     * Return the custom modules path
233
+     *
234
+     * @return STRING directory where custom module files are located
235
+     */
236
+    function getCustomPath() {
237
+        return $this->custom_path;
238
+    }
239
+
240
+
241
+    /**
242
+     * Return the new upgrade modules path
243
+     *
244
+     * @return STRING directory where new module files are located
245
+     */
246
+    function getNewPath() {
247
+        return $this->new_path;
248
+    }
249
+
250
+
251
+    /**
252
+     * Return the original modules path
253
+     *
254
+     * @return STRING directory where new module files are located
255
+     */
256
+    function getOriginalPath() {
257
+        return $this->original_path;
258
+    }
259 259
 
260 260
 }
261 261
 ?>
262 262
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	private $merged = array();
66 66
 	private $fp = NULL;
67 67
 
68
-	function __construct($new_path='', $original_path='', $custom_path='custom') {
68
+	function __construct($new_path = '', $original_path = '', $custom_path = 'custom') {
69 69
 
70
-		$this->new_path = empty($new_path) || preg_match('/[\/]$/', $new_path) ? $new_path : $new_path . '/';
71
-		$this->original_path = empty($original_path) || preg_match('/[\/]$/', $original_path) ? $original_path : $original_path . '/';
72
-		$this->custom_path = empty($custom_path) || preg_match('/[\/]$/', $custom_path) ? $custom_path : $custom_path . '/';
70
+		$this->new_path = empty($new_path) || preg_match('/[\/]$/', $new_path) ? $new_path : $new_path.'/';
71
+		$this->original_path = empty($original_path) || preg_match('/[\/]$/', $original_path) ? $original_path : $original_path.'/';
72
+		$this->custom_path = empty($custom_path) || preg_match('/[\/]$/', $custom_path) ? $custom_path : $custom_path.'/';
73 73
 
74 74
 		$this->mergeMapping = array(
75 75
 			'editviewdefs.php'=> new EditViewMerge(),
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
     /**
84 84
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
85 85
      */
86
-    function SugarMerge($new_path='', $original_path='', $custom_path='custom'){
86
+    function SugarMerge($new_path = '', $original_path = '', $custom_path = 'custom') {
87 87
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
88
-        if(isset($GLOBALS['log'])) {
88
+        if (isset($GLOBALS['log'])) {
89 89
             $GLOBALS['log']->deprecated($deprecatedMessage);
90 90
         }
91 91
         else {
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
 
98
-	function setLogFilePointer($fp){
98
+	function setLogFilePointer($fp) {
99 99
 		$this->fp = $fp;
100 100
 	}
101 101
 
@@ -111,35 +111,35 @@  discard block
 block discarded – undo
111 111
 	 * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
112 112
 	 * @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
113 113
 	 */
114
-	function mergeAll($merge=true, $save=true, $logHistory=true){
114
+	function mergeAll($merge = true, $save = true, $logHistory = true) {
115 115
 		$this->merged = array();
116 116
 		$searchDirectory = $this->custom_path;
117
-		if(!preg_match('/[\/]modules$/si', $searchDirectory)) {
117
+		if (!preg_match('/[\/]modules$/si', $searchDirectory)) {
118 118
 		   $searchDirectory .= preg_match('/[\/]$/', $this->custom_path) ? 'modules' : '/modules';
119 119
 		}
120 120
 
121
-		if(file_exists($searchDirectory)){
121
+		if (file_exists($searchDirectory)) {
122 122
 			$dir = dir($searchDirectory);
123
-			while($e = $dir->read()){
124
-				if(substr($e , 0, 1) != '.') {
125
-					if(is_dir("{$searchDirectory}/{$e}/metadata")){
123
+			while ($e = $dir->read()) {
124
+				if (substr($e, 0, 1) != '.') {
125
+					if (is_dir("{$searchDirectory}/{$e}/metadata")) {
126 126
 
127 127
                         //lets make sure that the directory matches the case of the module before we pass it in
128 128
                         global $moduleList;
129 129
                         //lets populate an array with the available modules, and make the key's lowercase
130
-                        $checkModList =  array_combine ($moduleList,$moduleList);
130
+                        $checkModList = array_combine($moduleList, $moduleList);
131 131
                         $checkModList = array_change_key_case($checkModList);
132 132
 
133 133
   						//now lets compare with the current directory.  This accounts for cases in which the directory was created in lowercase
134
-                        if(!empty($checkModList[strtolower($e)])){
134
+                        if (!empty($checkModList[strtolower($e)])) {
135 135
                             //directory was lowercase, let's use the right module value
136 136
 							$e = $checkModList[strtolower($e)];
137 137
                         }
138 138
 
139
-					    if( is_array($merge) )
139
+					    if (is_array($merge))
140 140
 					    {
141
-					        if ( in_array($e,$merge) )
142
-					        	$this->merged[$e] = $this->mergeModule($e, TRUE, $save,$logHistory );
141
+					        if (in_array($e, $merge))
142
+					        	$this->merged[$e] = $this->mergeModule($e, TRUE, $save, $logHistory);
143 143
 					        else
144 144
 					        {
145 145
 					            $GLOBALS['log']->debug("SugarMerge is skipping $e module as filter array passed in but module not specified for merge.");
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					        }
148 148
 					    }
149 149
 					    else
150
-						  $this->merged[$e] = $this->mergeModule($e, $merge, $save,$logHistory );
150
+						  $this->merged[$e] = $this->mergeModule($e, $merge, $save, $logHistory);
151 151
 					}
152 152
 				}
153 153
 			}
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 	 * @param BOOLEAN $logHistory - do we wish to create history entries for any of the merges
170 170
 	 * @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
171 171
 	 */
172
-	function mergeModule($module, $merge = true, $save=true,$logHistory=true){
172
+	function mergeModule($module, $merge = true, $save = true, $logHistory = true) {
173 173
 		$merged = array();
174
-		$path = $this->original_path . 'modules/' . $module . '/metadata/';
175
-		$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
176
-		$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
177
-		foreach($this->mergeMapping as $file=>&$object){
178
-			if(file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
179
-				if($merge){
174
+		$path = $this->original_path.'modules/'.$module.'/metadata/';
175
+		$custom_path = $this->custom_path.'modules/'.$module.'/metadata/';
176
+		$new_path = $this->new_path.'modules/'.$module.'/metadata/';
177
+		foreach ($this->mergeMapping as $file=>&$object) {
178
+			if (file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")) {
179
+				if ($merge) {
180 180
 					$merged[$file] = $this->mergeFile($module, $file, $save, $logHistory);
181
-				}else{
181
+				} else {
182 182
 					$merged[$file] = true;
183 183
 				}
184 184
 			}
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
 	 * @param STRING $save - should the merged file be saved to the custom directory
197 197
 	 * @return BOOLEAN - success or failure of the merge
198 198
 	 */
199
-	function mergeFile($module, $file, $save=true,$logHistory=true){
200
-		$path = $this->original_path . 'modules/' . $module . '/metadata/';
201
-		$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
202
-		$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
203
-		if($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
204
-		if(isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
199
+	function mergeFile($module, $file, $save = true, $logHistory = true) {
200
+		$path = $this->original_path.'modules/'.$module.'/metadata/';
201
+		$custom_path = $this->custom_path.'modules/'.$module.'/metadata/';
202
+		$new_path = $this->new_path.'modules/'.$module.'/metadata/';
203
+		if ($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
204
+		if (isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")) {
205 205
 		    //Create a log entry of the custom file before it is merged
206
-		    if($logHistory && $save)
207
-		          $this->createHistoryLog($module, "{$custom_path}{$file}",$file);
206
+		    if ($logHistory && $save)
207
+		          $this->createHistoryLog($module, "{$custom_path}{$file}", $file);
208 208
             $this->mergeMapping[$file]->sugarMerge = $this;
209 209
 		    return $this->mergeMapping[$file]->merge($module, "{$path}{$file}", "{$new_path}{$file}", "{$custom_path}{$file}", $save);
210 210
 		}
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 	 * @param STRING $file - name of the file
221 221
 	 * @param STRING $customFile - Path to the custom file that will be merged
222 222
 	 */
223
-	protected function createHistoryLog($module,$customFile,$file)
223
+	protected function createHistoryLog($module, $customFile, $file)
224 224
 	{
225
-	    $historyPath = 'custom/' . MB_HISTORYMETADATALOCATION . "/modules/$module/metadata/$file";
225
+	    $historyPath = 'custom/'.MB_HISTORYMETADATALOCATION."/modules/$module/metadata/$file";
226 226
 	    $history = new History($historyPath);
227 227
 	    $timeStamp = $history->append($customFile);
228
-	    $GLOBALS['log']->debug("Created history file after merge with new file: " . $historyPath .'_'.$timeStamp);
228
+	    $GLOBALS['log']->debug("Created history file after merge with new file: ".$historyPath.'_'.$timeStamp);
229 229
 	}
230 230
 
231 231
 	/**
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -87,8 +89,7 @@  discard block
 block discarded – undo
87 89
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
88 90
         if(isset($GLOBALS['log'])) {
89 91
             $GLOBALS['log']->deprecated($deprecatedMessage);
90
-        }
91
-        else {
92
+        } else {
92 93
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
93 94
         }
94 95
         self::__construct($new_path, $original_path, $custom_path);
@@ -138,16 +139,16 @@  discard block
 block discarded – undo
138 139
 
139 140
 					    if( is_array($merge) )
140 141
 					    {
141
-					        if ( in_array($e,$merge) )
142
-					        	$this->merged[$e] = $this->mergeModule($e, TRUE, $save,$logHistory );
143
-					        else
142
+					        if ( in_array($e,$merge) ) {
143
+					        					        	$this->merged[$e] = $this->mergeModule($e, TRUE, $save,$logHistory );
144
+					        } else
144 145
 					        {
145 146
 					            $GLOBALS['log']->debug("SugarMerge is skipping $e module as filter array passed in but module not specified for merge.");
146 147
 					            continue;
147 148
 					        }
149
+					    } else {
150
+					    						  $this->merged[$e] = $this->mergeModule($e, $merge, $save,$logHistory );
148 151
 					    }
149
-					    else
150
-						  $this->merged[$e] = $this->mergeModule($e, $merge, $save,$logHistory );
151 152
 					}
152 153
 				}
153 154
 			}
@@ -178,7 +179,7 @@  discard block
 block discarded – undo
178 179
 			if(file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
179 180
 				if($merge){
180 181
 					$merged[$file] = $this->mergeFile($module, $file, $save, $logHistory);
181
-				}else{
182
+				} else{
182 183
 					$merged[$file] = true;
183 184
 				}
184 185
 			}
@@ -200,11 +201,14 @@  discard block
 block discarded – undo
200 201
 		$path = $this->original_path . 'modules/' . $module . '/metadata/';
201 202
 		$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
202 203
 		$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
203
-		if($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
204
+		if($this->fp) {
205
+		    $this->mergeMapping[$file]->setLogFilePointer($this->fp);
206
+		}
204 207
 		if(isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
205 208
 		    //Create a log entry of the custom file before it is merged
206
-		    if($logHistory && $save)
207
-		          $this->createHistoryLog($module, "{$custom_path}{$file}",$file);
209
+		    if($logHistory && $save) {
210
+		    		          $this->createHistoryLog($module, "{$custom_path}{$file}",$file);
211
+		    }
208 212
             $this->mergeMapping[$file]->sugarMerge = $this;
209 213
 		    return $this->mergeMapping[$file]->merge($module, "{$path}{$file}", "{$new_path}{$file}", "{$custom_path}{$file}", $save);
210 214
 		}
Please login to merge, or discard this patch.
modules/UpgradeWizard/uw_utils.php 1 patch
Indentation   +2716 added lines, -2716 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         return UploadFile::realpath($path);
93 93
     }
94 94
     if(substr($path, 0, 9) == "upload://") {
95
-    	$path = rtrim($GLOBALS['sugar_config']['upload_dir'], "/\\")."/".substr($path, 9);
95
+        $path = rtrim($GLOBALS['sugar_config']['upload_dir'], "/\\")."/".substr($path, 9);
96 96
     }
97 97
     return $path;
98 98
 }
@@ -108,49 +108,49 @@  discard block
 block discarded – undo
108 108
  * @return array errors
109 109
  */
110 110
 function commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, $errors, $path='') {
111
-	global $mod_strings;
112
-	// create restore file directory
113
-	sugar_mkdir($rest_dir, 0775, true);
111
+    global $mod_strings;
112
+    // create restore file directory
113
+    sugar_mkdir($rest_dir, 0775, true);
114 114
 
115 115
     if(file_exists($rest_dir) && is_dir($rest_dir)){
116
-		logThis('backing up files to be overwritten...', $path);
117
-		$newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array());
118
-
119
-		// keep this around for canceling
120
-		$_SESSION['uw_restore_dir'] = getUploadRelativeName($rest_dir);
121
-
122
-		foreach ($newFiles as $file) {
123
-			if (strpos($file, 'md5'))
124
-				continue;
125
-
126
-			// get name of current file to place in restore directory
127
-			$cleanFile = str_replace(clean_path($unzip_dir . '/' . $zip_from_dir), '', $file);
128
-
129
-			// make sure the directory exists
130
-			$cleanDir = $rest_dir . '/' . dirname($cleanFile);
131
-			sugar_mkdir($cleanDir, 0775, true);
132
-			$oldFile = clean_path(getcwd() . '/' . $cleanFile);
133
-
134
-			// only copy restore files for replacements - ignore new files from patch
135
-			if (is_file($oldFile)) {
136
-				if (is_writable($rest_dir)) {
137
-					logThis('Backing up file: ' . $oldFile, $path);
138
-					if (!copy($oldFile, $rest_dir . '/' . $cleanFile)) {
139
-						logThis('*** ERROR: could not backup file: ' . $oldFile, $path);
140
-						$errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_FILE_NOT_COPIED']}: {$oldFile}";
141
-					} else {
142
-						$backupFilesExist = true;
143
-					}
144
-
145
-				} else {
146
-					logThis('*** ERROR: directory not writable: ' . $rest_dir, $path);
147
-					$errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_DIR_NOT_WRITABLE']}: {$oldFile}";
148
-				}
149
-			}
150
-		}
116
+        logThis('backing up files to be overwritten...', $path);
117
+        $newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array());
118
+
119
+        // keep this around for canceling
120
+        $_SESSION['uw_restore_dir'] = getUploadRelativeName($rest_dir);
121
+
122
+        foreach ($newFiles as $file) {
123
+            if (strpos($file, 'md5'))
124
+                continue;
125
+
126
+            // get name of current file to place in restore directory
127
+            $cleanFile = str_replace(clean_path($unzip_dir . '/' . $zip_from_dir), '', $file);
128
+
129
+            // make sure the directory exists
130
+            $cleanDir = $rest_dir . '/' . dirname($cleanFile);
131
+            sugar_mkdir($cleanDir, 0775, true);
132
+            $oldFile = clean_path(getcwd() . '/' . $cleanFile);
133
+
134
+            // only copy restore files for replacements - ignore new files from patch
135
+            if (is_file($oldFile)) {
136
+                if (is_writable($rest_dir)) {
137
+                    logThis('Backing up file: ' . $oldFile, $path);
138
+                    if (!copy($oldFile, $rest_dir . '/' . $cleanFile)) {
139
+                        logThis('*** ERROR: could not backup file: ' . $oldFile, $path);
140
+                        $errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_FILE_NOT_COPIED']}: {$oldFile}";
141
+                    } else {
142
+                        $backupFilesExist = true;
143
+                    }
144
+
145
+                } else {
146
+                    logThis('*** ERROR: directory not writable: ' . $rest_dir, $path);
147
+                    $errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_DIR_NOT_WRITABLE']}: {$oldFile}";
148
+                }
149
+            }
150
+        }
151 151
     }
152
-	logThis('file backup done.', $path);
153
-	return $errors;
152
+    logThis('file backup done.', $path);
153
+    return $errors;
154 154
 }
155 155
 
156 156
 /**
@@ -165,82 +165,82 @@  discard block
 block discarded – undo
165 165
 
166 166
 
167 167
 function commitCopyNewFiles($unzip_dir, $zip_from_dir, $path='') {
168
-	logThis('Starting file copy process...', $path);
169
-	global $sugar_version;
170
-	$backwardModules='';
171
-
172
-    	$modules = getAllModules();
173
-			$backwardModules = array();
174
-			foreach($modules as $mod){
175
-				if(is_dir(clean_path(getcwd().'/modules/'.$mod.'/.500'))){
176
-					$files = array();
177
-			    	$files= findAllFiles(clean_path(getcwd().'/modules/'.$mod.'/.500'),$files);
178
-			    	if(sizeof($files) >0){
179
-			    		//backward compatibility is on
180
-						$backwardModules[] = $mod;
181
-			    	}
182
-			   }
183
-			}
184
-
185
-	$newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array());
186
-	$zipPath = clean_path($unzip_dir . '/' . $zip_from_dir);
187
-
188
-	// handle special do-not-overwrite conditions
189
-	$doNotOverwrite = array();
190
-	$doNotOverwrite[] = '__stub';
191
-	if(isset($_REQUEST['overwrite_files_serial'])) {
192
-		$doNotOverwrite = explode('::', $_REQUEST['overwrite_files_serial']);
193
-	}
168
+    logThis('Starting file copy process...', $path);
169
+    global $sugar_version;
170
+    $backwardModules='';
171
+
172
+        $modules = getAllModules();
173
+            $backwardModules = array();
174
+            foreach($modules as $mod){
175
+                if(is_dir(clean_path(getcwd().'/modules/'.$mod.'/.500'))){
176
+                    $files = array();
177
+                    $files= findAllFiles(clean_path(getcwd().'/modules/'.$mod.'/.500'),$files);
178
+                    if(sizeof($files) >0){
179
+                        //backward compatibility is on
180
+                        $backwardModules[] = $mod;
181
+                    }
182
+                }
183
+            }
194 184
 
195
-	$copiedFiles = array();
196
-	$skippedFiles = array();
197
-
198
-	foreach($newFiles as $file) {
199
-		$cleanFile = str_replace($zipPath, '', $file);
200
-		$srcFile = $zipPath . $cleanFile;
201
-		$targetFile = clean_path(getcwd() . '/' . $cleanFile);
202
-		if($backwardModules != null && sizeof($backwardModules) >0){
203
-			foreach($backwardModules as $mod){
204
-				$splitPath = explode('/',trim($cleanFile));
205
-				if('modules' == trim($splitPath[1]) && $mod == trim($splitPath[2])){
206
-					$cleanFile = str_replace('/modules/'.$mod, '/modules/'.$mod.'/.500', $cleanFile);
207
-					$targetFile = clean_path(getcwd() . '/' . $cleanFile);
208
-				}
209
-			}
210
-		}
211
-		if(!is_dir(dirname($targetFile))) {
212
-			mkdir_recursive(dirname($targetFile)); // make sure the directory exists
213
-		}
185
+    $newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array());
186
+    $zipPath = clean_path($unzip_dir . '/' . $zip_from_dir);
214 187
 
215
-		if((!file_exists($targetFile)) || /* brand new file */
216
-			(!in_array($targetFile, $doNotOverwrite)) /* manual diff file */
217
-			) {
218
-			// handle sugar_version.php
219
-			if(strpos($targetFile, 'sugar_version.php') !== false && !preg_match('/\/portal\/sugar_version\.php$/i', $targetFile)) {
220
-				logThis('Skipping "sugar_version.php" - file copy will occur at end of successful upgrade', $path);
221
-				$_SESSION['sugar_version_file'] = $srcFile;
222
-				continue;
223
-			}
224
-
225
-			//logThis('Copying file to destination: ' . $targetFile, $path);
226
-
227
-			if(!copy($srcFile, $targetFile)) {
228
-				logThis('*** ERROR: could not copy file: ' . $targetFile, $path);
229
-			} else {
230
-				$copiedFiles[] = $targetFile;
231
-			}
232
-		} else {
233
-			//logThis('Skipping file: ' . $targetFile, $path);
234
-			$skippedFiles[] = $targetFile;
235
-		}
236
-	}
237
-	logThis('File copy done.', $path);
188
+    // handle special do-not-overwrite conditions
189
+    $doNotOverwrite = array();
190
+    $doNotOverwrite[] = '__stub';
191
+    if(isset($_REQUEST['overwrite_files_serial'])) {
192
+        $doNotOverwrite = explode('::', $_REQUEST['overwrite_files_serial']);
193
+    }
194
+
195
+    $copiedFiles = array();
196
+    $skippedFiles = array();
197
+
198
+    foreach($newFiles as $file) {
199
+        $cleanFile = str_replace($zipPath, '', $file);
200
+        $srcFile = $zipPath . $cleanFile;
201
+        $targetFile = clean_path(getcwd() . '/' . $cleanFile);
202
+        if($backwardModules != null && sizeof($backwardModules) >0){
203
+            foreach($backwardModules as $mod){
204
+                $splitPath = explode('/',trim($cleanFile));
205
+                if('modules' == trim($splitPath[1]) && $mod == trim($splitPath[2])){
206
+                    $cleanFile = str_replace('/modules/'.$mod, '/modules/'.$mod.'/.500', $cleanFile);
207
+                    $targetFile = clean_path(getcwd() . '/' . $cleanFile);
208
+                }
209
+            }
210
+        }
211
+        if(!is_dir(dirname($targetFile))) {
212
+            mkdir_recursive(dirname($targetFile)); // make sure the directory exists
213
+        }
214
+
215
+        if((!file_exists($targetFile)) || /* brand new file */
216
+            (!in_array($targetFile, $doNotOverwrite)) /* manual diff file */
217
+            ) {
218
+            // handle sugar_version.php
219
+            if(strpos($targetFile, 'sugar_version.php') !== false && !preg_match('/\/portal\/sugar_version\.php$/i', $targetFile)) {
220
+                logThis('Skipping "sugar_version.php" - file copy will occur at end of successful upgrade', $path);
221
+                $_SESSION['sugar_version_file'] = $srcFile;
222
+                continue;
223
+            }
224
+
225
+            //logThis('Copying file to destination: ' . $targetFile, $path);
226
+
227
+            if(!copy($srcFile, $targetFile)) {
228
+                logThis('*** ERROR: could not copy file: ' . $targetFile, $path);
229
+            } else {
230
+                $copiedFiles[] = $targetFile;
231
+            }
232
+        } else {
233
+            //logThis('Skipping file: ' . $targetFile, $path);
234
+            $skippedFiles[] = $targetFile;
235
+        }
236
+    }
237
+    logThis('File copy done.', $path);
238 238
 
239
-	$ret = array();
240
-	$ret['copiedFiles'] = $copiedFiles;
241
-	$ret['skippedFiles'] = $skippedFiles;
239
+    $ret = array();
240
+    $ret['copiedFiles'] = $copiedFiles;
241
+    $ret['skippedFiles'] = $skippedFiles;
242 242
 
243
-	return $ret;
243
+    return $ret;
244 244
 }
245 245
 
246 246
 
@@ -252,31 +252,31 @@  discard block
 block discarded – undo
252 252
 
253 253
 
254 254
 function removeFileFromPath($file,$path, $deleteNot=array()){
255
-		$removed = 0;
256
-		$cur = $path . '/' . $file;
257
-		if(file_exists($cur)){
258
-			$del = true;
259
-			foreach($deleteNot as $dn){
260
-				if($cur == $dn){
261
-					$del = false;
262
-				}
263
-			}
264
-			if($del){
265
-				unlink($cur);
266
-				$removed++;
267
-			}
268
-		}
269
-		if(!file_exists($path))return $removed;
270
-		$d = dir($path);
271
-		while(false !== ($e = $d->read())){  // Fixed bug. !== is required to literally match the type and value of false, so that a filename that could evaluate and cast to false, ie "false" or "0", still allows the while loop to continue.  From example at http://www.php.net/manual/en/function.dir.php
272
-			$next = $path . '/'. $e;
273
-			if(substr($e, 0, 1) != '.' && is_dir($next)){
274
-				$removed += removeFileFromPath($file, $next, $deleteNot);
275
-			}
276
-		}
277
-		$d->close();  // from example at http://www.php.net/manual/en/function.dir.php
278
-		return $removed;
279
-	}
255
+        $removed = 0;
256
+        $cur = $path . '/' . $file;
257
+        if(file_exists($cur)){
258
+            $del = true;
259
+            foreach($deleteNot as $dn){
260
+                if($cur == $dn){
261
+                    $del = false;
262
+                }
263
+            }
264
+            if($del){
265
+                unlink($cur);
266
+                $removed++;
267
+            }
268
+        }
269
+        if(!file_exists($path))return $removed;
270
+        $d = dir($path);
271
+        while(false !== ($e = $d->read())){  // Fixed bug. !== is required to literally match the type and value of false, so that a filename that could evaluate and cast to false, ie "false" or "0", still allows the while loop to continue.  From example at http://www.php.net/manual/en/function.dir.php
272
+            $next = $path . '/'. $e;
273
+            if(substr($e, 0, 1) != '.' && is_dir($next)){
274
+                $removed += removeFileFromPath($file, $next, $deleteNot);
275
+            }
276
+        }
277
+        $d->close();  // from example at http://www.php.net/manual/en/function.dir.php
278
+        return $removed;
279
+    }
280 280
 
281 281
 /**
282 282
  * This function copies/overwrites between directories
@@ -287,32 +287,32 @@  discard block
 block discarded – undo
287 287
  */
288 288
 
289 289
 function copyRecursiveBetweenDirectories($from,$to){
290
-	if(file_exists($from)){
291
-		$modifiedFiles = array();
292
-		$modifiedFiles = findAllFiles(clean_path($from), $modifiedFiles);
293
-	 	$cwd = clean_path(getcwd());
294
-		foreach($modifiedFiles as $file) {
295
-			$srcFile = clean_path($file);
290
+    if(file_exists($from)){
291
+        $modifiedFiles = array();
292
+        $modifiedFiles = findAllFiles(clean_path($from), $modifiedFiles);
293
+            $cwd = clean_path(getcwd());
294
+        foreach($modifiedFiles as $file) {
295
+            $srcFile = clean_path($file);
296 296
             if (strpos($srcFile,".svn") === false) {
297
-	    		$targetFile = str_replace($from, $to, $srcFile);
298
-
299
-				if(!is_dir(dirname($targetFile))) {
300
-					mkdir_recursive(dirname($targetFile)); // make sure the directory exists
301
-				}
302
-
303
-					// handle sugar_version.php
304
-					if(strpos($targetFile, 'sugar_version.php') !== false && !preg_match('/\/portal\/sugar_version\.php$/i', $targetFile)) {
305
-						logThis('Skipping "sugar_version.php" - file copy will occur at end of successful upgrade', $targetFile);
306
-						$_SESSION['sugar_version_file'] = $srcFile;
307
-						continue;
308
-					}
309
-
310
-					if(!copy($srcFile, $targetFile)) {
311
-						logThis("*** ERROR: could not copy file $srcFile to $targetFile");
312
-					}
313
-            	}
314
-		 }
315
-	}
297
+                $targetFile = str_replace($from, $to, $srcFile);
298
+
299
+                if(!is_dir(dirname($targetFile))) {
300
+                    mkdir_recursive(dirname($targetFile)); // make sure the directory exists
301
+                }
302
+
303
+                    // handle sugar_version.php
304
+                    if(strpos($targetFile, 'sugar_version.php') !== false && !preg_match('/\/portal\/sugar_version\.php$/i', $targetFile)) {
305
+                        logThis('Skipping "sugar_version.php" - file copy will occur at end of successful upgrade', $targetFile);
306
+                        $_SESSION['sugar_version_file'] = $srcFile;
307
+                        continue;
308
+                    }
309
+
310
+                    if(!copy($srcFile, $targetFile)) {
311
+                        logThis("*** ERROR: could not copy file $srcFile to $targetFile");
312
+                    }
313
+                }
314
+            }
315
+    }
316 316
 }
317 317
 
318 318
 function deleteDirectory($dirname,$only_empty=false) {
@@ -352,50 +352,50 @@  discard block
 block discarded – undo
352 352
  */
353 353
 
354 354
 function deleteAndOverWriteSelectedFiles($unzip_dir, $zip_from_dir,$delete_dirs){
355
-	if($delete_dirs != null){
356
-		foreach($delete_dirs as $del_dir){
357
-			deleteDirectory($del_dir);
358
-			$newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir.'/'.$del_dir), array());
359
-			$zipPath = clean_path($unzip_dir . '/' . $zip_from_dir.'/'.$del_dir);
360
-			$copiedFiles = array();
361
-			$skippedFiles = array();
362
-
363
-			foreach($newFiles as $file) {
364
-				$cleanFile = str_replace($zipPath, '', $file);
365
-				$srcFile = $zipPath . $cleanFile;
366
-				$targetFile = clean_path(getcwd() . '/' . $cleanFile);
367
-
368
-				if(!is_dir(dirname($targetFile))) {
369
-					mkdir_recursive(dirname($targetFile)); // make sure the directory exists
370
-				}
371
-
372
-				if(!file_exists($targetFile)){
373
-					// handle sugar_version.php
374
-					if(strpos($targetFile, 'sugar_version.php') !== false) {
375
-						logThis('Skipping sugar_version.php - file copy will occur at end of successful upgrade');
376
-						$_SESSION['sugar_version_file'] = $srcFile;
377
-						continue;
378
-					}
379
-
380
-					//logThis('Copying file to destination: ' . $targetFile);
381
-
382
-					if(!copy($srcFile, $targetFile)) {
383
-						logThis('*** ERROR: could not copy file: ' . $targetFile);
384
-					} else {
385
-						$copiedFiles[] = $targetFile;
386
-					}
387
-				} else {
388
-					//logThis('Skipping file: ' . $targetFile);
389
-					$skippedFiles[] = $targetFile;
390
-				}
391
-			  }
392
-		}
393
-	}
394
-	$ret = array();
395
-	$ret['copiedFiles'] = $copiedFiles;
396
-	$ret['skippedFiles'] = $skippedFiles;
355
+    if($delete_dirs != null){
356
+        foreach($delete_dirs as $del_dir){
357
+            deleteDirectory($del_dir);
358
+            $newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir.'/'.$del_dir), array());
359
+            $zipPath = clean_path($unzip_dir . '/' . $zip_from_dir.'/'.$del_dir);
360
+            $copiedFiles = array();
361
+            $skippedFiles = array();
362
+
363
+            foreach($newFiles as $file) {
364
+                $cleanFile = str_replace($zipPath, '', $file);
365
+                $srcFile = $zipPath . $cleanFile;
366
+                $targetFile = clean_path(getcwd() . '/' . $cleanFile);
367
+
368
+                if(!is_dir(dirname($targetFile))) {
369
+                    mkdir_recursive(dirname($targetFile)); // make sure the directory exists
370
+                }
371
+
372
+                if(!file_exists($targetFile)){
373
+                    // handle sugar_version.php
374
+                    if(strpos($targetFile, 'sugar_version.php') !== false) {
375
+                        logThis('Skipping sugar_version.php - file copy will occur at end of successful upgrade');
376
+                        $_SESSION['sugar_version_file'] = $srcFile;
377
+                        continue;
378
+                    }
379
+
380
+                    //logThis('Copying file to destination: ' . $targetFile);
381
+
382
+                    if(!copy($srcFile, $targetFile)) {
383
+                        logThis('*** ERROR: could not copy file: ' . $targetFile);
384
+                    } else {
385
+                        $copiedFiles[] = $targetFile;
386
+                    }
387
+                } else {
388
+                    //logThis('Skipping file: ' . $targetFile);
389
+                    $skippedFiles[] = $targetFile;
390
+                }
391
+                }
392
+        }
393
+    }
394
+    $ret = array();
395
+    $ret['copiedFiles'] = $copiedFiles;
396
+    $ret['skippedFiles'] = $skippedFiles;
397 397
 
398
-	return $ret;
398
+    return $ret;
399 399
 }
400 400
 
401 401
 //Default is empty the directory. For removing set it to false
@@ -407,78 +407,78 @@  discard block
 block discarded – undo
407 407
 
408 408
 function recursive_empty_or_remove_directory($directory, $exclude_dirs=null,$exclude_files=null,$empty=TRUE)
409 409
 {
410
-	// if the path has a slash at the end we remove it here
411
-	if(substr($directory,-1) == '/')
412
-	{
413
-		$directory = substr($directory,0,-1);
414
-	}
410
+    // if the path has a slash at the end we remove it here
411
+    if(substr($directory,-1) == '/')
412
+    {
413
+        $directory = substr($directory,0,-1);
414
+    }
415 415
 
416
-	// if the path is not valid or is not a directory ...
417
-	if(!file_exists($directory) || !is_dir($directory))
418
-	{
419
-		// ... we return false and exit the function
420
-		return FALSE;
421
-
422
-	// ... if the path is not readable
423
-	}elseif(!is_readable($directory))
424
-	{
425
-		// ... we return false and exit the function
426
-		return FALSE;
427
-
428
-	// ... else if the path is readable
429
-	}else{
430
-
431
-		// we open the directory
432
-		$handle = opendir($directory);
433
-
434
-		// and scan through the items inside
435
-		while (FALSE !== ($item = readdir($handle)))
436
-		{
437
-			// if the filepointer is not the current directory
438
-			// or the parent directory
439
-			if($item != '.' && $item != '..')
440
-			{
441
-				// we build the new path to delete
442
-				$path = $directory.'/'.$item;
443
-
444
-				// if the new path is a directory
445
-				//add another check if the dir is in the list to exclude delete
446
-				if(is_dir($path) && $exclude_dirs != null && in_array($path,$exclude_dirs)){
447
-				    //do nothing
448
-				}
449
-				else if(is_dir($path))
450
-				{
451
-					// we call this function with the new path
452
-					recursive_empty_or_remove_directory($path);
453
-				}
454
-				// if the new path is a file
455
-				else{
456
-					// we remove the file
457
-					if($exclude_files != null && in_array($path,$exclude_files)){
458
-                           //do nothing
459
-					}
460
-					else{
461
-						unlink($path);
462
-				    }
463
-				}
464
-			}
465
-		}
466
-		// close the directory
467
-		closedir($handle);
468
-
469
-		// if the option to empty is not set to true
470
-		if($empty == FALSE)
471
-		{
472
-			// try to delete the now empty directory
473
-			if(!rmdir($directory))
474
-			{
475
-				// return false if not possible
476
-				return FALSE;
477
-			}
478
-		}
479
-		// return success
480
-		return TRUE;
481
-	}
416
+    // if the path is not valid or is not a directory ...
417
+    if(!file_exists($directory) || !is_dir($directory))
418
+    {
419
+        // ... we return false and exit the function
420
+        return FALSE;
421
+
422
+    // ... if the path is not readable
423
+    }elseif(!is_readable($directory))
424
+    {
425
+        // ... we return false and exit the function
426
+        return FALSE;
427
+
428
+    // ... else if the path is readable
429
+    }else{
430
+
431
+        // we open the directory
432
+        $handle = opendir($directory);
433
+
434
+        // and scan through the items inside
435
+        while (FALSE !== ($item = readdir($handle)))
436
+        {
437
+            // if the filepointer is not the current directory
438
+            // or the parent directory
439
+            if($item != '.' && $item != '..')
440
+            {
441
+                // we build the new path to delete
442
+                $path = $directory.'/'.$item;
443
+
444
+                // if the new path is a directory
445
+                //add another check if the dir is in the list to exclude delete
446
+                if(is_dir($path) && $exclude_dirs != null && in_array($path,$exclude_dirs)){
447
+                    //do nothing
448
+                }
449
+                else if(is_dir($path))
450
+                {
451
+                    // we call this function with the new path
452
+                    recursive_empty_or_remove_directory($path);
453
+                }
454
+                // if the new path is a file
455
+                else{
456
+                    // we remove the file
457
+                    if($exclude_files != null && in_array($path,$exclude_files)){
458
+                            //do nothing
459
+                    }
460
+                    else{
461
+                        unlink($path);
462
+                    }
463
+                }
464
+            }
465
+        }
466
+        // close the directory
467
+        closedir($handle);
468
+
469
+        // if the option to empty is not set to true
470
+        if($empty == FALSE)
471
+        {
472
+            // try to delete the now empty directory
473
+            if(!rmdir($directory))
474
+            {
475
+                // return false if not possible
476
+                return FALSE;
477
+            }
478
+        }
479
+        // return success
480
+        return TRUE;
481
+    }
482 482
 }
483 483
 // ------------------------------------------------------------
484 484
 
@@ -487,80 +487,80 @@  discard block
 block discarded – undo
487 487
 
488 488
 function getAllCustomizedModules() {
489 489
 
490
-		require_once('files.md5');
491
-
492
-	    $return_array = array();
493
-	    $modules = getAllModules();
494
-	    foreach($modules as $mod) {
495
-	    	   //find all files in each module if the files have been modified
496
-	    	   //as compared to the base version then add the module to the
497
-	    	   //customized modules array
498
-	    	   $modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array());
499
-               foreach($modFiles as $file){
500
-             	  $fileContents = file_get_contents($file);
501
-             	   $file = str_replace(clean_path(getcwd()),'',$file);
502
-               	  if($md5_string['./' . $file]){
503
-	               	  if(md5($fileContents) != $md5_string['./' . $file]) {
504
-	               	     //A file has been customized in the module. Put the module into the
505
-	               	     // customized modules array.
506
-	               	     echo 'Changed File'.$file;
507
-	               	  	  $return_array[$mod];
508
-	               	  	  break;
509
-	               	  }
510
-               	  }
511
-               	  else{
512
-               	  	// This is a new file in user's version and indicates that module has been
513
-               	  	//customized. Put the module in the customized array.
514
-                       echo 'New File'.$file;
515
-                       $return_array[$mod];
516
-                       break;
517
-               	  }
518
-               }
519
-	    } //foreach
520
-
521
-		return $return_array;
522
-	}
490
+        require_once('files.md5');
491
+
492
+        $return_array = array();
493
+        $modules = getAllModules();
494
+        foreach($modules as $mod) {
495
+                //find all files in each module if the files have been modified
496
+                //as compared to the base version then add the module to the
497
+                //customized modules array
498
+                $modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array());
499
+                foreach($modFiles as $file){
500
+                    $fileContents = file_get_contents($file);
501
+                    $file = str_replace(clean_path(getcwd()),'',$file);
502
+                        if($md5_string['./' . $file]){
503
+                            if(md5($fileContents) != $md5_string['./' . $file]) {
504
+                            //A file has been customized in the module. Put the module into the
505
+                            // customized modules array.
506
+                            echo 'Changed File'.$file;
507
+                                $return_array[$mod];
508
+                                break;
509
+                            }
510
+                        }
511
+                        else{
512
+                            // This is a new file in user's version and indicates that module has been
513
+                            //customized. Put the module in the customized array.
514
+                        echo 'New File'.$file;
515
+                        $return_array[$mod];
516
+                        break;
517
+                        }
518
+                }
519
+        } //foreach
520
+
521
+        return $return_array;
522
+    }
523 523
 
524 524
     /**
525 525
      * Array of all Modules in the version bein upgraded
526 526
      * This method returns an Array of all modules
527 527
      * @return $modules Array of modules.
528 528
      */
529
-	function getAllModules() {
530
-		$modules = array();
531
-		$d = dir('modules');
532
-		while($e = $d->read()){
533
-			if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
534
-			$modules[] = $e;
535
-		}
536
-		return $modules;
537
-	}
529
+    function getAllModules() {
530
+        $modules = array();
531
+        $d = dir('modules');
532
+        while($e = $d->read()){
533
+            if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
534
+            $modules[] = $e;
535
+        }
536
+        return $modules;
537
+    }
538 538
 
539 539
 //Remove files with the smae md5
540 540
 
541 541
 function removeMd5MatchingFiles($deleteNot=array()){
542 542
 
543
-	$md5_string = array();
544
-	if(file_exists(clean_path(getcwd().'/files.md5'))){
545
-		require(clean_path(getcwd().'/files.md5'));
546
-	}
543
+    $md5_string = array();
544
+    if(file_exists(clean_path(getcwd().'/files.md5'))){
545
+        require(clean_path(getcwd().'/files.md5'));
546
+    }
547 547
     $modulesAll = getAllModules();
548
-     foreach($modulesAll as $mod){
549
-	      $allModFiles = array();
550
-	      if(is_dir('modules/'.$mod)){
551
-	      $allModFiles = findAllFiles('modules/'.$mod,$allModFiles);
552
-	       foreach($allModFiles as $file){
553
-	           	if(file_exists($file) && !in_array(basename($file),$deleteNot)){
554
-		       		 if(isset($md5_string['./'.$file])) {
555
-		                  $fileContents = file_get_contents($file);
556
-		               	  if(md5($fileContents) == $md5_string['./'.$file]) {
557
-		               	  	unlink($file);
558
-		               	  }
559
-		              }
560
-	            }
561
-           }
562
-	   }
563
-   }
548
+        foreach($modulesAll as $mod){
549
+            $allModFiles = array();
550
+            if(is_dir('modules/'.$mod)){
551
+            $allModFiles = findAllFiles('modules/'.$mod,$allModFiles);
552
+            foreach($allModFiles as $file){
553
+                    if(file_exists($file) && !in_array(basename($file),$deleteNot)){
554
+                        if(isset($md5_string['./'.$file])) {
555
+                            $fileContents = file_get_contents($file);
556
+                                if(md5($fileContents) == $md5_string['./'.$file]) {
557
+                                    unlink($file);
558
+                                }
559
+                        }
560
+                }
561
+            }
562
+        }
563
+    }
564 564
 }
565 565
 
566 566
 /**
@@ -569,128 +569,128 @@  discard block
 block discarded – undo
569 569
  * @param string path Optional full path to alternate upgradeWizard log.
570 570
  */
571 571
 function commitHandleReminders($skippedFiles, $path='') {
572
-	global $mod_strings;
573
-	global $current_user;
572
+    global $mod_strings;
573
+    global $current_user;
574 574
 
575
-	if(empty($mod_strings))
576
-		$mod_strings = return_module_language('en_us', 'UpgradeWizard');
575
+    if(empty($mod_strings))
576
+        $mod_strings = return_module_language('en_us', 'UpgradeWizard');
577 577
 
578
-	if(empty($current_user->id)) {
579
-		$current_user->getSystemUser();
580
-	}
578
+    if(empty($current_user->id)) {
579
+        $current_user->getSystemUser();
580
+    }
581 581
 
582
-	if(count($skippedFiles) > 0) {
583
-		$desc = $mod_strings['LBL_UW_COMMIT_ADD_TASK_OVERVIEW'] . "\n\n";
584
-		$desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_1'];
585
-		$desc .= $_SESSION['uw_restore_dir'] . "\n\n";
586
-		$desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_2'] . "\n\n";
582
+    if(count($skippedFiles) > 0) {
583
+        $desc = $mod_strings['LBL_UW_COMMIT_ADD_TASK_OVERVIEW'] . "\n\n";
584
+        $desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_1'];
585
+        $desc .= $_SESSION['uw_restore_dir'] . "\n\n";
586
+        $desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_2'] . "\n\n";
587 587
 
588
-		foreach($skippedFiles as $file) {
589
-			$desc .= $file . "\n";
590
-		}
588
+        foreach($skippedFiles as $file) {
589
+            $desc .= $file . "\n";
590
+        }
591 591
 
592
-		//MFH #13468
593
-		/// Not using new TimeDate stuff here because it needs to be compatible with 6.0
594
-		$nowDate = gmdate('Y-m-d');
595
-		$nowTime = gmdate('H:i:s');
596
-		$nowDateTime = $nowDate . ' ' . $nowTime;
597
-
598
-		if($_REQUEST['addTaskReminder'] == 'remind') {
599
-			logThis('Adding Task for admin for manual merge.', $path);
600
-
601
-			$task = new Task();
602
-			$task->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
603
-			$task->description = $desc;
604
-			$task->date_due = $nowDate;
605
-			$task->time_due = $nowTime;
606
-			$task->priority = 'High';
607
-			$task->status = 'Not Started';
608
-			$task->assigned_user_id = $current_user->id;
609
-			$task->created_by = $current_user->id;
610
-			$task->date_entered = $nowDateTime;
611
-			$task->date_modified = $nowDateTime;
612
-			$task->save();
613
-		}
592
+        //MFH #13468
593
+        /// Not using new TimeDate stuff here because it needs to be compatible with 6.0
594
+        $nowDate = gmdate('Y-m-d');
595
+        $nowTime = gmdate('H:i:s');
596
+        $nowDateTime = $nowDate . ' ' . $nowTime;
597
+
598
+        if($_REQUEST['addTaskReminder'] == 'remind') {
599
+            logThis('Adding Task for admin for manual merge.', $path);
600
+
601
+            $task = new Task();
602
+            $task->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
603
+            $task->description = $desc;
604
+            $task->date_due = $nowDate;
605
+            $task->time_due = $nowTime;
606
+            $task->priority = 'High';
607
+            $task->status = 'Not Started';
608
+            $task->assigned_user_id = $current_user->id;
609
+            $task->created_by = $current_user->id;
610
+            $task->date_entered = $nowDateTime;
611
+            $task->date_modified = $nowDateTime;
612
+            $task->save();
613
+        }
614 614
 
615
-		if($_REQUEST['addEmailReminder'] == 'remind') {
616
-			logThis('Sending Reminder for admin for manual merge.', $path);
617
-
618
-			$email = new Email();
619
-			$email->assigned_user_id = $current_user->id;
620
-			$email->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
621
-			$email->description = $desc;
622
-			$email->description_html = nl2br($desc);
623
-			$email->from_name = $current_user->full_name;
624
-			$email->from_addr = $current_user->email1;
625
-			$email->to_addrs_arr = $email->parse_addrs($current_user->email1, '', '', '');
626
-			$email->cc_addrs_arr = array();
627
-			$email->bcc_addrs_arr = array();
628
-			$email->date_entered = $nowDateTime;
629
-			$email->date_modified = $nowDateTime;
630
-			$email->send();
631
-			$email->save();
632
-		}
633
-	}
615
+        if($_REQUEST['addEmailReminder'] == 'remind') {
616
+            logThis('Sending Reminder for admin for manual merge.', $path);
617
+
618
+            $email = new Email();
619
+            $email->assigned_user_id = $current_user->id;
620
+            $email->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
621
+            $email->description = $desc;
622
+            $email->description_html = nl2br($desc);
623
+            $email->from_name = $current_user->full_name;
624
+            $email->from_addr = $current_user->email1;
625
+            $email->to_addrs_arr = $email->parse_addrs($current_user->email1, '', '', '');
626
+            $email->cc_addrs_arr = array();
627
+            $email->bcc_addrs_arr = array();
628
+            $email->date_entered = $nowDateTime;
629
+            $email->date_modified = $nowDateTime;
630
+            $email->send();
631
+            $email->save();
632
+        }
633
+    }
634 634
 }
635 635
 
636 636
 function deleteCache(){
637
-	//Clean modules from cache
638
-	$cachedir = sugar_cached('modules');
639
-	if(is_dir($cachedir)){
640
-		$allModFiles = array();
641
-		$allModFiles = findAllFiles($cachedir,$allModFiles, true);
642
-		foreach($allModFiles as $file) {
643
-	       	if(file_exists($file)) {
644
-	       		if(is_dir($file)) {
645
-				  rmdir_recursive($file);
646
-	       		} else {
647
-	       		  unlink($file);
648
-               }
649
-	       	}
650
-	    }
637
+    //Clean modules from cache
638
+    $cachedir = sugar_cached('modules');
639
+    if(is_dir($cachedir)){
640
+        $allModFiles = array();
641
+        $allModFiles = findAllFiles($cachedir,$allModFiles, true);
642
+        foreach($allModFiles as $file) {
643
+                if(file_exists($file)) {
644
+                    if(is_dir($file)) {
645
+                    rmdir_recursive($file);
646
+                    } else {
647
+                        unlink($file);
648
+                }
649
+                }
650
+        }
651 651
 
652
-	}
652
+    }
653 653
 
654
-	//Clean jsLanguage from cache
655
-	$cachedir = sugar_cached('jsLanguage');
656
-	if(is_dir($cachedir)){
657
-		$allModFiles = array();
658
-		$allModFiles = findAllFiles($cachedir,$allModFiles);
659
-	   foreach($allModFiles as $file){
660
-		   	if(file_exists($file)){
661
-				unlink($file);
662
-		   	}
663
-		}
664
-	}
665
-	//Clean smarty from cache
666
-	$cachedir = sugar_cached('smarty');
667
-	if(is_dir($cachedir)){
668
-		$allModFiles = array();
669
-		$allModFiles = findAllFiles($cachedir,$allModFiles);
670
-	   foreach($allModFiles as $file){
671
-	       	if(file_exists($file)){
672
-				unlink($file);
673
-	       	}
674
-	   }
675
-	}
676
-	//Rebuild dashlets cache
677
-	require_once('include/Dashlets/DashletCacheBuilder.php');
678
-	$dc = new DashletCacheBuilder();
654
+    //Clean jsLanguage from cache
655
+    $cachedir = sugar_cached('jsLanguage');
656
+    if(is_dir($cachedir)){
657
+        $allModFiles = array();
658
+        $allModFiles = findAllFiles($cachedir,$allModFiles);
659
+        foreach($allModFiles as $file){
660
+                if(file_exists($file)){
661
+                unlink($file);
662
+                }
663
+        }
664
+    }
665
+    //Clean smarty from cache
666
+    $cachedir = sugar_cached('smarty');
667
+    if(is_dir($cachedir)){
668
+        $allModFiles = array();
669
+        $allModFiles = findAllFiles($cachedir,$allModFiles);
670
+        foreach($allModFiles as $file){
671
+                if(file_exists($file)){
672
+                unlink($file);
673
+                }
674
+        }
675
+    }
676
+    //Rebuild dashlets cache
677
+    require_once('include/Dashlets/DashletCacheBuilder.php');
678
+    $dc = new DashletCacheBuilder();
679 679
     $dc->buildCache();
680 680
 }
681 681
 
682 682
 function deleteChance(){
683
-	//Clean folder from cache
684
-	if(is_dir('include/SugarObjects/templates/chance')){
685
-		rmdir_recursive('include/SugarObjects/templates/chance');
686
-	 }
687
-	if(is_dir('include/SugarObjects/templates/chance')){
688
-		if(!isset($_SESSION['chance'])){
689
-			$_SESSION['chance'] = '';
690
-		}
691
-		$_SESSION['chance'] = 'include/SugarObjects/templates/chance';
692
-		//rename('include/SugarObjects/templates/chance','include/SugarObjects/templates/chance_removeit');
693
-	}
683
+    //Clean folder from cache
684
+    if(is_dir('include/SugarObjects/templates/chance')){
685
+        rmdir_recursive('include/SugarObjects/templates/chance');
686
+        }
687
+    if(is_dir('include/SugarObjects/templates/chance')){
688
+        if(!isset($_SESSION['chance'])){
689
+            $_SESSION['chance'] = '';
690
+        }
691
+        $_SESSION['chance'] = 'include/SugarObjects/templates/chance';
692
+        //rename('include/SugarObjects/templates/chance','include/SugarObjects/templates/chance_removeit');
693
+    }
694 694
 }
695 695
 
696 696
 
@@ -704,17 +704,17 @@  discard block
 block discarded – undo
704 704
 function upgradeUWFiles($file) {
705 705
     $cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached("upgrades/temp"));
706 706
 
707
-	unzip($file, $cacheUploadUpgradesTemp);
707
+    unzip($file, $cacheUploadUpgradesTemp);
708 708
 
709
-	if(!file_exists("$cacheUploadUpgradesTemp/manifest.php")) {
710
-		logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
711
-		return;
712
-	} else {
713
-		include("$cacheUploadUpgradesTemp/manifest.php");
714
-	}
709
+    if(!file_exists("$cacheUploadUpgradesTemp/manifest.php")) {
710
+        logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
711
+        return;
712
+    } else {
713
+        include("$cacheUploadUpgradesTemp/manifest.php");
714
+    }
715 715
 
716
-	$allFiles = array();
717
-	$from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
716
+    $allFiles = array();
717
+    $from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
718 718
 
719 719
     // Localization
720 720
     if(file_exists("$from_dir/include/Localization/Localization.php")) {
@@ -773,25 +773,25 @@  discard block
 block discarded – undo
773 773
  */
774 774
 function upgradeUWFilesCopy($allFiles, $from_dir)
775 775
 {
776
-   foreach($allFiles as $file)
777
-   {
778
-       if(is_array($file))
779
-       {
780
-           upgradeUWFilesCopy($file, $from_dir);
781
-       } else {
782
-           $destFile = str_replace($from_dir."/", "", $file);
783
-           if(!is_dir(dirname($destFile))) {
784
-              mkdir_recursive(dirname($destFile)); // make sure the directory exists
785
-           }
786
-
787
-           if(stristr($file,'uw_main.tpl'))
788
-              logThis('Skipping "'.$file.'" - file copy will during commit step.');
789
-           else {
790
-              logThis('updating UpgradeWizard code: '.$destFile);
791
-              copy_recursive($file, $destFile);
792
-           }
793
-       }
794
-   }
776
+    foreach($allFiles as $file)
777
+    {
778
+        if(is_array($file))
779
+        {
780
+            upgradeUWFilesCopy($file, $from_dir);
781
+        } else {
782
+            $destFile = str_replace($from_dir."/", "", $file);
783
+            if(!is_dir(dirname($destFile))) {
784
+                mkdir_recursive(dirname($destFile)); // make sure the directory exists
785
+            }
786
+
787
+            if(stristr($file,'uw_main.tpl'))
788
+                logThis('Skipping "'.$file.'" - file copy will during commit step.');
789
+            else {
790
+                logThis('updating UpgradeWizard code: '.$destFile);
791
+                copy_recursive($file, $destFile);
792
+            }
793
+        }
794
+    }
795 795
 }
796 796
 
797 797
 
@@ -800,22 +800,22 @@  discard block
 block discarded – undo
800 800
  * gets valid patch file names that exist in upload/upgrade/patch/
801 801
  */
802 802
 function getValidPatchName($returnFull = true) {
803
-	global $base_upgrade_dir;
804
-	global $mod_strings;
805
-	global $uh;
806
-	global $sugar_version;
803
+    global $base_upgrade_dir;
804
+    global $mod_strings;
805
+    global $uh;
806
+    global $sugar_version;
807 807
     global $sugar_config;
808 808
     $uh = new UpgradeHistory();
809 809
     list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
810 810
     $return = array();
811 811
 
812
-	// scan for new files (that are not installed)
813
-	logThis('finding new files for upgrade');
814
-	$upgrade_content = '';
815
-	$upgrade_contents = findAllFiles($base_upgrade_dir, array(), false, 'zip');
816
-	//other variations of zip file i.e. ZIP, zIp,zIP,Zip,ZIp,ZiP
817
-	$ready = "<ul>\n";
818
-	$ready .= "
812
+    // scan for new files (that are not installed)
813
+    logThis('finding new files for upgrade');
814
+    $upgrade_content = '';
815
+    $upgrade_contents = findAllFiles($base_upgrade_dir, array(), false, 'zip');
816
+    //other variations of zip file i.e. ZIP, zIp,zIP,Zip,ZIp,ZiP
817
+    $ready = "<ul>\n";
818
+    $ready .= "
819 819
 		<table>
820 820
 			<tr>
821 821
 				<td></td>
@@ -838,79 +838,79 @@  discard block
 block discarded – undo
838 838
 					<b>{$mod_strings['LBL_ML_DESCRIPTION']}</b>
839 839
 				</td>
840 840
 			</tr>";
841
-	$disabled = '';
842
-
843
-	// assume old patches are there.
844
-	$upgradeToVersion = array(); // fill with valid patches - we will only use the latest qualified found patch
845
-
846
-	// cn: bug 10609 - notices for uninitialized variables
847
-	$icon = '';
848
-	$name = '';
849
-	$type = '';
850
-	$version = '';
851
-	$published_date = '';
852
-	$uninstallable = '';
853
-	$description = '';
854
-	$disabled = '';
855
-
856
-	foreach($upgrade_contents as $upgrade_content) {
857
-		if(!preg_match("#.*\.zip\$#i", $upgrade_content)) {
858
-			continue;
859
-		}
841
+    $disabled = '';
842
+
843
+    // assume old patches are there.
844
+    $upgradeToVersion = array(); // fill with valid patches - we will only use the latest qualified found patch
845
+
846
+    // cn: bug 10609 - notices for uninitialized variables
847
+    $icon = '';
848
+    $name = '';
849
+    $type = '';
850
+    $version = '';
851
+    $published_date = '';
852
+    $uninstallable = '';
853
+    $description = '';
854
+    $disabled = '';
855
+
856
+    foreach($upgrade_contents as $upgrade_content) {
857
+        if(!preg_match("#.*\.zip\$#i", $upgrade_content)) {
858
+            continue;
859
+        }
860 860
 
861
-		$the_base = basename($upgrade_content);
862
-		$the_md5 = md5_file($upgrade_content);
861
+        $the_base = basename($upgrade_content);
862
+        $the_md5 = md5_file($upgrade_content);
863 863
 
864
-		$md5_matches = $uh->findByMd5($the_md5);
864
+        $md5_matches = $uh->findByMd5($the_md5);
865 865
 
866
-		/* If a patch is in the /patch dir AND has no record in the upgrade_history table we assume that it's the one we want.
866
+        /* If a patch is in the /patch dir AND has no record in the upgrade_history table we assume that it's the one we want.
867 867
 		 * Edge-case: manual upgrade with a FTP of a patch; UH table has no entry for it.  Assume nothing. :( */
868
-		if(0 == sizeof($md5_matches)) {
869
-			$target_manifest = remove_file_extension( $upgrade_content ) . '-manifest.php';
870
-			require_once($target_manifest);
871
-
872
-			if(empty($manifest['version'])) {
873
-				logThis("*** Potential error: patch found with no version [ {$upgrade_content} ]");
874
-				continue;
875
-			}
876
-			if(!isset($manifest['type']) || $manifest['type'] != 'patch') {
877
-				logThis("*** Potential error: patch found with either no 'type' or non-patch type [ {$upgrade_content} ]");
878
-				continue;
879
-			}
880
-
881
-			$upgradeToVersion[$manifest['version']] = urlencode($upgrade_content);
882
-
883
-			$name = empty($manifest['name']) ? $upgrade_content : $manifest['name'];
884
-			$version = empty($manifest['version']) ? '' : $manifest['version'];
885
-			$published_date = empty($manifest['published_date']) ? '' : $manifest['published_date'];
886
-			$icon = '';
887
-			$description = empty($manifest['description']) ? 'None' : $manifest['description'];
888
-			$uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes';
889
-			$type = getUITextForType( $manifest['type'] );
890
-			$manifest_type = $manifest['type'];
891
-
892
-			if(empty($manifest['icon'])) {
893
-				$icon = getImageForType( $manifest['type'] );
894
-			} else {
895
-				$path_parts = pathinfo( $manifest['icon'] );
896
-				$icon = "<!--not_in_theme!--><img src=\"" . remove_file_extension( $upgrade_content ) . "-icon." . $path_parts['extension'] . "\">";
897
-			}
898
-	    }
899
-	}
868
+        if(0 == sizeof($md5_matches)) {
869
+            $target_manifest = remove_file_extension( $upgrade_content ) . '-manifest.php';
870
+            require_once($target_manifest);
871
+
872
+            if(empty($manifest['version'])) {
873
+                logThis("*** Potential error: patch found with no version [ {$upgrade_content} ]");
874
+                continue;
875
+            }
876
+            if(!isset($manifest['type']) || $manifest['type'] != 'patch') {
877
+                logThis("*** Potential error: patch found with either no 'type' or non-patch type [ {$upgrade_content} ]");
878
+                continue;
879
+            }
880
+
881
+            $upgradeToVersion[$manifest['version']] = urlencode($upgrade_content);
882
+
883
+            $name = empty($manifest['name']) ? $upgrade_content : $manifest['name'];
884
+            $version = empty($manifest['version']) ? '' : $manifest['version'];
885
+            $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date'];
886
+            $icon = '';
887
+            $description = empty($manifest['description']) ? 'None' : $manifest['description'];
888
+            $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes';
889
+            $type = getUITextForType( $manifest['type'] );
890
+            $manifest_type = $manifest['type'];
891
+
892
+            if(empty($manifest['icon'])) {
893
+                $icon = getImageForType( $manifest['type'] );
894
+            } else {
895
+                $path_parts = pathinfo( $manifest['icon'] );
896
+                $icon = "<!--not_in_theme!--><img src=\"" . remove_file_extension( $upgrade_content ) . "-icon." . $path_parts['extension'] . "\">";
897
+            }
898
+        }
899
+    }
900 900
 
901
-	// cn: bug 10488 use the NEWEST upgrade/patch available when running upgrade wizard.
902
-	ksort($upgradeToVersion);
903
-	$upgradeToVersion = array_values($upgradeToVersion);
904
-	$newest = array_pop($upgradeToVersion);
905
-	$_SESSION['install_file'] = urldecode($newest); // in-case it was there from a prior.
906
-	logThis("*** UW using [ {$_SESSION['install_file']} ] as source for patch files.");
901
+    // cn: bug 10488 use the NEWEST upgrade/patch available when running upgrade wizard.
902
+    ksort($upgradeToVersion);
903
+    $upgradeToVersion = array_values($upgradeToVersion);
904
+    $newest = array_pop($upgradeToVersion);
905
+    $_SESSION['install_file'] = urldecode($newest); // in-case it was there from a prior.
906
+    logThis("*** UW using [ {$_SESSION['install_file']} ] as source for patch files.");
907 907
 
908
-	$cleanUpgradeContent = urlencode($_SESSION['install_file']);
908
+    $cleanUpgradeContent = urlencode($_SESSION['install_file']);
909 909
 
910
-	// cn: 10606 - cannot upload a patch file since this returned always.
911
-	if(!empty($cleanUpgradeContent)) {
912
-		$ready .= "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$published_date</td><td>$uninstallable</td><td>$description</td>\n";
913
-		$ready .=<<<eoq
910
+    // cn: 10606 - cannot upload a patch file since this returned always.
911
+    if(!empty($cleanUpgradeContent)) {
912
+        $ready .= "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$published_date</td><td>$uninstallable</td><td>$description</td>\n";
913
+        $ready .=<<<eoq
914 914
 	        <td>
915 915
 				<form action="index.php" method="post">
916 916
 					<input type="hidden" name="module" value="UpgradeWizard">
@@ -922,23 +922,23 @@  discard block
 block discarded – undo
922 922
 				</form>
923 923
 			</td></table>
924 924
 eoq;
925
-		$disabled = "DISABLED";
926
-	}
925
+        $disabled = "DISABLED";
926
+    }
927 927
 
928 928
 
929 929
 
930
-	if(empty($cleanUpgradeContent)){
931
-	    $ready .= "<tr><td colspan='7'><i>None</i></td>\n";
932
-		$ready .= "</table>\n";
933
-	}
934
-	$ready .= "<br></ul>\n";
930
+    if(empty($cleanUpgradeContent)){
931
+        $ready .= "<tr><td colspan='7'><i>None</i></td>\n";
932
+        $ready .= "</table>\n";
933
+    }
934
+    $ready .= "<br></ul>\n";
935 935
 
936
-	$return['ready'] = $ready;
937
-	$return['disabled'] = $disabled;
936
+    $return['ready'] = $ready;
937
+    $return['disabled'] = $disabled;
938 938
 
939
-	if($returnFull) {
940
-		return $return;
941
-	}
939
+    if($returnFull) {
940
+        return $return;
941
+    }
942 942
 }
943 943
 
944 944
 
@@ -947,36 +947,36 @@  discard block
 block discarded – undo
947 947
  * @return bool true on success
948 948
  */
949 949
 function updateVersions($version) {
950
-	global $db;
951
-	global $sugar_config;
952
-	global $path;
953
-
954
-	logThis('At updateVersions()... updating config table and sugar_version.php.', $path);
955
-
956
-	// handle file copy
957
-	if(isset($_SESSION['sugar_version_file']) && !empty($_SESSION['sugar_version_file'])) {
958
-		if(!copy($_SESSION['sugar_version_file'], clean_path(getcwd().'/sugar_version.php'))) {
959
-			logThis('*** ERROR: sugar_version.php could not be copied to destination! Cannot complete upgrade', $path);
960
-			return false;
961
-		} else {
962
-			logThis('sugar_version.php successfully updated!', $path);
963
-		}
964
-	} else {
965
-		logThis('*** ERROR: no sugar_version.php file location found! - cannot complete upgrade...', $path);
966
-		return false;
967
-	}
950
+    global $db;
951
+    global $sugar_config;
952
+    global $path;
953
+
954
+    logThis('At updateVersions()... updating config table and sugar_version.php.', $path);
955
+
956
+    // handle file copy
957
+    if(isset($_SESSION['sugar_version_file']) && !empty($_SESSION['sugar_version_file'])) {
958
+        if(!copy($_SESSION['sugar_version_file'], clean_path(getcwd().'/sugar_version.php'))) {
959
+            logThis('*** ERROR: sugar_version.php could not be copied to destination! Cannot complete upgrade', $path);
960
+            return false;
961
+        } else {
962
+            logThis('sugar_version.php successfully updated!', $path);
963
+        }
964
+    } else {
965
+        logThis('*** ERROR: no sugar_version.php file location found! - cannot complete upgrade...', $path);
966
+        return false;
967
+    }
968 968
 
969
-	$q1 = "DELETE FROM config WHERE category = 'info' AND name = 'sugar_version'";
970
-	$q2 = "INSERT INTO config (category, name, value) VALUES ('info', 'sugar_version', '{$version}')";
969
+    $q1 = "DELETE FROM config WHERE category = 'info' AND name = 'sugar_version'";
970
+    $q2 = "INSERT INTO config (category, name, value) VALUES ('info', 'sugar_version', '{$version}')";
971 971
 
972
-	logThis('Deleting old DB version info from config table.', $path);
973
-	$db->query($q1);
972
+    logThis('Deleting old DB version info from config table.', $path);
973
+    $db->query($q1);
974 974
 
975
-	logThis('Inserting updated version info into config table.', $path);
976
-	$db->query($q2);
975
+    logThis('Inserting updated version info into config table.', $path);
976
+    $db->query($q2);
977 977
 
978
-	logThis('updateVersions() complete.', $path);
979
-	return true;
978
+    logThis('updateVersions() complete.', $path);
979
+    return true;
980 980
 }
981 981
 
982 982
 
@@ -988,11 +988,11 @@  discard block
 block discarded – undo
988 988
  * @return array mod_strings
989 989
  */
990 990
 function getModuleLanguagePack($lang, $module) {
991
-	$mod_strings = array();
991
+    $mod_strings = array();
992 992
 
993
-	if(!empty($lang) && !empty($module)) {
994
-		$langPack = clean_path(getcwd().'/'.$module.'/language/'.$lang.'.lang.php');
995
-		$langPackEn = clean_path(getcwd().'/'.$module.'/language/en_us.lang.php');
993
+    if(!empty($lang) && !empty($module)) {
994
+        $langPack = clean_path(getcwd().'/'.$module.'/language/'.$lang.'.lang.php');
995
+        $langPackEn = clean_path(getcwd().'/'.$module.'/language/en_us.lang.php');
996 996
 
997 997
         if (file_exists($langPack))
998 998
         {
@@ -1002,47 +1002,47 @@  discard block
 block discarded – undo
1002 1002
         {
1003 1003
             include($langPackEn);
1004 1004
         }
1005
-	}
1005
+    }
1006 1006
 
1007
-	return $mod_strings;
1007
+    return $mod_strings;
1008 1008
 }
1009 1009
 /**
1010 1010
  * checks system compliance for 4.5+ codebase
1011 1011
  * @return array Mixed values
1012 1012
  */
1013 1013
 function checkSystemCompliance() {
1014
-	global $sugar_config;
1015
-	global $current_language;
1016
-	global $db;
1017
-	global $mod_strings;
1014
+    global $sugar_config;
1015
+    global $current_language;
1016
+    global $db;
1017
+    global $mod_strings;
1018 1018
     global $app_strings;
1019 1019
 
1020
-	if(!defined('SUGARCRM_MIN_MEM')) {
1021
-		define('SUGARCRM_MIN_MEM', 40);
1022
-	}
1020
+    if(!defined('SUGARCRM_MIN_MEM')) {
1021
+        define('SUGARCRM_MIN_MEM', 40);
1022
+    }
1023 1023
 
1024
-	$installer_mod_strings = getModuleLanguagePack($current_language, './install');
1025
-	$ret = array();
1026
-	$ret['error_found'] = false;
1027
-
1028
-	// PHP version
1029
-	$php_version = constant('PHP_VERSION');
1030
-	$check_php_version_result = check_php_version($php_version);
1031
-
1032
-	switch($check_php_version_result) {
1033
-		case -1:
1034
-			$ret['phpVersion'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
1035
-			$ret['error_found'] = true;
1036
-			break;
1037
-		case 0:
1038
-			$ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_PHP_UNSUPPORTED']} {$php_version} )</span></b>";
1039
-			break;
1040
-		case 1:
1041
-			$ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_PHP_OK']} {$php_version} )</span></b>";
1042
-			break;
1043
-	}
1024
+    $installer_mod_strings = getModuleLanguagePack($current_language, './install');
1025
+    $ret = array();
1026
+    $ret['error_found'] = false;
1027
+
1028
+    // PHP version
1029
+    $php_version = constant('PHP_VERSION');
1030
+    $check_php_version_result = check_php_version($php_version);
1044 1031
 
1045
-	// database and connect
1032
+    switch($check_php_version_result) {
1033
+        case -1:
1034
+            $ret['phpVersion'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
1035
+            $ret['error_found'] = true;
1036
+            break;
1037
+        case 0:
1038
+            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_PHP_UNSUPPORTED']} {$php_version} )</span></b>";
1039
+            break;
1040
+        case 1:
1041
+            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_PHP_OK']} {$php_version} )</span></b>";
1042
+            break;
1043
+    }
1044
+
1045
+    // database and connect
1046 1046
     $canInstall = $db->canInstall();
1047 1047
     if ($canInstall !== true)
1048 1048
     {
@@ -1057,75 +1057,75 @@  discard block
 block discarded – undo
1057 1057
         }
1058 1058
     }
1059 1059
 
1060
-	// XML Parsing
1061
-	if(function_exists('xml_parser_create')) {
1062
-		$ret['xmlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1063
-	} else {
1064
-		$ret['xmlStatus'] = "<b><span class=stop>{$installer_mod_strings['LBL_CHECKSYS_NOT_AVAILABLE']}</span></b>";
1065
-		$ret['error_found'] = true;
1066
-	}
1060
+    // XML Parsing
1061
+    if(function_exists('xml_parser_create')) {
1062
+        $ret['xmlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1063
+    } else {
1064
+        $ret['xmlStatus'] = "<b><span class=stop>{$installer_mod_strings['LBL_CHECKSYS_NOT_AVAILABLE']}</span></b>";
1065
+        $ret['error_found'] = true;
1066
+    }
1067 1067
 
1068
-	// cURL
1069
-	if(function_exists('curl_init')) {
1070
-		$ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1071
-	} else {
1072
-		$ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_CURL']}</span></b>";
1073
-		$ret['error_found'] = false;
1074
-	}
1068
+    // cURL
1069
+    if(function_exists('curl_init')) {
1070
+        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1071
+    } else {
1072
+        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_CURL']}</span></b>";
1073
+        $ret['error_found'] = false;
1074
+    }
1075 1075
 
1076
-	// mbstrings
1077
-	if(function_exists('mb_strlen')) {
1078
-		$ret['mbstringStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1079
-	} else {
1080
-		$ret['mbstringStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_MBSTRING']}</span></b>";
1081
-		$ret['error_found'] = true;
1082
-	}
1076
+    // mbstrings
1077
+    if(function_exists('mb_strlen')) {
1078
+        $ret['mbstringStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1079
+    } else {
1080
+        $ret['mbstringStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_MBSTRING']}</span></b>";
1081
+        $ret['error_found'] = true;
1082
+    }
1083 1083
 
1084
-	// imap
1085
-	if(function_exists('imap_open')) {
1086
-		$ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1087
-	} else {
1088
-		$ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_IMAP']}</span></b>";
1089
-		$ret['error_found'] = false;
1090
-	}
1084
+    // imap
1085
+    if(function_exists('imap_open')) {
1086
+        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1087
+    } else {
1088
+        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_IMAP']}</span></b>";
1089
+        $ret['error_found'] = false;
1090
+    }
1091 1091
 
1092 1092
 
1093
-	// safe mode
1094
-	if('1' == ini_get('safe_mode')) {
1095
-		$ret['safeModeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_SAFE_MODE']}</span></b>";
1096
-		$ret['error_found'] = true;
1097
-	} else {
1098
-		$ret['safeModeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1099
-	}
1093
+    // safe mode
1094
+    if('1' == ini_get('safe_mode')) {
1095
+        $ret['safeModeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_SAFE_MODE']}</span></b>";
1096
+        $ret['error_found'] = true;
1097
+    } else {
1098
+        $ret['safeModeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1099
+    }
1100 1100
 
1101 1101
 
1102
-	// call time pass by ref
1102
+    // call time pass by ref
1103 1103
     if('1' == ini_get('allow_call_time_pass_reference')) {
1104
-		$ret['callTimeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_CALL_TIME']}</span></b>";
1105
-		//continue upgrading
1106
-	} else {
1107
-		$ret['callTimeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1108
-	}
1104
+        $ret['callTimeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_CALL_TIME']}</span></b>";
1105
+        //continue upgrading
1106
+    } else {
1107
+        $ret['callTimeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
1108
+    }
1109 1109
 
1110
-	// memory limit
1111
-	$ret['memory_msg']     = "";
1112
-	$memory_limit   = "-1";//ini_get('memory_limit');
1113
-	$sugarMinMem = constant('SUGARCRM_MIN_MEM');
1114
-	// logic based on: http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
1115
-	if( $memory_limit == "" ){          // memory_limit disabled at compile time, no memory limit
1116
-	    $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_OK']}</span></b>";
1117
-	} elseif( $memory_limit == "-1" ){   // memory_limit enabled, but set to unlimited
1118
-	    $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_UNLIMITED']}</span></b>";
1119
-	} else {
1120
-	    rtrim($memory_limit, 'M');
1121
-	    $memory_limit_int = (int) $memory_limit;
1122
-	    if( $memory_limit_int < constant('SUGARCRM_MIN_MEM') ){
1123
-	        $ret['memory_msg'] = "<b><span class=\"stop\">{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_1']}" . constant('SUGARCRM_MIN_MEM') . "{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_2']}</span></b>";
1124
-			$ret['error_found'] = true;
1125
-	    } else {
1126
-			$ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']} ({$memory_limit})</span></b>";
1127
-	    }
1128
-	}
1110
+    // memory limit
1111
+    $ret['memory_msg']     = "";
1112
+    $memory_limit   = "-1";//ini_get('memory_limit');
1113
+    $sugarMinMem = constant('SUGARCRM_MIN_MEM');
1114
+    // logic based on: http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
1115
+    if( $memory_limit == "" ){          // memory_limit disabled at compile time, no memory limit
1116
+        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_OK']}</span></b>";
1117
+    } elseif( $memory_limit == "-1" ){   // memory_limit enabled, but set to unlimited
1118
+        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_UNLIMITED']}</span></b>";
1119
+    } else {
1120
+        rtrim($memory_limit, 'M');
1121
+        $memory_limit_int = (int) $memory_limit;
1122
+        if( $memory_limit_int < constant('SUGARCRM_MIN_MEM') ){
1123
+            $ret['memory_msg'] = "<b><span class=\"stop\">{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_1']}" . constant('SUGARCRM_MIN_MEM') . "{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_2']}</span></b>";
1124
+            $ret['error_found'] = true;
1125
+        } else {
1126
+            $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']} ({$memory_limit})</span></b>";
1127
+        }
1128
+    }
1129 1129
         // zip support
1130 1130
     if (!class_exists("ZipArchive"))
1131 1131
     {
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
         $ret['error_found'] = true;
1162 1162
     }
1163 1163
 
1164
-	/* mbstring.func_overload
1164
+    /* mbstring.func_overload
1165 1165
 	$ret['mbstring.func_overload'] = '';
1166 1166
 	$mb = ini_get('mbstring.func_overload');
1167 1167
 
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 		$ret['error_found'] = true;
1171 1171
 	}
1172 1172
 	*/
1173
-	return $ret;
1173
+    return $ret;
1174 1174
 }
1175 1175
 
1176 1176
 
@@ -1178,141 +1178,141 @@  discard block
 block discarded – undo
1178 1178
  * is a file that we blow away automagically
1179 1179
  */
1180 1180
 function isAutoOverwriteFile($file) {
1181
-	$overwriteDirs = array(
1182
-		'./sugar_version.php',
1183
-		'./modules/UpgradeWizard/uw_main.tpl',
1184
-	);
1185
-	$file = trim('.'.str_replace(clean_path(getcwd()), '', $file));
1186
-
1187
-	if(in_array($file, $overwriteDirs)) {
1188
-		return true;
1189
-	}
1181
+    $overwriteDirs = array(
1182
+        './sugar_version.php',
1183
+        './modules/UpgradeWizard/uw_main.tpl',
1184
+    );
1185
+    $file = trim('.'.str_replace(clean_path(getcwd()), '', $file));
1186
+
1187
+    if(in_array($file, $overwriteDirs)) {
1188
+        return true;
1189
+    }
1190 1190
 
1191
-	$fileExtension = substr(strrchr($file, "."), 1);
1192
-	if($fileExtension == 'tpl' || $fileExtension == 'html') {
1193
-		return false;
1194
-	}
1191
+    $fileExtension = substr(strrchr($file, "."), 1);
1192
+    if($fileExtension == 'tpl' || $fileExtension == 'html') {
1193
+        return false;
1194
+    }
1195 1195
 
1196
-	return true;
1196
+    return true;
1197 1197
 }
1198 1198
 
1199 1199
 /**
1200 1200
  * flatfile logger
1201 1201
  */
1202 1202
 function logThis($entry, $path='') {
1203
-	global $mod_strings;
1204
-	if(file_exists('include/utils/sugar_file_utils.php')){
1205
-		require_once('include/utils/sugar_file_utils.php');
1206
-	}
1207
-		$log = empty($path) ? clean_path(getcwd().'/upgradeWizard.log') : clean_path($path);
1208
-
1209
-		// create if not exists
1210
-		if(!file_exists($log)) {
1211
-			if(function_exists('sugar_fopen')){
1212
-				$fp = @sugar_fopen($log, 'w+'); // attempts to create file
1213
-		     }
1214
-		     else{
1215
-				$fp = fopen($log, 'w+'); // attempts to create file
1216
-		     }
1217
-			if(!is_resource($fp)) {
1218
-				$GLOBALS['log']->fatal('UpgradeWizard could not create the upgradeWizard.log file');
1219
-				die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1220
-			}
1221
-		} else {
1222
-			if(function_exists('sugar_fopen')){
1223
-				$fp = @sugar_fopen($log, 'a+'); // write pointer at end of file
1224
-		     }
1225
-		     else{
1226
-				$fp = @fopen($log, 'a+'); // write pointer at end of file
1227
-		     }
1228
-
1229
-			if(!is_resource($fp)) {
1230
-				$GLOBALS['log']->fatal('UpgradeWizard could not open/lock upgradeWizard.log file');
1231
-				die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1232
-			}
1233
-		}
1203
+    global $mod_strings;
1204
+    if(file_exists('include/utils/sugar_file_utils.php')){
1205
+        require_once('include/utils/sugar_file_utils.php');
1206
+    }
1207
+        $log = empty($path) ? clean_path(getcwd().'/upgradeWizard.log') : clean_path($path);
1208
+
1209
+        // create if not exists
1210
+        if(!file_exists($log)) {
1211
+            if(function_exists('sugar_fopen')){
1212
+                $fp = @sugar_fopen($log, 'w+'); // attempts to create file
1213
+                }
1214
+                else{
1215
+                $fp = fopen($log, 'w+'); // attempts to create file
1216
+                }
1217
+            if(!is_resource($fp)) {
1218
+                $GLOBALS['log']->fatal('UpgradeWizard could not create the upgradeWizard.log file');
1219
+                die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1220
+            }
1221
+        } else {
1222
+            if(function_exists('sugar_fopen')){
1223
+                $fp = @sugar_fopen($log, 'a+'); // write pointer at end of file
1224
+                }
1225
+                else{
1226
+                $fp = @fopen($log, 'a+'); // write pointer at end of file
1227
+                }
1234 1228
 
1235
-		$line = date('r').' [UpgradeWizard] - '.$entry."\n";
1229
+            if(!is_resource($fp)) {
1230
+                $GLOBALS['log']->fatal('UpgradeWizard could not open/lock upgradeWizard.log file');
1231
+                die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1232
+            }
1233
+        }
1236 1234
 
1237
-		if(@fwrite($fp, $line) === false) {
1238
-			$GLOBALS['log']->fatal('UpgradeWizard could not write to upgradeWizard.log: '.$entry);
1239
-			die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1240
-		}
1235
+        $line = date('r').' [UpgradeWizard] - '.$entry."\n";
1241 1236
 
1242
-		if(is_resource($fp)) {
1243
-			fclose($fp);
1244
-		}
1237
+        if(@fwrite($fp, $line) === false) {
1238
+            $GLOBALS['log']->fatal('UpgradeWizard could not write to upgradeWizard.log: '.$entry);
1239
+            die($mod_strings['ERR_UW_LOG_FILE_UNWRITABLE']);
1240
+        }
1241
+
1242
+        if(is_resource($fp)) {
1243
+            fclose($fp);
1244
+        }
1245 1245
 }
1246 1246
 
1247 1247
 /**
1248
-	*  @params : none
1249
-	*  @author: nsingh
1250
-	*  @desc This function is to be used in the upgrade process to preserve changes/customaizations made to pre 5.1 quickcreate layout.
1251
-	*  Prior to 5.1 we have been using editviewdefs as the base for quickcreatedefs. If a custom field was added to edit view layout, it
1252
-	*  was automatically picked up by the quick create. [Addresses Bug 21469]
1253
-	*  This function will check if customizations were made, and will create quickcreatedefs.php in the /cutom/working/$module_name directory.
1254
-	**/
1248
+ *  @params : none
1249
+ *  @author: nsingh
1250
+ *  @desc This function is to be used in the upgrade process to preserve changes/customaizations made to pre 5.1 quickcreate layout.
1251
+ *  Prior to 5.1 we have been using editviewdefs as the base for quickcreatedefs. If a custom field was added to edit view layout, it
1252
+ *  was automatically picked up by the quick create. [Addresses Bug 21469]
1253
+ *  This function will check if customizations were made, and will create quickcreatedefs.php in the /cutom/working/$module_name directory.
1254
+ **/
1255 1255
 function updateQuickCreateDefs(){
1256
-	$d = dir('modules');
1257
-	$studio_modules = array();
1258
-
1259
-	while($e = $d->read()){ //collect all studio modules.
1260
-		if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
1261
-		if(file_exists('modules/' . $e . '/metadata/studio.php'))
1262
-		{
1263
-			array_push($studio_modules, $e);
1264
-		}
1265
-	}
1256
+    $d = dir('modules');
1257
+    $studio_modules = array();
1266 1258
 
1267
-	foreach( $studio_modules as $modname ){ //for each studio enabled module
1268
-		//Check !exists modules/$modname/metadata/quickcreatedefs.php &&
1269
-		//exists custom/$modname/editviewdefs.php (module was customized) &&
1270
-		//!exists custom/$modname/quickcreateviewdefs.php
1271
-
1272
-		$editviewdefs = "custom/working/modules/".$modname."/metadata/editviewdefs.php";
1273
-		$quickcreatedefs = "custom/working/modules/".$modname."/metadata/quickcreatedefs.php";
1274
-
1275
-		if ( !file_exists("modules/".$modname."/metadata/quickcreatedefs.php") &&
1276
-			 file_exists($editviewdefs) &&
1277
-			 !file_exists($quickcreatedefs) ){
1278
-				//clone editviewdef and save it in custom/working/modules/metadata
1279
-				$GLOBALS['log']->debug("Copying editviewdefs.php as quickcreatedefs.php for the $modname module in custom/working/modules/$modname/metadata!");
1280
-				if(copy( $editviewdefs, $quickcreatedefs)){
1281
-					if(file_exists($quickcreatedefs) && is_readable($quickcreatedefs)){
1282
-						$file = file($quickcreatedefs);
1283
-						//replace 'EditView' with 'QuickCreate'
1284
-						$fp = fopen($quickcreatedefs,'w');
1285
-						foreach($file as &$line){
1286
-							if(preg_match('/^\s*\'EditView\'\s*=>\s*$/', $line) > 0){
1287
-								$line = "'QuickCreate' =>\n";
1288
-							}
1289
-							fwrite($fp, $line);
1290
-						}
1291
-						//write back.
1292
-						fclose($fp);
1293
-					}
1294
-					else{
1295
-						$GLOBALS['log']->debug("Failed to replace 'EditView' with QuickCreate because $quickcreatedefs is either not readable or does not exist.");
1296
-					}
1297
-				}else{
1298
-					$GLOBALS['log']->debug("Failed to copy $editviewdefs to $quickcreatedefs!");
1299
-				}
1300
-		}
1301
-	}
1259
+    while($e = $d->read()){ //collect all studio modules.
1260
+        if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
1261
+        if(file_exists('modules/' . $e . '/metadata/studio.php'))
1262
+        {
1263
+            array_push($studio_modules, $e);
1264
+        }
1265
+    }
1266
+
1267
+    foreach( $studio_modules as $modname ){ //for each studio enabled module
1268
+        //Check !exists modules/$modname/metadata/quickcreatedefs.php &&
1269
+        //exists custom/$modname/editviewdefs.php (module was customized) &&
1270
+        //!exists custom/$modname/quickcreateviewdefs.php
1271
+
1272
+        $editviewdefs = "custom/working/modules/".$modname."/metadata/editviewdefs.php";
1273
+        $quickcreatedefs = "custom/working/modules/".$modname."/metadata/quickcreatedefs.php";
1274
+
1275
+        if ( !file_exists("modules/".$modname."/metadata/quickcreatedefs.php") &&
1276
+             file_exists($editviewdefs) &&
1277
+             !file_exists($quickcreatedefs) ){
1278
+                //clone editviewdef and save it in custom/working/modules/metadata
1279
+                $GLOBALS['log']->debug("Copying editviewdefs.php as quickcreatedefs.php for the $modname module in custom/working/modules/$modname/metadata!");
1280
+                if(copy( $editviewdefs, $quickcreatedefs)){
1281
+                    if(file_exists($quickcreatedefs) && is_readable($quickcreatedefs)){
1282
+                        $file = file($quickcreatedefs);
1283
+                        //replace 'EditView' with 'QuickCreate'
1284
+                        $fp = fopen($quickcreatedefs,'w');
1285
+                        foreach($file as &$line){
1286
+                            if(preg_match('/^\s*\'EditView\'\s*=>\s*$/', $line) > 0){
1287
+                                $line = "'QuickCreate' =>\n";
1288
+                            }
1289
+                            fwrite($fp, $line);
1290
+                        }
1291
+                        //write back.
1292
+                        fclose($fp);
1293
+                    }
1294
+                    else{
1295
+                        $GLOBALS['log']->debug("Failed to replace 'EditView' with QuickCreate because $quickcreatedefs is either not readable or does not exist.");
1296
+                    }
1297
+                }else{
1298
+                    $GLOBALS['log']->debug("Failed to copy $editviewdefs to $quickcreatedefs!");
1299
+                }
1300
+        }
1301
+    }
1302 1302
 }
1303 1303
 
1304 1304
 /**
1305 1305
  * test perms for CREATE queries
1306 1306
  */
1307 1307
 function testPermsCreate($db, $out) {
1308
-	logThis('Checking CREATE TABLE permissions...');
1309
-	global $mod_strings;
1308
+    logThis('Checking CREATE TABLE permissions...');
1309
+    global $mod_strings;
1310 1310
 
1311
-	if(!$db->checkPrivilege("CREATE TABLE")) {
1311
+    if(!$db->checkPrivilege("CREATE TABLE")) {
1312 1312
         logThis('cannot CREATE TABLE!');
1313
-		$out['db']['dbNoCreate'] = true;
1314
-		$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_CREATE']}</span></td></tr>";
1315
-	}
1313
+        $out['db']['dbNoCreate'] = true;
1314
+        $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_CREATE']}</span></td></tr>";
1315
+    }
1316 1316
     return $out;
1317 1317
 }
1318 1318
 
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
  * test perms for INSERT
1321 1321
  */
1322 1322
 function testPermsInsert($db, $out, $skip=false) {
1323
-	logThis('Checking INSERT INTO permissions...');
1324
-	global $mod_strings;
1323
+    logThis('Checking INSERT INTO permissions...');
1324
+    global $mod_strings;
1325 1325
 
1326
-	if(!$db->checkPrivilege("INSERT")) {
1327
-		logThis('cannot INSERT INTO!');
1328
-		$out['db']['dbNoInsert'] = true;
1329
-		$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_INSERT']}</span></td></tr>";
1326
+    if(!$db->checkPrivilege("INSERT")) {
1327
+        logThis('cannot INSERT INTO!');
1328
+        $out['db']['dbNoInsert'] = true;
1329
+        $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_INSERT']}</span></td></tr>";
1330 1330
     }
1331 1331
     return $out;
1332 1332
 }
@@ -1336,12 +1336,12 @@  discard block
 block discarded – undo
1336 1336
  * test perms for UPDATE TABLE
1337 1337
  */
1338 1338
 function testPermsUpdate($db, $out, $skip=false) {
1339
-	logThis('Checking UPDATE TABLE permissions...');
1340
-	global $mod_strings;
1341
-	if(!$db->checkPrivilege("UPDATE")) {
1342
-					logThis('cannot UPDATE TABLE!');
1343
-					$out['db']['dbNoUpdate'] = true;
1344
-					$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_UPDATE']}</span></td></tr>";
1339
+    logThis('Checking UPDATE TABLE permissions...');
1340
+    global $mod_strings;
1341
+    if(!$db->checkPrivilege("UPDATE")) {
1342
+                    logThis('cannot UPDATE TABLE!');
1343
+                    $out['db']['dbNoUpdate'] = true;
1344
+                    $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_UPDATE']}</span></td></tr>";
1345 1345
     }
1346 1346
     return $out;
1347 1347
 }
@@ -1351,12 +1351,12 @@  discard block
 block discarded – undo
1351 1351
  * test perms for SELECT
1352 1352
  */
1353 1353
 function testPermsSelect($db, $out, $skip=false) {
1354
-	logThis('Checking SELECT permissions...');
1355
-	global $mod_strings;
1356
-	if(!$db->checkPrivilege("SELECT")) {
1357
-				logThis('cannot SELECT!');
1358
-				$out['db']['dbNoSelect'] = true;
1359
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_SELECT']}</span></td></tr>";
1354
+    logThis('Checking SELECT permissions...');
1355
+    global $mod_strings;
1356
+    if(!$db->checkPrivilege("SELECT")) {
1357
+                logThis('cannot SELECT!');
1358
+                $out['db']['dbNoSelect'] = true;
1359
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_SELECT']}</span></td></tr>";
1360 1360
     }
1361 1361
     return $out;
1362 1362
 }
@@ -1365,12 +1365,12 @@  discard block
 block discarded – undo
1365 1365
  * test perms for DELETE
1366 1366
  */
1367 1367
 function testPermsDelete($db, $out, $skip=false) {
1368
-	logThis('Checking DELETE FROM permissions...');
1369
-	global $mod_strings;
1370
-	if(!$db->checkPrivilege("DELETE")) {
1371
-				logThis('cannot DELETE FROM!');
1372
-				$out['db']['dbNoDelete'] = true;
1373
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DELETE']}</span></td></tr>";
1368
+    logThis('Checking DELETE FROM permissions...');
1369
+    global $mod_strings;
1370
+    if(!$db->checkPrivilege("DELETE")) {
1371
+                logThis('cannot DELETE FROM!');
1372
+                $out['db']['dbNoDelete'] = true;
1373
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DELETE']}</span></td></tr>";
1374 1374
     }
1375 1375
     return $out;
1376 1376
 }
@@ -1380,12 +1380,12 @@  discard block
 block discarded – undo
1380 1380
  * test perms for ALTER TABLE ADD COLUMN
1381 1381
  */
1382 1382
 function testPermsAlterTableAdd($db, $out, $skip=false) {
1383
-	logThis('Checking ALTER TABLE ADD COLUMN permissions...');
1384
-	global $mod_strings;
1385
-	if(!$db->checkPrivilege("ADD COLUMN")) {
1386
-				logThis('cannot ADD COLUMN!');
1387
-				$out['db']['dbNoAddColumn'] = true;
1388
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_ADD_COLUMN']}</span></td></tr>";
1383
+    logThis('Checking ALTER TABLE ADD COLUMN permissions...');
1384
+    global $mod_strings;
1385
+    if(!$db->checkPrivilege("ADD COLUMN")) {
1386
+                logThis('cannot ADD COLUMN!');
1387
+                $out['db']['dbNoAddColumn'] = true;
1388
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_ADD_COLUMN']}</span></td></tr>";
1389 1389
     }
1390 1390
     return $out;
1391 1391
 }
@@ -1394,12 +1394,12 @@  discard block
 block discarded – undo
1394 1394
  * test perms for ALTER TABLE ADD COLUMN
1395 1395
  */
1396 1396
 function testPermsAlterTableChange($db, $out, $skip=false) {
1397
-	logThis('Checking ALTER TABLE CHANGE COLUMN permissions...');
1398
-	global $mod_strings;
1399
-	if(!$db->checkPrivilege("CHANGE COLUMN")) {
1400
-				logThis('cannot CHANGE COLUMN!');
1401
-				$out['db']['dbNoChangeColumn'] = true;
1402
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_CHANGE_COLUMN']}</span></td></tr>";
1397
+    logThis('Checking ALTER TABLE CHANGE COLUMN permissions...');
1398
+    global $mod_strings;
1399
+    if(!$db->checkPrivilege("CHANGE COLUMN")) {
1400
+                logThis('cannot CHANGE COLUMN!');
1401
+                $out['db']['dbNoChangeColumn'] = true;
1402
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_CHANGE_COLUMN']}</span></td></tr>";
1403 1403
     }
1404 1404
     return $out;
1405 1405
 }
@@ -1408,12 +1408,12 @@  discard block
 block discarded – undo
1408 1408
  * test perms for ALTER TABLE DROP COLUMN
1409 1409
  */
1410 1410
 function testPermsAlterTableDrop($db, $out, $skip=false) {
1411
-	logThis('Checking ALTER TABLE DROP COLUMN permissions...');
1412
-	global $mod_strings;
1413
-	if(!$db->checkPrivilege("DROP COLUMN")) {
1414
-				logThis('cannot DROP COLUMN!');
1415
-				$out['db']['dbNoDropColumn'] = true;
1416
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DROP_COLUMN']}</span></td></tr>";
1411
+    logThis('Checking ALTER TABLE DROP COLUMN permissions...');
1412
+    global $mod_strings;
1413
+    if(!$db->checkPrivilege("DROP COLUMN")) {
1414
+                logThis('cannot DROP COLUMN!');
1415
+                $out['db']['dbNoDropColumn'] = true;
1416
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DROP_COLUMN']}</span></td></tr>";
1417 1417
     }
1418 1418
     return $out;
1419 1419
 }
@@ -1423,21 +1423,21 @@  discard block
 block discarded – undo
1423 1423
  * test perms for DROP TABLE
1424 1424
  */
1425 1425
 function testPermsDropTable($db, $out, $skip=false) {
1426
-	logThis('Checking DROP TABLE permissions...');
1427
-	global $mod_strings;
1428
-	if(!$db->checkPrivilege("DROP TABLE")) {
1429
-				logThis('cannot DROP TABLE!');
1430
-				$out['db']['dbNoDropTable'] = true;
1431
-				$out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DROP_TABLE']}</span></td></tr>";
1426
+    logThis('Checking DROP TABLE permissions...');
1427
+    global $mod_strings;
1428
+    if(!$db->checkPrivilege("DROP TABLE")) {
1429
+                logThis('cannot DROP TABLE!');
1430
+                $out['db']['dbNoDropTable'] = true;
1431
+                $out['dbOut'] .= "<tr><td align='left'><span class='error'>{$mod_strings['LBL_UW_DB_NO_DROP_TABLE']}</span></td></tr>";
1432 1432
     }
1433 1433
     return $out;
1434 1434
 }
1435 1435
 
1436 1436
 function getFormattedError($error, $query) {
1437
-	$error = "<div><b>".$error;
1438
-	$error .= "</b>::{$query}</div>";
1437
+    $error = "<div><b>".$error;
1438
+    $error .= "</b>::{$query}</div>";
1439 1439
 
1440
-	return $error;
1440
+    return $error;
1441 1441
 }
1442 1442
 
1443 1443
 /**
@@ -1446,25 +1446,25 @@  discard block
 block discarded – undo
1446 1446
  * @return string table The table
1447 1447
  */
1448 1448
 function getTableFromQuery($query) {
1449
-	$standardQueries = array('ALTER TABLE', 'DROP TABLE', 'CREATE TABLE', 'INSERT INTO', 'UPDATE', 'DELETE FROM');
1450
-	$query = preg_replace("/[^A-Za-z0-9\_\s]/", "", $query);
1451
-	$query = trim(str_replace($standardQueries, '', $query));
1449
+    $standardQueries = array('ALTER TABLE', 'DROP TABLE', 'CREATE TABLE', 'INSERT INTO', 'UPDATE', 'DELETE FROM');
1450
+    $query = preg_replace("/[^A-Za-z0-9\_\s]/", "", $query);
1451
+    $query = trim(str_replace($standardQueries, '', $query));
1452 1452
 
1453
-	$firstSpc = strpos($query, " ");
1454
-	$end = ($firstSpc > 0) ? $firstSpc : strlen($query);
1455
-	$table = substr($query, 0, $end);
1453
+    $firstSpc = strpos($query, " ");
1454
+    $end = ($firstSpc > 0) ? $firstSpc : strlen($query);
1455
+    $table = substr($query, 0, $end);
1456 1456
 
1457
-	return $table;
1457
+    return $table;
1458 1458
 }
1459 1459
 
1460 1460
 //prelicense check
1461 1461
 
1462 1462
 function preLicenseCheck() {
1463
-	require_once('modules/UpgradeWizard/uw_files.php');
1463
+    require_once('modules/UpgradeWizard/uw_files.php');
1464 1464
 
1465
-	global $sugar_config;
1466
-	global $mod_strings;
1467
-	global $sugar_version;
1465
+    global $sugar_config;
1466
+    global $mod_strings;
1467
+    global $sugar_version;
1468 1468
 
1469 1469
     if (empty($sugar_version))
1470 1470
     {
@@ -1472,36 +1472,36 @@  discard block
 block discarded – undo
1472 1472
     }
1473 1473
 
1474 1474
 if(!isset($_SESSION['unzip_dir']) || empty($_SESSION['unzip_dir'])) {
1475
-		logThis('unzipping files in upgrade archive...');
1476
-		$errors					= array();
1477
-		list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
1478
-		$unzip_dir = '';
1479
-		//also come up with mechanism to read from upgrade-progress file
1480
-		if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
1481
-			if (file_exists(clean_path($base_tmp_upgrade_dir)) && $handle = opendir(clean_path($base_tmp_upgrade_dir))) {
1482
-		    		while (false !== ($file = readdir($handle))) {
1483
-		    		if($file !="." && $file !="..")	{
1484
-					 if(is_file($base_tmp_upgrade_dir."/".$file."/manifest.php")){
1485
-					 	require_once($base_tmp_upgrade_dir."/".$file."/manifest.php");
1486
-					 	$package_name= $manifest['copy_files']['from_dir'];
1487
-					 	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")){
1488
-					 		$unzip_dir = $base_tmp_upgrade_dir."/".$file;
1489
-					 		if(file_exists("$base_upgrade_dir/patch/".$package_name.'.zip')){
1490
-					 			$_SESSION['install_file'] = $package_name.".zip";
1491
-					 			break;
1492
-					 		}
1493
-						}
1494
-					  }
1495
-		    		}
1496
-		    	}
1497
-			}
1498
-		}
1475
+        logThis('unzipping files in upgrade archive...');
1476
+        $errors					= array();
1477
+        list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
1478
+        $unzip_dir = '';
1479
+        //also come up with mechanism to read from upgrade-progress file
1480
+        if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
1481
+            if (file_exists(clean_path($base_tmp_upgrade_dir)) && $handle = opendir(clean_path($base_tmp_upgrade_dir))) {
1482
+                    while (false !== ($file = readdir($handle))) {
1483
+                    if($file !="." && $file !="..")	{
1484
+                        if(is_file($base_tmp_upgrade_dir."/".$file."/manifest.php")){
1485
+                            require_once($base_tmp_upgrade_dir."/".$file."/manifest.php");
1486
+                            $package_name= $manifest['copy_files']['from_dir'];
1487
+                            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")){
1488
+                                $unzip_dir = $base_tmp_upgrade_dir."/".$file;
1489
+                                if(file_exists("$base_upgrade_dir/patch/".$package_name.'.zip')){
1490
+                                    $_SESSION['install_file'] = $package_name.".zip";
1491
+                                    break;
1492
+                                }
1493
+                        }
1494
+                        }
1495
+                    }
1496
+                }
1497
+            }
1498
+        }
1499 1499
         if(empty($_SESSION['install_file'])){
1500
-        	unlinkUWTempFiles();
1501
-        	resetUwSession();
1502
-        	echo 'Upload File not found so redirecting to Upgrade Start ';
1503
-        	$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1504
-        	echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1500
+            unlinkUWTempFiles();
1501
+            resetUwSession();
1502
+            echo 'Upload File not found so redirecting to Upgrade Start ';
1503
+            $redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1504
+            echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1505 1505
 $upgrade_directories_not_found =<<<eoq
1506 1506
 	<table cellpadding="3" cellspacing="0" border="0">
1507 1507
 		<tr>
@@ -1512,66 +1512,66 @@  discard block
 block discarded – undo
1512 1512
 	</table>
1513 1513
 eoq;
1514 1514
 $uwMain = $upgrade_directories_not_found;
1515
-				return '';
1515
+                return '';
1516 1516
         }
1517
-		$install_file			= "$base_upgrade_dir/patch/".basename(urldecode( $_SESSION['install_file'] ));
1518
-		$show_files				= true;
1519
-		if(empty($unzip_dir)){
1520
-			$unzip_dir				= mk_temp_dir( $base_tmp_upgrade_dir );
1521
-		}
1522
-		$zip_from_dir			= ".";
1523
-		$zip_to_dir				= ".";
1524
-		$zip_force_copy			= array();
1517
+        $install_file			= "$base_upgrade_dir/patch/".basename(urldecode( $_SESSION['install_file'] ));
1518
+        $show_files				= true;
1519
+        if(empty($unzip_dir)){
1520
+            $unzip_dir				= mk_temp_dir( $base_tmp_upgrade_dir );
1521
+        }
1522
+        $zip_from_dir			= ".";
1523
+        $zip_to_dir				= ".";
1524
+        $zip_force_copy			= array();
1525 1525
 
1526
-		if(!$unzip_dir){
1527
-			logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
1528
-			die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
1529
-		}
1526
+        if(!$unzip_dir){
1527
+            logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
1528
+            die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
1529
+        }
1530 1530
 
1531
-		//double check whether unzipped .
1532
-		if(file_exists($unzip_dir ."/scripts") && file_exists($unzip_dir."/manifest.php")){
1533
-        	//already unzipped
1534
-		}
1535
-		else{
1536
-			unzip( $install_file, $unzip_dir );
1537
-		}
1531
+        //double check whether unzipped .
1532
+        if(file_exists($unzip_dir ."/scripts") && file_exists($unzip_dir."/manifest.php")){
1533
+            //already unzipped
1534
+        }
1535
+        else{
1536
+            unzip( $install_file, $unzip_dir );
1537
+        }
1538 1538
 
1539
-		// assumption -- already validated manifest.php at time of upload
1540
-		require_once( "$unzip_dir/manifest.php" );
1539
+        // assumption -- already validated manifest.php at time of upload
1540
+        require_once( "$unzip_dir/manifest.php" );
1541 1541
 
1542
-		if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
1543
-		    $zip_from_dir   = $manifest['copy_files']['from_dir'];
1544
-		}
1545
-		if( isset( $manifest['copy_files']['to_dir'] ) && $manifest['copy_files']['to_dir'] != "" ){
1546
-		    $zip_to_dir     = $manifest['copy_files']['to_dir'];
1547
-		}
1548
-		if( isset( $manifest['copy_files']['force_copy'] ) && $manifest['copy_files']['force_copy'] != "" ){
1549
-		    $zip_force_copy     = $manifest['copy_files']['force_copy'];
1550
-		}
1551
-		if( isset( $manifest['version'] ) ){
1552
-		    $version    = $manifest['version'];
1553
-		}
1554
-		if( !is_writable( "config.php" ) ){
1555
-			return $mod_strings['ERR_UW_CONFIG'];
1556
-		}
1542
+        if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
1543
+            $zip_from_dir   = $manifest['copy_files']['from_dir'];
1544
+        }
1545
+        if( isset( $manifest['copy_files']['to_dir'] ) && $manifest['copy_files']['to_dir'] != "" ){
1546
+            $zip_to_dir     = $manifest['copy_files']['to_dir'];
1547
+        }
1548
+        if( isset( $manifest['copy_files']['force_copy'] ) && $manifest['copy_files']['force_copy'] != "" ){
1549
+            $zip_force_copy     = $manifest['copy_files']['force_copy'];
1550
+        }
1551
+        if( isset( $manifest['version'] ) ){
1552
+            $version    = $manifest['version'];
1553
+        }
1554
+        if( !is_writable( "config.php" ) ){
1555
+            return $mod_strings['ERR_UW_CONFIG'];
1556
+        }
1557 1557
 
1558
-		$_SESSION['unzip_dir'] = clean_path($unzip_dir);
1559
-		$_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
1560
-		logThis('unzip done.');
1561
-	} else {
1562
-		$unzip_dir = $_SESSION['unzip_dir'];
1563
-		$zip_from_dir = $_SESSION['zip_from_dir'];
1564
-	}
1558
+        $_SESSION['unzip_dir'] = clean_path($unzip_dir);
1559
+        $_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
1560
+        logThis('unzip done.');
1561
+    } else {
1562
+        $unzip_dir = $_SESSION['unzip_dir'];
1563
+        $zip_from_dir = $_SESSION['zip_from_dir'];
1564
+    }
1565 1565
 
1566 1566
     //check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
1567
-	if(!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir'])
1568
-		|| !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])){
1569
-		    //redirect to start
1570
-	    unlinkUWTempFiles();
1571
-		resetUwSession();
1572
-		echo 'Upload File not found so redirecting to Upgrade Start ';
1573
-		$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1574
-		echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1567
+    if(!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir'])
1568
+        || !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])){
1569
+            //redirect to start
1570
+        unlinkUWTempFiles();
1571
+        resetUwSession();
1572
+        echo 'Upload File not found so redirecting to Upgrade Start ';
1573
+        $redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1574
+        echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1575 1575
 $upgrade_directories_not_found =<<<eoq
1576 1576
 	<table cellpadding="3" cellspacing="0" border="0">
1577 1577
 		<tr>
@@ -1582,77 +1582,77 @@  discard block
 block discarded – undo
1582 1582
 	</table>
1583 1583
 eoq;
1584 1584
 $uwMain = $upgrade_directories_not_found;
1585
-				return '';
1586
-	}
1585
+                return '';
1586
+    }
1587 1587
 
1588 1588
     logThis ('is SugarConfig there '.file_exists(clean_path($unzip_dir.'/'.$zip_from_dir."/include/SugarObjects/SugarConfig.php")));
1589
-	if(file_exists(clean_path($unzip_dir.'/'.$zip_from_dir."/include/SugarObjects/SugarConfig.php"))) {
1590
-		$file = clean_path($unzip_dir.'/'.$zip_from_dir."/include/SugarObjects/SugarConfig.php");
1591
-		$destFile = str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), $cwd, $file);
1592
-		if(!is_dir(dirname($destFile))) {
1593
-			mkdir_recursive(dirname($destFile)); // make sure the directory exists
1594
-		}
1589
+    if(file_exists(clean_path($unzip_dir.'/'.$zip_from_dir."/include/SugarObjects/SugarConfig.php"))) {
1590
+        $file = clean_path($unzip_dir.'/'.$zip_from_dir."/include/SugarObjects/SugarConfig.php");
1591
+        $destFile = str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), $cwd, $file);
1592
+        if(!is_dir(dirname($destFile))) {
1593
+            mkdir_recursive(dirname($destFile)); // make sure the directory exists
1594
+        }
1595 1595
         copy($file,$destFile);
1596 1596
         //also copy include utils array utils
1597 1597
         $file = clean_path($unzip_dir.'/'.$zip_from_dir."/include/utils/array_utils.php");
1598
-		$destFile = str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), $cwd, $file);
1599
-		if(!is_dir(dirname($destFile))) {
1600
-			mkdir_recursive(dirname($destFile)); // make sure the directory exists
1601
-		}
1598
+        $destFile = str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), $cwd, $file);
1599
+        if(!is_dir(dirname($destFile))) {
1600
+            mkdir_recursive(dirname($destFile)); // make sure the directory exists
1601
+        }
1602 1602
         copy($file,$destFile);
1603
-	}
1603
+    }
1604 1604
 }
1605 1605
 
1606 1606
 
1607 1607
 function preflightCheck() {
1608
-	require_once('modules/UpgradeWizard/uw_files.php');
1608
+    require_once('modules/UpgradeWizard/uw_files.php');
1609 1609
 
1610
-	global $sugar_config;
1611
-	global $mod_strings;
1612
-	global $sugar_version;
1610
+    global $sugar_config;
1611
+    global $mod_strings;
1612
+    global $sugar_version;
1613 1613
 
1614 1614
     if (empty($sugar_version))
1615 1615
     {
1616 1616
         require('sugar_version.php');
1617 1617
     }
1618 1618
 
1619
-	unset($_SESSION['rebuild_relationships']);
1620
-	unset($_SESSION['rebuild_extensions']);
1621
-
1622
-	// don't bother if are rechecking
1623
-	$manualDiff			= array();
1624
-	if(!isset($_SESSION['unzip_dir']) || empty($_SESSION['unzip_dir'])) {
1625
-		logThis('unzipping files in upgrade archive...');
1626
-		$errors					= array();
1627
-		list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
1628
-		$unzip_dir = '';
1629
-		//Following is if User logged out unexpectedly and then logged into UpgradeWizard again.
1630
-		//also come up with mechanism to read from upgrade-progress file.
1631
-		if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
1632
-			if (file_exists($base_tmp_upgrade_dir) && $handle = opendir($base_tmp_upgrade_dir)) {
1633
-		    	while (false !== ($file = readdir($handle))) {
1634
-		    		if($file !="." && $file !="..")	{
1635
-					 if(is_file($base_tmp_upgrade_dir."/".$file."/manifest.php")){
1636
-					 	require_once($base_tmp_upgrade_dir."/".$file."/manifest.php");
1637
-					 	$package_name= $manifest['copy_files']['from_dir'];
1638
-					 	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")){
1639
-					 		$unzip_dir = $base_tmp_upgrade_dir."/".$file;
1640
-					 		if(file_exists("$base_upgrade_dir/patch/".$package_name.'.zip')){
1641
-					 			$_SESSION['install_file'] = $package_name.".zip";
1642
-					 			break;
1643
-					 		}
1644
-						}
1645
-					  }
1646
-		    		}
1647
-		    	}
1648
-			}
1649
-		}
1619
+    unset($_SESSION['rebuild_relationships']);
1620
+    unset($_SESSION['rebuild_extensions']);
1621
+
1622
+    // don't bother if are rechecking
1623
+    $manualDiff			= array();
1624
+    if(!isset($_SESSION['unzip_dir']) || empty($_SESSION['unzip_dir'])) {
1625
+        logThis('unzipping files in upgrade archive...');
1626
+        $errors					= array();
1627
+        list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
1628
+        $unzip_dir = '';
1629
+        //Following is if User logged out unexpectedly and then logged into UpgradeWizard again.
1630
+        //also come up with mechanism to read from upgrade-progress file.
1631
+        if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
1632
+            if (file_exists($base_tmp_upgrade_dir) && $handle = opendir($base_tmp_upgrade_dir)) {
1633
+                while (false !== ($file = readdir($handle))) {
1634
+                    if($file !="." && $file !="..")	{
1635
+                        if(is_file($base_tmp_upgrade_dir."/".$file."/manifest.php")){
1636
+                            require_once($base_tmp_upgrade_dir."/".$file."/manifest.php");
1637
+                            $package_name= $manifest['copy_files']['from_dir'];
1638
+                            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")){
1639
+                                $unzip_dir = $base_tmp_upgrade_dir."/".$file;
1640
+                                if(file_exists("$base_upgrade_dir/patch/".$package_name.'.zip')){
1641
+                                    $_SESSION['install_file'] = $package_name.".zip";
1642
+                                    break;
1643
+                                }
1644
+                        }
1645
+                        }
1646
+                    }
1647
+                }
1648
+            }
1649
+        }
1650 1650
         if(empty($_SESSION['install_file'])){
1651
-        	unlinkUWTempFiles();
1652
-        	resetUwSession();
1653
-        	echo 'Upload File not found so redirecting to Upgrade Start ';
1654
-        	$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1655
-        	echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1651
+            unlinkUWTempFiles();
1652
+            resetUwSession();
1653
+            echo 'Upload File not found so redirecting to Upgrade Start ';
1654
+            $redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1655
+            echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1656 1656
 $upgrade_directories_not_found =<<<eoq
1657 1657
 	<table cellpadding="3" cellspacing="0" border="0">
1658 1658
 		<tr>
@@ -1663,67 +1663,67 @@  discard block
 block discarded – undo
1663 1663
 	</table>
1664 1664
 eoq;
1665 1665
 $uwMain = $upgrade_directories_not_found;
1666
-				return '';
1666
+                return '';
1667 1667
 
1668 1668
         }
1669
-		$install_file			= "$base_upgrade_dir/patch/".basename(urldecode( $_SESSION['install_file'] ));
1670
-		$show_files				= true;
1671
-		if(empty($unzip_dir)){
1672
-			$unzip_dir				= mk_temp_dir( $base_tmp_upgrade_dir );
1673
-		}
1674
-		$zip_from_dir			= ".";
1675
-		$zip_to_dir				= ".";
1676
-		$zip_force_copy			= array();
1669
+        $install_file			= "$base_upgrade_dir/patch/".basename(urldecode( $_SESSION['install_file'] ));
1670
+        $show_files				= true;
1671
+        if(empty($unzip_dir)){
1672
+            $unzip_dir				= mk_temp_dir( $base_tmp_upgrade_dir );
1673
+        }
1674
+        $zip_from_dir			= ".";
1675
+        $zip_to_dir				= ".";
1676
+        $zip_force_copy			= array();
1677 1677
 
1678
-		if(!$unzip_dir){
1679
-			logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
1680
-			die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
1681
-		}
1678
+        if(!$unzip_dir){
1679
+            logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
1680
+            die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
1681
+        }
1682 1682
 
1683
-		//double check whether unzipped .
1684
-		if(file_exists($unzip_dir ."/scripts") && file_exists($unzip_dir."/manifest.php")){
1685
-        	//already unzipped
1686
-		}
1687
-		else{
1688
-			unzip( $install_file, $unzip_dir );
1689
-		}
1683
+        //double check whether unzipped .
1684
+        if(file_exists($unzip_dir ."/scripts") && file_exists($unzip_dir."/manifest.php")){
1685
+            //already unzipped
1686
+        }
1687
+        else{
1688
+            unzip( $install_file, $unzip_dir );
1689
+        }
1690 1690
 
1691
-		// assumption -- already validated manifest.php at time of upload
1692
-		require_once( "$unzip_dir/manifest.php" );
1691
+        // assumption -- already validated manifest.php at time of upload
1692
+        require_once( "$unzip_dir/manifest.php" );
1693 1693
 
1694
-		if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
1695
-		    $zip_from_dir   = $manifest['copy_files']['from_dir'];
1696
-		}
1697
-		if( isset( $manifest['copy_files']['to_dir'] ) && $manifest['copy_files']['to_dir'] != "" ){
1698
-		    $zip_to_dir     = $manifest['copy_files']['to_dir'];
1699
-		}
1700
-		if( isset( $manifest['copy_files']['force_copy'] ) && $manifest['copy_files']['force_copy'] != "" ){
1701
-		    $zip_force_copy     = $manifest['copy_files']['force_copy'];
1702
-		}
1703
-		if( isset( $manifest['version'] ) ){
1704
-		    $version    = $manifest['version'];
1705
-		}
1706
-		if( !is_writable( "config.php" ) ){
1707
-			return $mod_strings['ERR_UW_CONFIG'];
1708
-		}
1694
+        if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
1695
+            $zip_from_dir   = $manifest['copy_files']['from_dir'];
1696
+        }
1697
+        if( isset( $manifest['copy_files']['to_dir'] ) && $manifest['copy_files']['to_dir'] != "" ){
1698
+            $zip_to_dir     = $manifest['copy_files']['to_dir'];
1699
+        }
1700
+        if( isset( $manifest['copy_files']['force_copy'] ) && $manifest['copy_files']['force_copy'] != "" ){
1701
+            $zip_force_copy     = $manifest['copy_files']['force_copy'];
1702
+        }
1703
+        if( isset( $manifest['version'] ) ){
1704
+            $version    = $manifest['version'];
1705
+        }
1706
+        if( !is_writable( "config.php" ) ){
1707
+            return $mod_strings['ERR_UW_CONFIG'];
1708
+        }
1709 1709
 
1710
-		$_SESSION['unzip_dir'] = clean_path($unzip_dir);
1711
-		$_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
1710
+        $_SESSION['unzip_dir'] = clean_path($unzip_dir);
1711
+        $_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
1712 1712
 
1713
-	 //logThis('unzip done.');
1714
-	} else {
1715
-		$unzip_dir = $_SESSION['unzip_dir'];
1716
-		$zip_from_dir = $_SESSION['zip_from_dir'];
1717
-	}
1718
-	//check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
1719
-	if(!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir'])
1720
-		|| !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])){
1721
-		    //redirect to start
1722
-	    unlinkUWTempFiles();
1723
-		resetUwSession();
1724
-		echo 'Upload File not found so redirecting to Upgrade Start ';
1725
-		$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1726
-		echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1713
+        //logThis('unzip done.');
1714
+    } else {
1715
+        $unzip_dir = $_SESSION['unzip_dir'];
1716
+        $zip_from_dir = $_SESSION['zip_from_dir'];
1717
+    }
1718
+    //check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
1719
+    if(!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir'])
1720
+        || !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])){
1721
+            //redirect to start
1722
+        unlinkUWTempFiles();
1723
+        resetUwSession();
1724
+        echo 'Upload File not found so redirecting to Upgrade Start ';
1725
+        $redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
1726
+        echo '<form name="redirect" action="' .$redirect_new_wizard. '"  method="POST">';
1727 1727
 $upgrade_directories_not_found =<<<eoq
1728 1728
 	<table cellpadding="3" cellspacing="0" border="0">
1729 1729
 		<tr>
@@ -1734,208 +1734,208 @@  discard block
 block discarded – undo
1734 1734
 	</table>
1735 1735
 eoq;
1736 1736
 $uwMain = $upgrade_directories_not_found;
1737
-				return '';
1738
-	}
1739
-	//copy minimum required files
1740
-	fileCopy('include/utils/sugar_file_utils.php');
1737
+                return '';
1738
+    }
1739
+    //copy minimum required files
1740
+    fileCopy('include/utils/sugar_file_utils.php');
1741 1741
 
1742
-	$upgradeFiles = findAllFiles(clean_path("$unzip_dir/$zip_from_dir"), array());
1743
-	$cache_html_files= array();
1742
+    $upgradeFiles = findAllFiles(clean_path("$unzip_dir/$zip_from_dir"), array());
1743
+    $cache_html_files= array();
1744 1744
 
1745
-	// get md5 sums
1746
-	$md5_string = array();
1747
-	if(file_exists(clean_path(getcwd().'/files.md5'))){
1748
-		require(clean_path(getcwd().'/files.md5'));
1749
-	}
1745
+    // get md5 sums
1746
+    $md5_string = array();
1747
+    if(file_exists(clean_path(getcwd().'/files.md5'))){
1748
+        require(clean_path(getcwd().'/files.md5'));
1749
+    }
1750 1750
 
1751
-	// file preflight checks
1752
-	logThis('verifying md5 checksums for files...');
1753
-	foreach($upgradeFiles as $file) {
1754
-		if(in_array(str_replace(clean_path("$unzip_dir/$zip_from_dir") . "/", '', $file), $uw_files))
1755
-			continue; // skip already loaded files
1751
+    // file preflight checks
1752
+    logThis('verifying md5 checksums for files...');
1753
+    foreach($upgradeFiles as $file) {
1754
+        if(in_array(str_replace(clean_path("$unzip_dir/$zip_from_dir") . "/", '', $file), $uw_files))
1755
+            continue; // skip already loaded files
1756 1756
 
1757
-		if(strpos($file, '.md5'))
1758
-			continue; // skip md5 file
1757
+        if(strpos($file, '.md5'))
1758
+            continue; // skip md5 file
1759 1759
 
1760
-		// normalize file paths
1761
-		$file = clean_path($file);
1760
+        // normalize file paths
1761
+        $file = clean_path($file);
1762 1762
 
1763
-		// check that we can move/delete the upgraded file
1764
-		if(!is_writable($file)) {
1765
-			$errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$file;
1766
-		}
1767
-		// check that destination files are writable
1768
-		$destFile = getcwd().str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), '', $file);
1763
+        // check that we can move/delete the upgraded file
1764
+        if(!is_writable($file)) {
1765
+            $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$file;
1766
+        }
1767
+        // check that destination files are writable
1768
+        $destFile = getcwd().str_replace(clean_path($unzip_dir.'/'.$zip_from_dir), '', $file);
1769 1769
 
1770
-		if(is_file($destFile)) { // of course it needs to exist first...
1771
-			if(!is_writable($destFile)) {
1772
-				$errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$destFile;
1773
-			}
1774
-		}
1770
+        if(is_file($destFile)) { // of course it needs to exist first...
1771
+            if(!is_writable($destFile)) {
1772
+                $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$destFile;
1773
+            }
1774
+        }
1775 1775
 
1776
-		///////////////////////////////////////////////////////////////////////
1777
-		////	DIFFS
1778
-		// compare md5s and build up a manual merge list
1779
-		$targetFile = clean_path(".".str_replace(getcwd(),'',$destFile));
1780
-		$targetMd5 = '0';
1781
-		if(is_file($destFile)) {
1782
-			if(strpos($targetFile, '.php')) {
1783
-				// handle PHP files that were hit with the security regex
1784
-				$fp = '';
1785
-				if(function_exists('sugar_fopen')){
1786
-					$fp = sugar_fopen($destFile, 'r');
1787
-				}
1788
-				else{
1789
-					$fp = fopen($destFile, 'r');
1790
-				}
1791
-				$filesize = filesize($destFile);
1792
-				if($filesize > 0) {
1793
-					$fileContents = stream_get_contents($fp);
1794
-					$targetMd5 = md5($fileContents);
1795
-				}
1796
-			} else {
1797
-				$targetMd5 = md5_file($destFile);
1798
-			}
1799
-		}
1776
+        ///////////////////////////////////////////////////////////////////////
1777
+        ////	DIFFS
1778
+        // compare md5s and build up a manual merge list
1779
+        $targetFile = clean_path(".".str_replace(getcwd(),'',$destFile));
1780
+        $targetMd5 = '0';
1781
+        if(is_file($destFile)) {
1782
+            if(strpos($targetFile, '.php')) {
1783
+                // handle PHP files that were hit with the security regex
1784
+                $fp = '';
1785
+                if(function_exists('sugar_fopen')){
1786
+                    $fp = sugar_fopen($destFile, 'r');
1787
+                }
1788
+                else{
1789
+                    $fp = fopen($destFile, 'r');
1790
+                }
1791
+                $filesize = filesize($destFile);
1792
+                if($filesize > 0) {
1793
+                    $fileContents = stream_get_contents($fp);
1794
+                    $targetMd5 = md5($fileContents);
1795
+                }
1796
+            } else {
1797
+                $targetMd5 = md5_file($destFile);
1798
+            }
1799
+        }
1800 1800
 
1801
-		if(isset($md5_string[$targetFile]) && $md5_string[$targetFile] != $targetMd5) {
1802
-			logThis('found a file with a differing md5: ['.$targetFile.']');
1803
-			$manualDiff[] = $destFile;
1804
-		}
1805
-		////	END DIFFS
1806
-		///////////////////////////////////////////////////////////////////////
1807
-	}
1808
-	logThis('md5 verification done.');
1809
-	$errors['manual'] = $manualDiff;
1801
+        if(isset($md5_string[$targetFile]) && $md5_string[$targetFile] != $targetMd5) {
1802
+            logThis('found a file with a differing md5: ['.$targetFile.']');
1803
+            $manualDiff[] = $destFile;
1804
+        }
1805
+        ////	END DIFFS
1806
+        ///////////////////////////////////////////////////////////////////////
1807
+    }
1808
+    logThis('md5 verification done.');
1809
+    $errors['manual'] = $manualDiff;
1810 1810
 
1811
-	return $errors;
1811
+    return $errors;
1812 1812
 }
1813 1813
 
1814 1814
 function fileCopy($file_path){
1815
-	if(file_exists(clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir'].'/'.$file_path))) {
1816
-		$file = clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir'].'/'.$file_path);
1817
-		$destFile = str_replace(clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir']),  clean_path(getcwd()), $file);
1818
-	if(!is_dir(dirname($destFile))) {
1819
-		mkdir_recursive(dirname($destFile)); // make sure the directory exists
1820
-		}
1821
-		copy_recursive($file,$destFile);
1822
-	}
1815
+    if(file_exists(clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir'].'/'.$file_path))) {
1816
+        $file = clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir'].'/'.$file_path);
1817
+        $destFile = str_replace(clean_path($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir']),  clean_path(getcwd()), $file);
1818
+    if(!is_dir(dirname($destFile))) {
1819
+        mkdir_recursive(dirname($destFile)); // make sure the directory exists
1820
+        }
1821
+        copy_recursive($file,$destFile);
1822
+    }
1823 1823
 }
1824 1824
 function getChecklist($steps, $step) {
1825
-	global $mod_strings;
1826
-
1827
-	$skip = array('start', 'cancel', 'uninstall','end');
1828
-	$j=0;
1829
-	$i=1;
1830
-	$ret  = '<table cellpadding="3" cellspacing="4" border="0">';
1831
-	$ret .= '<tr><th colspan="3" align="left">'.$mod_strings['LBL_UW_CHECKLIST'].':</th></tr>';
1832
-	foreach($steps['desc'] as $k => $desc) {
1833
-		if(in_array($steps['files'][$j], $skip)) {
1834
-			$j++;
1835
-			continue;
1836
-		}
1825
+    global $mod_strings;
1837 1826
 
1838
-		//$status = "<span class='error'>{$mod_strings['LBL_UW_INCOMPLETE']}</span>";
1839
-		$desc_mod_pre = '';
1840
-		$desc_mod_post = '';
1841
-		/*
1827
+    $skip = array('start', 'cancel', 'uninstall','end');
1828
+    $j=0;
1829
+    $i=1;
1830
+    $ret  = '<table cellpadding="3" cellspacing="4" border="0">';
1831
+    $ret .= '<tr><th colspan="3" align="left">'.$mod_strings['LBL_UW_CHECKLIST'].':</th></tr>';
1832
+    foreach($steps['desc'] as $k => $desc) {
1833
+        if(in_array($steps['files'][$j], $skip)) {
1834
+            $j++;
1835
+            continue;
1836
+        }
1837
+
1838
+        //$status = "<span class='error'>{$mod_strings['LBL_UW_INCOMPLETE']}</span>";
1839
+        $desc_mod_pre = '';
1840
+        $desc_mod_post = '';
1841
+        /*
1842 1842
 		if(isset($_SESSION['step'][$steps['files'][$k]]) && $_SESSION['step'][$steps['files'][$k]] == 'success') {
1843 1843
 			//$status = $mod_strings['LBL_UW_COMPLETE'];
1844 1844
 		}
1845 1845
 		*/
1846 1846
 
1847
-		if($k == $_REQUEST['step']) {
1848
-			//$status = $mod_strings['LBL_UW_IN_PROGRESS'];
1849
-			$desc_mod_pre = "<font color=blue><i>";
1850
-			$desc_mod_post = "</i></font>";
1851
-		}
1847
+        if($k == $_REQUEST['step']) {
1848
+            //$status = $mod_strings['LBL_UW_IN_PROGRESS'];
1849
+            $desc_mod_pre = "<font color=blue><i>";
1850
+            $desc_mod_post = "</i></font>";
1851
+        }
1852 1852
 
1853
-		$ret .= "<tr><td>&nbsp;</td><td><b>{$i}: {$desc_mod_pre}{$desc}{$desc_mod_post}</b></td>";
1854
-		$ret .= "<td id={$steps['files'][$j]}><i></i></td></tr>";
1855
-		$i++;
1856
-		$j++;
1857
-	}
1858
-	$ret .= "</table>";
1859
-	return $ret;
1853
+        $ret .= "<tr><td>&nbsp;</td><td><b>{$i}: {$desc_mod_pre}{$desc}{$desc_mod_post}</b></td>";
1854
+        $ret .= "<td id={$steps['files'][$j]}><i></i></td></tr>";
1855
+        $i++;
1856
+        $j++;
1857
+    }
1858
+    $ret .= "</table>";
1859
+    return $ret;
1860 1860
 }
1861 1861
 
1862 1862
 function prepSystemForUpgrade() {
1863
-	global $sugar_config;
1864
-	global $sugar_flavor;
1865
-	global $mod_strings;
1863
+    global $sugar_config;
1864
+    global $sugar_flavor;
1865
+    global $mod_strings;
1866 1866
     global $current_language;
1867
-	global $subdirs;
1868
-	global $base_upgrade_dir;
1869
-	global $base_tmp_upgrade_dir;
1867
+    global $subdirs;
1868
+    global $base_upgrade_dir;
1869
+    global $base_tmp_upgrade_dir;
1870 1870
     list($p_base_upgrade_dir, $p_base_tmp_upgrade_dir) = getUWDirs();
1871
-	///////////////////////////////////////////////////////////////////////////////
1872
-	////	Make sure variables exist
1873
-	if(empty($base_upgrade_dir)){
1874
-		$base_upgrade_dir       = $p_base_upgrade_dir;
1875
-	}
1876
-	if(empty($base_tmp_upgrade_dir)){
1877
-		$base_tmp_upgrade_dir   = $p_base_tmp_upgrade_dir;
1878
-	}
1879
-	sugar_mkdir($base_tmp_upgrade_dir, 0775, true);
1880
-	if(!isset($subdirs) || empty($subdirs)){
1881
-		$subdirs = array('full', 'langpack', 'module', 'patch', 'theme');
1882
-	}
1871
+    ///////////////////////////////////////////////////////////////////////////////
1872
+    ////	Make sure variables exist
1873
+    if(empty($base_upgrade_dir)){
1874
+        $base_upgrade_dir       = $p_base_upgrade_dir;
1875
+    }
1876
+    if(empty($base_tmp_upgrade_dir)){
1877
+        $base_tmp_upgrade_dir   = $p_base_tmp_upgrade_dir;
1878
+    }
1879
+    sugar_mkdir($base_tmp_upgrade_dir, 0775, true);
1880
+    if(!isset($subdirs) || empty($subdirs)){
1881
+        $subdirs = array('full', 'langpack', 'module', 'patch', 'theme');
1882
+    }
1883 1883
 
1884 1884
     $upgrade_progress_dir = $base_tmp_upgrade_dir;
1885 1885
     $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
1886 1886
     if(file_exists($upgrade_progress_file)){
1887
-    	if(function_exists('get_upgrade_progress') && function_exists('didThisStepRunBefore')){
1888
-    		if(didThisStepRunBefore('end')){
1889
-    			include($upgrade_progress_file);
1890
-    			unset($upgrade_config);
1891
-    			unlink($upgrade_progress_file);
1892
-    		}
1893
-    	}
1887
+        if(function_exists('get_upgrade_progress') && function_exists('didThisStepRunBefore')){
1888
+            if(didThisStepRunBefore('end')){
1889
+                include($upgrade_progress_file);
1890
+                unset($upgrade_config);
1891
+                unlink($upgrade_progress_file);
1892
+            }
1893
+        }
1894 1894
     }
1895 1895
 
1896 1896
     // increase the cuttoff time to 1 hour
1897
-	ini_set("max_execution_time", "3600");
1897
+    ini_set("max_execution_time", "3600");
1898 1898
 
1899 1899
     // make sure dirs exist
1900
-	if($subdirs != null){
1901
-		foreach($subdirs as $subdir) {
1902
-		    sugar_mkdir("$base_upgrade_dir/$subdir", 0775, true);
1903
-		}
1904
-	}
1905
-	// array of special scripts that are executed during (un)installation-- key is type of script, value is filename
1906
-	if(!defined('SUGARCRM_PRE_INSTALL_FILE')) {
1907
-		define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
1908
-		define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
1909
-		define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
1910
-		define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
1911
-	}
1900
+    if($subdirs != null){
1901
+        foreach($subdirs as $subdir) {
1902
+            sugar_mkdir("$base_upgrade_dir/$subdir", 0775, true);
1903
+        }
1904
+    }
1905
+    // array of special scripts that are executed during (un)installation-- key is type of script, value is filename
1906
+    if(!defined('SUGARCRM_PRE_INSTALL_FILE')) {
1907
+        define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
1908
+        define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
1909
+        define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
1910
+        define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
1911
+    }
1912 1912
 
1913
-	$script_files = array(
1914
-		"pre-install" => constant('SUGARCRM_PRE_INSTALL_FILE'),
1915
-		"post-install" => constant('SUGARCRM_POST_INSTALL_FILE'),
1916
-		"pre-uninstall" => constant('SUGARCRM_PRE_UNINSTALL_FILE'),
1917
-		"post-uninstall" => constant('SUGARCRM_POST_UNINSTALL_FILE'),
1918
-	);
1913
+    $script_files = array(
1914
+        "pre-install" => constant('SUGARCRM_PRE_INSTALL_FILE'),
1915
+        "post-install" => constant('SUGARCRM_POST_INSTALL_FILE'),
1916
+        "pre-uninstall" => constant('SUGARCRM_PRE_UNINSTALL_FILE'),
1917
+        "post-uninstall" => constant('SUGARCRM_POST_UNINSTALL_FILE'),
1918
+    );
1919 1919
 
1920
-	// check that the upload limit is set to 6M or greater
1921
-	define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024);  // 6 Megabytes
1922
-	$upload_max_filesize = ini_get('upload_max_filesize');
1923
-	$upload_max_filesize_bytes = return_bytes($upload_max_filesize);
1920
+    // check that the upload limit is set to 6M or greater
1921
+    define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024);  // 6 Megabytes
1922
+    $upload_max_filesize = ini_get('upload_max_filesize');
1923
+    $upload_max_filesize_bytes = return_bytes($upload_max_filesize);
1924 1924
 
1925
-	if($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
1926
-		$GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize");
1925
+    if($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
1926
+        $GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize");
1927 1927
         $admin_strings = return_module_language($current_language, 'Administration');
1928
-		echo '<p class="error">'.$admin_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'].' '.get_cfg_var('cfg_file_path')."</p>\n";
1929
-	}
1928
+        echo '<p class="error">'.$admin_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'].' '.get_cfg_var('cfg_file_path')."</p>\n";
1929
+    }
1930 1930
 }
1931 1931
 
1932 1932
 if ( !function_exists('extractFile') ) {
1933 1933
 function extractFile($zip_file, $file_in_zip) {
1934 1934
     global $base_tmp_upgrade_dir;
1935 1935
 
1936
-	// strip cwd
1937
-	$absolute_base_tmp_upgrade_dir = clean_path($base_tmp_upgrade_dir);
1938
-	$relative_base_tmp_upgrade_dir = clean_path(str_replace(clean_path(getcwd()), '', $absolute_base_tmp_upgrade_dir));
1936
+    // strip cwd
1937
+    $absolute_base_tmp_upgrade_dir = clean_path($base_tmp_upgrade_dir);
1938
+    $relative_base_tmp_upgrade_dir = clean_path(str_replace(clean_path(getcwd()), '', $absolute_base_tmp_upgrade_dir));
1939 1939
 
1940 1940
     // mk_temp_dir expects relative pathing
1941 1941
     $my_zip_dir = mk_temp_dir($relative_base_tmp_upgrade_dir);
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 
1949 1949
 if ( !function_exists('extractManifest') ) {
1950 1950
 function extractManifest($zip_file) {
1951
-	logThis('extracting manifest.');
1951
+    logThis('extracting manifest.');
1952 1952
     return(extractFile($zip_file, "manifest.php"));
1953 1953
 }
1954 1954
 }
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 function getInstallType($type_string) {
1958 1958
     // detect file type
1959 1959
     global $subdirs;
1960
-	$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
1960
+    $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
1961 1961
     foreach($subdirs as $subdir) {
1962 1962
         if(preg_match("#/$subdir/#", $type_string)) {
1963 1963
             return($subdir);
@@ -2030,15 +2030,15 @@  discard block
 block discarded – undo
2030 2030
  * @return string Error message, blank on success
2031 2031
  */
2032 2032
 function validate_manifest($manifest) {
2033
-	logThis('validating manifest.php file');
2033
+    logThis('validating manifest.php file');
2034 2034
     // takes a manifest.php manifest array and validates contents
2035 2035
     global $subdirs;
2036 2036
     global $sugar_version;
2037
-	global $sugar_config;
2037
+    global $sugar_config;
2038 2038
     global $sugar_flavor;
2039
-	global $mod_strings;
2039
+    global $mod_strings;
2040 2040
 
2041
-	include_once('suitecrm_version.php');
2041
+    include_once('suitecrm_version.php');
2042 2042
 
2043 2043
     if(!isset($manifest['type'])) {
2044 2044
         return $mod_strings['ERROR_MANIFEST_TYPE'];
@@ -2047,95 +2047,95 @@  discard block
 block discarded – undo
2047 2047
     $type = $manifest['type'];
2048 2048
 
2049 2049
     if(getInstallType("/$type/") == "") {
2050
-		return $mod_strings['ERROR_PACKAGE_TYPE']. ": '" . $type . "'.";
2051
-    }
2052
-
2053
-	if(isset($manifest['acceptable_php_versions'])) {
2054
-		$version_ok = false;
2055
-		$matches_empty = true;
2056
-		if(isset($manifest['acceptable_php_versions']['exact_matches'])) {
2057
-			$matches_empty = false;
2058
-			foreach($manifest['acceptable_php_versions']['exact_matches'] as $match) {
2059
-				if($match == PHP_VERSION) {
2060
-					$version_ok = true;
2061
-				}
2062
-			}
2063
-		}
2064
-		if(!$version_ok && isset($manifest['acceptable_php_versions']['regex_matches'])) {
2065
-			$matches_empty = false;
2066
-			foreach($manifest['acceptable_php_versions']['regex_matches'] as $match) {
2067
-				if(preg_match("/$match/", PHP_VERSION)) {
2068
-					$version_ok = true;
2069
-				}
2070
-			}
2071
-		}
2050
+        return $mod_strings['ERROR_PACKAGE_TYPE']. ": '" . $type . "'.";
2051
+    }
2072 2052
 
2073
-		if(!$matches_empty && !$version_ok) {
2074
-			return $mod_strings['ERROR_PHP_VERSION_INCOMPATIBLE']."<br />".
2075
-			$mod_strings['ERR_UW_PHP_VERSION'].PHP_VERSION;
2076
-		}
2077
-	}
2053
+    if(isset($manifest['acceptable_php_versions'])) {
2054
+        $version_ok = false;
2055
+        $matches_empty = true;
2056
+        if(isset($manifest['acceptable_php_versions']['exact_matches'])) {
2057
+            $matches_empty = false;
2058
+            foreach($manifest['acceptable_php_versions']['exact_matches'] as $match) {
2059
+                if($match == PHP_VERSION) {
2060
+                    $version_ok = true;
2061
+                }
2062
+            }
2063
+        }
2064
+        if(!$version_ok && isset($manifest['acceptable_php_versions']['regex_matches'])) {
2065
+            $matches_empty = false;
2066
+            foreach($manifest['acceptable_php_versions']['regex_matches'] as $match) {
2067
+                if(preg_match("/$match/", PHP_VERSION)) {
2068
+                    $version_ok = true;
2069
+                }
2070
+            }
2071
+        }
2078 2072
 
2073
+        if(!$matches_empty && !$version_ok) {
2074
+            return $mod_strings['ERROR_PHP_VERSION_INCOMPATIBLE']."<br />".
2075
+            $mod_strings['ERR_UW_PHP_VERSION'].PHP_VERSION;
2076
+        }
2077
+    }
2079 2078
 
2080
-	if(!isset($manifest['acceptable_suitecrm_versions'])) {
2081
-		// If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions not set check on sugar version.
2082
-		if (isset($manifest['acceptable_sugar_versions'])) {
2083
-			$version_ok = false;
2084
-			$matches_empty = true;
2085
-			if (isset($manifest['acceptable_sugar_versions']['exact_matches'])) {
2086
-				$matches_empty = false;
2087
-				foreach ($manifest['acceptable_sugar_versions']['exact_matches'] as $match) {
2088
-					if ($match == $sugar_version) {
2089
-						$version_ok = true;
2090
-					}
2091
-				}
2092
-			}
2093
-			if (!$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches'])) {
2094
-				$matches_empty = false;
2095
-				foreach ($manifest['acceptable_sugar_versions']['regex_matches'] as $match) {
2096
-					if (preg_match("/$match/", $sugar_version)) {
2097
-						$version_ok = true;
2098
-					}
2099
-				}
2100
-			}
2101
-
2102
-			if (!$matches_empty && !$version_ok) {
2103
-				return $mod_strings['ERROR_VERSION_INCOMPATIBLE'] . "<br />" .
2104
-				$mod_strings['ERR_UW_VERSION'] . $sugar_version;
2105
-			}
2106
-		}
2107
-		else {
2108
-			// if neither set reject
2109
-			return $mod_strings['ERROR_NO_VERSION_SET'];
2110
-		}
2111
-	}
2112
-	else {
2113
-		// If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
2114
-		// If sugarcrm version not set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
2115
-		$version_ok = false;
2116
-		$matches_empty = true;
2117
-		if (isset($manifest['acceptable_suitecrm_versions']['exact_matches'])) {
2118
-			$matches_empty = false;
2119
-			foreach ($manifest['acceptable_suitecrm_versions']['exact_matches'] as $match) {
2120
-				if ($match == $suitecrm_version) {
2121
-					$version_ok = true;
2122
-				}
2123
-			}
2124
-		}
2125
-		if (!$version_ok && isset($manifest['acceptable_suitecrm_versions']['regex_matches'])) {
2126
-			$matches_empty = false;
2127
-			foreach ($manifest['acceptable_suitecrm_versions']['regex_matches'] as $match) {
2128
-				if (preg_match("/$match/", $suitecrm_version)) {
2129
-					$version_ok = true;
2130
-				}
2131
-			}
2132
-		}
2133 2079
 
2134
-		if (!$matches_empty && !$version_ok) {
2135
-			return $mod_strings['ERROR_SUITECRM_VERSION_INCOMPATIBLE'] . "<br />" .
2136
-			$mod_strings['ERR_UW_SUITECRM_VERSION'] . $suitecrm_version;
2137
-		}
2138
-	}
2080
+    if(!isset($manifest['acceptable_suitecrm_versions'])) {
2081
+        // If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions not set check on sugar version.
2082
+        if (isset($manifest['acceptable_sugar_versions'])) {
2083
+            $version_ok = false;
2084
+            $matches_empty = true;
2085
+            if (isset($manifest['acceptable_sugar_versions']['exact_matches'])) {
2086
+                $matches_empty = false;
2087
+                foreach ($manifest['acceptable_sugar_versions']['exact_matches'] as $match) {
2088
+                    if ($match == $sugar_version) {
2089
+                        $version_ok = true;
2090
+                    }
2091
+                }
2092
+            }
2093
+            if (!$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches'])) {
2094
+                $matches_empty = false;
2095
+                foreach ($manifest['acceptable_sugar_versions']['regex_matches'] as $match) {
2096
+                    if (preg_match("/$match/", $sugar_version)) {
2097
+                        $version_ok = true;
2098
+                    }
2099
+                }
2100
+            }
2101
+
2102
+            if (!$matches_empty && !$version_ok) {
2103
+                return $mod_strings['ERROR_VERSION_INCOMPATIBLE'] . "<br />" .
2104
+                $mod_strings['ERR_UW_VERSION'] . $sugar_version;
2105
+            }
2106
+        }
2107
+        else {
2108
+            // if neither set reject
2109
+            return $mod_strings['ERROR_NO_VERSION_SET'];
2110
+        }
2111
+    }
2112
+    else {
2113
+        // If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
2114
+        // If sugarcrm version not set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
2115
+        $version_ok = false;
2116
+        $matches_empty = true;
2117
+        if (isset($manifest['acceptable_suitecrm_versions']['exact_matches'])) {
2118
+            $matches_empty = false;
2119
+            foreach ($manifest['acceptable_suitecrm_versions']['exact_matches'] as $match) {
2120
+                if ($match == $suitecrm_version) {
2121
+                    $version_ok = true;
2122
+                }
2123
+            }
2124
+        }
2125
+        if (!$version_ok && isset($manifest['acceptable_suitecrm_versions']['regex_matches'])) {
2126
+            $matches_empty = false;
2127
+            foreach ($manifest['acceptable_suitecrm_versions']['regex_matches'] as $match) {
2128
+                if (preg_match("/$match/", $suitecrm_version)) {
2129
+                    $version_ok = true;
2130
+                }
2131
+            }
2132
+        }
2133
+
2134
+        if (!$matches_empty && !$version_ok) {
2135
+            return $mod_strings['ERROR_SUITECRM_VERSION_INCOMPATIBLE'] . "<br />" .
2136
+            $mod_strings['ERR_UW_SUITECRM_VERSION'] . $suitecrm_version;
2137
+        }
2138
+    }
2139 2139
 
2140 2140
     if(isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0) {
2141 2141
         $flavor_ok = false;
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 }
2158 2158
 
2159 2159
 function unlinkUploadFiles() {
2160
-	return;
2160
+    return;
2161 2161
 //	logThis('at unlinkUploadFiles()');
2162 2162
 //
2163 2163
 //	if(isset($_SESSION['install_file']) && !empty($_SESSION['install_file'])) {
@@ -2174,37 +2174,37 @@  discard block
 block discarded – undo
2174 2174
  * deletes files created by unzipping a package
2175 2175
  */
2176 2176
 function unlinkUWTempFiles() {
2177
-	global $sugar_config;
2178
-	global $path;
2177
+    global $sugar_config;
2178
+    global $path;
2179 2179
 
2180
-	logThis('at unlinkUWTempFiles()');
2181
-	$tempDir='';
2182
-	list($upgDir, $tempDir) = getUWDirs();
2180
+    logThis('at unlinkUWTempFiles()');
2181
+    $tempDir='';
2182
+    list($upgDir, $tempDir) = getUWDirs();
2183 2183
 
2184 2184
     if(file_exists($tempDir) && is_dir($tempDir)){
2185
-		$files = findAllFiles($tempDir, array(), false);
2186
-		rsort($files);
2187
-		foreach($files as $file) {
2188
-			if(!is_dir($file)) {
2189
-				//logThis('unlinking ['.$file.']', $path);
2190
-				@unlink($file);
2191
-			}
2192
-		}
2193
-		// now do dirs
2194
-		$files = findAllFiles($tempDir, array(), true);
2195
-		foreach($files as $dir) {
2196
-			if(is_dir($dir)) {
2197
-				//logThis('removing dir ['.$dir.']', $path);
2198
-				@rmdir($dir);
2199
-			}
2200
-		}
2201
-		$cacheFile = sugar_cached("modules/UpgradeWizard/_persistence.php");
2202
-		if(is_file($cacheFile)) {
2203
-			logThis("Unlinking Upgrade cache file: '_persistence.php'", $path);
2204
-			@unlink($cacheFile);
2205
-		}
2206
-	}
2207
-	logThis("finished!");
2185
+        $files = findAllFiles($tempDir, array(), false);
2186
+        rsort($files);
2187
+        foreach($files as $file) {
2188
+            if(!is_dir($file)) {
2189
+                //logThis('unlinking ['.$file.']', $path);
2190
+                @unlink($file);
2191
+            }
2192
+        }
2193
+        // now do dirs
2194
+        $files = findAllFiles($tempDir, array(), true);
2195
+        foreach($files as $dir) {
2196
+            if(is_dir($dir)) {
2197
+                //logThis('removing dir ['.$dir.']', $path);
2198
+                @rmdir($dir);
2199
+            }
2200
+        }
2201
+        $cacheFile = sugar_cached("modules/UpgradeWizard/_persistence.php");
2202
+        if(is_file($cacheFile)) {
2203
+            logThis("Unlinking Upgrade cache file: '_persistence.php'", $path);
2204
+            @unlink($cacheFile);
2205
+        }
2206
+    }
2207
+    logThis("finished!");
2208 2208
 }
2209 2209
 
2210 2210
 /**
@@ -2215,44 +2215,44 @@  discard block
 block discarded – undo
2215 2215
  * returned collection
2216 2216
  */
2217 2217
 function uwFindAllFiles($dir, $theArray, $includeDirs=false, $skipDirs=array(), $echo=false) {
2218
-	// check skips
2218
+    // check skips
2219 2219
     if (whetherNeedToSkipDir($dir, $skipDirs))
2220
-	{
2221
-	    return $theArray;
2222
-	}
2220
+    {
2221
+        return $theArray;
2222
+    }
2223 2223
 
2224 2224
     if (!is_dir($dir)) { return $theArray; }   // Bug # 46035, just checking for valid dir
2225
-	$d = dir($dir);
2225
+    $d = dir($dir);
2226 2226
     if ($d === false)  { return $theArray; }   // Bug # 46035, more checking
2227 2227
 
2228
-	while($f = $d->read()) {
2229
-	                                // bug 40793 Skip Directories array in upgradeWizard does not function correctly
2230
-	    if($f == "." || $f == ".." || whetherNeedToSkipDir("$dir/$f", $skipDirs)) { // skip *nix self/parent
2231
-	        continue;
2232
-	    }
2228
+    while($f = $d->read()) {
2229
+                                    // bug 40793 Skip Directories array in upgradeWizard does not function correctly
2230
+        if($f == "." || $f == ".." || whetherNeedToSkipDir("$dir/$f", $skipDirs)) { // skip *nix self/parent
2231
+            continue;
2232
+        }
2233 2233
 
2234
-		// for AJAX length count
2235
-    	if($echo) {
2236
-	    	echo '.';
2237
-	    	ob_flush();
2238
-    	}
2234
+        // for AJAX length count
2235
+        if($echo) {
2236
+            echo '.';
2237
+            ob_flush();
2238
+        }
2239 2239
 
2240
-	    if(is_dir("$dir/$f")) {
2241
-			if($includeDirs) { // add the directory if flagged
2242
-				$theArray[] = clean_path("$dir/$f");
2243
-			}
2240
+        if(is_dir("$dir/$f")) {
2241
+            if($includeDirs) { // add the directory if flagged
2242
+                $theArray[] = clean_path("$dir/$f");
2243
+            }
2244 2244
 
2245
-			// recurse in
2246
-	        $theArray = uwFindAllFiles("$dir/$f/", $theArray, $includeDirs, $skipDirs, $echo);
2247
-	    } else {
2248
-	        $theArray[] = clean_path("$dir/$f");
2249
-	    }
2245
+            // recurse in
2246
+            $theArray = uwFindAllFiles("$dir/$f/", $theArray, $includeDirs, $skipDirs, $echo);
2247
+        } else {
2248
+            $theArray[] = clean_path("$dir/$f");
2249
+        }
2250 2250
 
2251 2251
 
2252
-	}
2253
-	rsort($theArray);
2254
-	$d->close();
2255
-	return $theArray;
2252
+    }
2253
+    rsort($theArray);
2254
+    $d->close();
2255
+    return $theArray;
2256 2256
 }
2257 2257
 
2258 2258
 
@@ -2261,46 +2261,46 @@  discard block
 block discarded – undo
2261 2261
  * unset's UW's Session Vars
2262 2262
  */
2263 2263
 function resetUwSession() {
2264
-	logThis('resetting $_SESSION');
2265
-
2266
-	if(isset($_SESSION['committed']))
2267
-		unset($_SESSION['committed']);
2268
-	if(isset($_SESSION['sugar_version_file']))
2269
-		unset($_SESSION['sugar_version_file']);
2270
-	if(isset($_SESSION['upgrade_complete']))
2271
-		unset($_SESSION['upgrade_complete']);
2272
-	if(isset($_SESSION['allTables']))
2273
-		unset($_SESSION['allTables']);
2274
-	if(isset($_SESSION['alterCustomTableQueries']))
2275
-		unset($_SESSION['alterCustomTableQueries']);
2276
-	if(isset($_SESSION['skip_zip_upload']))
2277
-		unset($_SESSION['skip_zip_upload']);
2278
-	if(isset($_SESSION['install_file']))
2279
-		unset($_SESSION['install_file']);
2280
-	if(isset($_SESSION['unzip_dir']))
2281
-		unset($_SESSION['unzip_dir']);
2282
-	if(isset($_SESSION['zip_from_dir']))
2283
-		unset($_SESSION['zip_from_dir']);
2284
-	if(isset($_SESSION['overwrite_files']))
2285
-		unset($_SESSION['overwrite_files']);
2286
-	if(isset($_SESSION['schema_change']))
2287
-		unset($_SESSION['schema_change']);
2288
-	if(isset($_SESSION['uw_restore_dir']))
2289
-		unset($_SESSION['uw_restore_dir']);
2290
-	if(isset($_SESSION['step']))
2291
-		unset($_SESSION['step']);
2292
-	if(isset($_SESSION['files']))
2293
-		unset($_SESSION['files']);
2294
-	if(isset($_SESSION['Upgraded451Wizard'])){
2295
-		unset($_SESSION['Upgraded451Wizard']);
2296
-	}
2297
-	if(isset($_SESSION['Initial_451to500_Step'])){
2298
-		unset($_SESSION['Initial_451to500_Step']);
2299
-	}
2300
-	if(isset($_SESSION['license_shown']))
2301
-		unset($_SESSION['license_shown']);
2264
+    logThis('resetting $_SESSION');
2265
+
2266
+    if(isset($_SESSION['committed']))
2267
+        unset($_SESSION['committed']);
2268
+    if(isset($_SESSION['sugar_version_file']))
2269
+        unset($_SESSION['sugar_version_file']);
2270
+    if(isset($_SESSION['upgrade_complete']))
2271
+        unset($_SESSION['upgrade_complete']);
2272
+    if(isset($_SESSION['allTables']))
2273
+        unset($_SESSION['allTables']);
2274
+    if(isset($_SESSION['alterCustomTableQueries']))
2275
+        unset($_SESSION['alterCustomTableQueries']);
2276
+    if(isset($_SESSION['skip_zip_upload']))
2277
+        unset($_SESSION['skip_zip_upload']);
2278
+    if(isset($_SESSION['install_file']))
2279
+        unset($_SESSION['install_file']);
2280
+    if(isset($_SESSION['unzip_dir']))
2281
+        unset($_SESSION['unzip_dir']);
2282
+    if(isset($_SESSION['zip_from_dir']))
2283
+        unset($_SESSION['zip_from_dir']);
2284
+    if(isset($_SESSION['overwrite_files']))
2285
+        unset($_SESSION['overwrite_files']);
2286
+    if(isset($_SESSION['schema_change']))
2287
+        unset($_SESSION['schema_change']);
2288
+    if(isset($_SESSION['uw_restore_dir']))
2289
+        unset($_SESSION['uw_restore_dir']);
2290
+    if(isset($_SESSION['step']))
2291
+        unset($_SESSION['step']);
2292
+    if(isset($_SESSION['files']))
2293
+        unset($_SESSION['files']);
2294
+    if(isset($_SESSION['Upgraded451Wizard'])){
2295
+        unset($_SESSION['Upgraded451Wizard']);
2296
+    }
2297
+    if(isset($_SESSION['Initial_451to500_Step'])){
2298
+        unset($_SESSION['Initial_451to500_Step']);
2299
+    }
2300
+    if(isset($_SESSION['license_shown']))
2301
+        unset($_SESSION['license_shown']);
2302 2302
     if(isset($_SESSION['sugarMergeRunResults']))
2303
-		unset($_SESSION['sugarMergeRunResults']);
2303
+        unset($_SESSION['sugarMergeRunResults']);
2304 2304
 }
2305 2305
 
2306 2306
 /**
@@ -2309,72 +2309,72 @@  discard block
 block discarded – undo
2309 2309
  */
2310 2310
 function UWrebuild() {
2311 2311
 	
2312
-	$GLOBALS['log']->deprecated('UWrebuild is deprecated');
2312
+    $GLOBALS['log']->deprecated('UWrebuild is deprecated');
2313 2313
 }
2314 2314
 
2315 2315
 function getCustomTables() {
2316
-	global $db;
2316
+    global $db;
2317 2317
 
2318 2318
     return $db->tablesLike('%_cstm');
2319 2319
 }
2320 2320
 
2321 2321
 function alterCustomTables($customTables)
2322 2322
 {
2323
-	return array();
2323
+    return array();
2324 2324
 }
2325 2325
 
2326 2326
 function getAllTables() {
2327
-	global $db;
2327
+    global $db;
2328 2328
     return $db->getTablesArray();
2329 2329
 }
2330 2330
 
2331 2331
 function printAlterTableSql($tables)
2332 2332
 {
2333
-	$alterTableSql = '';
2333
+    $alterTableSql = '';
2334 2334
 
2335
-	foreach($tables as $table)
2336
-		$alterTableSql .= "ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" . "\n";
2335
+    foreach($tables as $table)
2336
+        $alterTableSql .= "ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" . "\n";
2337 2337
 
2338
-	return $alterTableSql;
2338
+    return $alterTableSql;
2339 2339
 }
2340 2340
 
2341 2341
 function executeConvertTablesSql($tables)
2342 2342
 {
2343
-	global $db;
2343
+    global $db;
2344 2344
 
2345
-	foreach($tables as $table){
2346
-		$query = "ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
2347
-		if(!empty($table)){
2348
-			logThis("Sending query: ".$query);
2345
+    foreach($tables as $table){
2346
+        $query = "ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
2347
+        if(!empty($table)){
2348
+            logThis("Sending query: ".$query);
2349 2349
             $db->query($query);//, true, "An error has occured while performing db query.  See log file for details.<br>");
2350
-         }
2351
-	}
2352
-	return true;
2350
+            }
2351
+    }
2352
+    return true;
2353 2353
 }
2354 2354
 
2355 2355
 function testThis() {
2356
-	$files = uwFindAllFiles(getcwd().'/test', array());
2356
+    $files = uwFindAllFiles(getcwd().'/test', array());
2357 2357
 
2358
-	$out = "<table cellpadding='1' cellspacing='0' border='0'>\n";
2358
+    $out = "<table cellpadding='1' cellspacing='0' border='0'>\n";
2359 2359
 
2360
-	$priorPath = '';
2361
-	foreach($files as $file) {
2362
-		$relativeFile = clean_path(str_replace(getcwd().'/test', '', $file));
2363
-		$relativeFile = ($relativeFile{0} == '/') ? substr($relativeFile, 1, strlen($relativeFile)) : $relativeFile;
2360
+    $priorPath = '';
2361
+    foreach($files as $file) {
2362
+        $relativeFile = clean_path(str_replace(getcwd().'/test', '', $file));
2363
+        $relativeFile = ($relativeFile{0} == '/') ? substr($relativeFile, 1, strlen($relativeFile)) : $relativeFile;
2364 2364
 
2365
-		$relativePath = dirname($relativeFile);
2365
+        $relativePath = dirname($relativeFile);
2366 2366
 
2367
-		if($relativePath == $priorPath) { // same dir, new file
2368
-			$out .= "<tr><td>".basename($relativeFile)."</td></tr>";
2369
-			$priorPath = $relativePath;
2370
-		} else { // new dir
2367
+        if($relativePath == $priorPath) { // same dir, new file
2368
+            $out .= "<tr><td>".basename($relativeFile)."</td></tr>";
2369
+            $priorPath = $relativePath;
2370
+        } else { // new dir
2371 2371
 
2372
-		}
2373
-	}
2372
+        }
2373
+    }
2374 2374
 
2375
-	$out .= "</table>";
2375
+    $out .= "</table>";
2376 2376
 
2377
-	echo $out;
2377
+    echo $out;
2378 2378
 }
2379 2379
 
2380 2380
 
@@ -2382,35 +2382,35 @@  discard block
 block discarded – undo
2382 2382
 
2383 2383
 function testThis2($dir, $id=0, $hide=false) {
2384 2384
     global $mod_strings;
2385
-	$path = $dir;
2386
-	$dh = opendir($dir);
2387
-	rewinddir($dh);
2388
-
2389
-	$doHide = ($hide) ? 'none' : '';
2390
-	$out = "<div id='{$id}' style='display:{$doHide};'>";
2391
-	$out .= "<table cellpadding='1' cellspacing='0' style='border:0px solid #ccc'>\n";
2392
-
2393
-	while($file = readdir($dh)) {
2394
-		if($file == '.' || $file == '..' || $file == 'CVS' || $file == '.cvsignore')
2395
-			continue;
2396
-
2397
-		if(is_dir($path.'/'.$file)) {
2398
-			$file = $path.'/'.$file;
2399
-			$newI = create_guid();
2400
-			$out .= "<tr><td valign='top'><a href='javascript:toggleNwFiles(\"{$newI}\");'>".SugarThemeRegistry::current()->getImage("Workflow", "", null, null, ".gif", $mod_strings['LBL_WORKFLOW'])."</a></td>\n";
2401
-			$out .= "<td valign='top'><b><a href='javascript:toggleNwFiles(\"{$newI}\");'>".basename($file)."</a></b></td></tr>";
2402
-			$out .= "<tr><td></td><td valign='top'>".testThis2($file, $newI, true)."</td></tr>";
2403
-		} else {
2404
-			$out .= "<tr><td valign='top'>&nbsp;</td>\n";
2405
-			$out .= "<td valign='top'>".basename($file)."</td></tr>";
2406
-		}
2407
-	}
2385
+    $path = $dir;
2386
+    $dh = opendir($dir);
2387
+    rewinddir($dh);
2388
+
2389
+    $doHide = ($hide) ? 'none' : '';
2390
+    $out = "<div id='{$id}' style='display:{$doHide};'>";
2391
+    $out .= "<table cellpadding='1' cellspacing='0' style='border:0px solid #ccc'>\n";
2392
+
2393
+    while($file = readdir($dh)) {
2394
+        if($file == '.' || $file == '..' || $file == 'CVS' || $file == '.cvsignore')
2395
+            continue;
2396
+
2397
+        if(is_dir($path.'/'.$file)) {
2398
+            $file = $path.'/'.$file;
2399
+            $newI = create_guid();
2400
+            $out .= "<tr><td valign='top'><a href='javascript:toggleNwFiles(\"{$newI}\");'>".SugarThemeRegistry::current()->getImage("Workflow", "", null, null, ".gif", $mod_strings['LBL_WORKFLOW'])."</a></td>\n";
2401
+            $out .= "<td valign='top'><b><a href='javascript:toggleNwFiles(\"{$newI}\");'>".basename($file)."</a></b></td></tr>";
2402
+            $out .= "<tr><td></td><td valign='top'>".testThis2($file, $newI, true)."</td></tr>";
2403
+        } else {
2404
+            $out .= "<tr><td valign='top'>&nbsp;</td>\n";
2405
+            $out .= "<td valign='top'>".basename($file)."</td></tr>";
2406
+        }
2407
+    }
2408 2408
 
2409
-	$out .= "</tr></table>";
2410
-	$out .= "</div>";
2409
+    $out .= "</tr></table>";
2410
+    $out .= "</div>";
2411 2411
 
2412
-	closedir($dh);
2413
-	return $out;
2412
+    closedir($dh);
2413
+    return $out;
2414 2414
 }
2415 2415
 
2416 2416
 
@@ -2418,66 +2418,66 @@  discard block
 block discarded – undo
2418 2418
 
2419 2419
 
2420 2420
 function testThis3(&$files, $id, $hide, $previousPath = '') {
2421
-	if(!is_array($files) || empty($files))
2422
-		return '';
2421
+    if(!is_array($files) || empty($files))
2422
+        return '';
2423 2423
 
2424
-	$out = '';
2424
+    $out = '';
2425 2425
 
2426 2426
     global $mod_strings;
2427
-	// expecting full path here
2428
-	foreach($files as $k => $file) {
2429
-		$file = str_replace(getcwd(), '', $file);
2430
-		$path = dirname($file);
2431
-		$fileName = basename($file);
2432
-
2433
-		if($fileName == 'CVS' || $fileName == '.cvsignore')
2434
-			continue;
2435
-
2436
-		if($path == $previousPath) { // same directory
2437
-			// new row for each file
2438
-			$out .= "<tr><td valign='top' align='left'>&nbsp;</td>";
2439
-			$out .= "<td valign='top' align='left'>{$fileName}</td></tr>";
2440
-		} else { // new directory
2441
-			$newI = $k;
2442
-			$out .= "<tr><td valign='top'><a href='javascript:toggleNwFiles(\"{$newI}\");'>".SugarThemeRegistry::current()->getImage("Workflow", "", null, null, ".gif", $mod_strings['LBL_WORKFLOW'])."</a></td>\n";
2443
-			$out .= "<td valign='top'><b><a href='javascript:toggleNwFiles(\"{$newI}\");'>".$fileName."</a></b></td></tr>";
2444
-			$recurse = testThis3($files, $newI, true, $previousPath);
2445
-			$out .= "<tr><td></td><td valign='top'>".$recurse."</td></tr>";
2446
-		}
2427
+    // expecting full path here
2428
+    foreach($files as $k => $file) {
2429
+        $file = str_replace(getcwd(), '', $file);
2430
+        $path = dirname($file);
2431
+        $fileName = basename($file);
2432
+
2433
+        if($fileName == 'CVS' || $fileName == '.cvsignore')
2434
+            continue;
2435
+
2436
+        if($path == $previousPath) { // same directory
2437
+            // new row for each file
2438
+            $out .= "<tr><td valign='top' align='left'>&nbsp;</td>";
2439
+            $out .= "<td valign='top' align='left'>{$fileName}</td></tr>";
2440
+        } else { // new directory
2441
+            $newI = $k;
2442
+            $out .= "<tr><td valign='top'><a href='javascript:toggleNwFiles(\"{$newI}\");'>".SugarThemeRegistry::current()->getImage("Workflow", "", null, null, ".gif", $mod_strings['LBL_WORKFLOW'])."</a></td>\n";
2443
+            $out .= "<td valign='top'><b><a href='javascript:toggleNwFiles(\"{$newI}\");'>".$fileName."</a></b></td></tr>";
2444
+            $recurse = testThis3($files, $newI, true, $previousPath);
2445
+            $out .= "<tr><td></td><td valign='top'>".$recurse."</td></tr>";
2446
+        }
2447 2447
 
2448
-		$previousPath = $path;
2449
-	}
2450
-	$display = ($hide) ? 'none' : '';
2451
-	$ret = <<<eoq
2448
+        $previousPath = $path;
2449
+    }
2450
+    $display = ($hide) ? 'none' : '';
2451
+    $ret = <<<eoq
2452 2452
 	<div id="{$id}" style="display:{$display}">
2453 2453
 	<table cellpadding='1' cellspacing='0' border='0' style='border:1px solid #ccc'>
2454 2454
 		{$out}
2455 2455
 	</table>
2456 2456
 	</div>
2457 2457
 eoq;
2458
-	return $ret;
2458
+    return $ret;
2459 2459
 }
2460 2460
 
2461 2461
 
2462 2462
 function testThis4($filePath, $fileNodes=array(), $fileName='') {
2463
-	$path = dirname($filePath);
2464
-	$file = basename($filePath);
2463
+    $path = dirname($filePath);
2464
+    $file = basename($filePath);
2465 2465
 
2466
-	$exFile = explode('/', $path);
2466
+    $exFile = explode('/', $path);
2467 2467
 
2468
-	foreach($exFile as $pathSegment) {
2469
-		if(is_array($fileNodes[$pathSegment])) { // path already processed
2468
+    foreach($exFile as $pathSegment) {
2469
+        if(is_array($fileNodes[$pathSegment])) { // path already processed
2470 2470
 
2471
-		} else { // newly found path
2472
-			$fileNodes[$pathSegment] = array();
2473
-		}
2471
+        } else { // newly found path
2472
+            $fileNodes[$pathSegment] = array();
2473
+        }
2474 2474
 
2475
-		if($fileName != '') {
2476
-			$fileNodes[$pathSegment][] = $fileName;
2477
-		}
2478
-	}
2475
+        if($fileName != '') {
2476
+            $fileNodes[$pathSegment][] = $fileName;
2477
+        }
2478
+    }
2479 2479
 
2480
-	return $fileNodes;
2480
+    return $fileNodes;
2481 2481
 }
2482 2482
 
2483 2483
 
@@ -2490,18 +2490,18 @@  discard block
 block discarded – undo
2490 2490
  * @return array files Array of files with absolute paths
2491 2491
  */
2492 2492
 function getFilesForPermsCheck() {
2493
-	global $sugar_config;
2494
-
2495
-	logThis('Got JSON call to find all files...');
2496
-	$filesNotWritable = array();
2497
-	$filesNWPerms = array();
2498
-
2499
-	// add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one)
2500
-	$skipDirs = array(
2501
-		$sugar_config['upload_dir'],
2502
-	);
2503
-	$files = uwFindAllFiles(".", array(), true, $skipDirs, true);
2504
-	return $files;
2493
+    global $sugar_config;
2494
+
2495
+    logThis('Got JSON call to find all files...');
2496
+    $filesNotWritable = array();
2497
+    $filesNWPerms = array();
2498
+
2499
+    // add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one)
2500
+    $skipDirs = array(
2501
+        $sugar_config['upload_dir'],
2502
+    );
2503
+    $files = uwFindAllFiles(".", array(), true, $skipDirs, true);
2504
+    return $files;
2505 2505
 }
2506 2506
 
2507 2507
 /**
@@ -2510,10 +2510,10 @@  discard block
 block discarded – undo
2510 2510
  * @return string result of check
2511 2511
  */
2512 2512
 function checkFiles($files, $echo=false) {
2513
-	global $mod_strings;
2514
-	$filesNotWritable = array();
2515
-	$i=0;
2516
-	$filesOut = "
2513
+    global $mod_strings;
2514
+    $filesNotWritable = array();
2515
+    $i=0;
2516
+    $filesOut = "
2517 2517
 		<a href='javascript:void(0); toggleNwFiles(\"filesNw\");'>{$mod_strings['LBL_UW_SHOW_NW_FILES']}</a>
2518 2518
 		<div id='filesNw' style='display:none;'>
2519 2519
 		<table cellpadding='3' cellspacing='0' border='0'>
@@ -2524,15 +2524,15 @@  discard block
 block discarded – undo
2524 2524
 			<th align='left'>{$mod_strings['LBL_UW_FILE_GROUP']}</th>
2525 2525
 		</tr>";
2526 2526
 
2527
-	$isWindows = is_windows();
2528
-	foreach($files as $file) {
2527
+    $isWindows = is_windows();
2528
+    foreach($files as $file) {
2529 2529
 
2530
-		if($isWindows) {
2531
-			if(!is_writable_windows($file)) {
2532
-				logThis('WINDOWS: File ['.$file.'] not readable - saving for display');
2533
-				// don't warn yet - we're going to use this to check against replacement files
2534
-	// aw: commented out; it's a hack to allow upgrade wizard to continue on windows... will fix later
2535
-				/*$filesNotWritable[$i] = $file;
2530
+        if($isWindows) {
2531
+            if(!is_writable_windows($file)) {
2532
+                logThis('WINDOWS: File ['.$file.'] not readable - saving for display');
2533
+                // don't warn yet - we're going to use this to check against replacement files
2534
+    // aw: commented out; it's a hack to allow upgrade wizard to continue on windows... will fix later
2535
+                /*$filesNotWritable[$i] = $file;
2536 2536
 				$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
2537 2537
 				$filesOut .= "<tr>".
2538 2538
 								"<td><span class='error'>{$file}</span></td>".
@@ -2540,57 +2540,57 @@  discard block
 block discarded – undo
2540 2540
 								"<td>".$mod_strings['ERR_UW_CANNOT_DETERMINE_USER']."</td>".
2541 2541
 								"<td>".$mod_strings['ERR_UW_CANNOT_DETERMINE_GROUP']."</td>".
2542 2542
 							  "</tr>";*/
2543
-			}
2544
-		} else {
2545
-			if(!is_writable($file)) {
2546
-				logThis('File ['.$file.'] not writable - saving for display');
2547
-				// don't warn yet - we're going to use this to check against replacement files
2548
-				$filesNotWritable[$i] = $file;
2549
-				$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
2550
-				$owner = posix_getpwuid(fileowner($file));
2551
-				$group = posix_getgrgid(filegroup($file));
2552
-				$filesOut .= "<tr>".
2553
-								"<td><span class='error'>{$file}</span></td>".
2554
-								"<td>{$filesNWPerms[$i]}</td>".
2555
-								"<td>".$owner['name']."</td>".
2556
-								"<td>".$group['name']."</td>".
2557
-							  "</tr>";
2558
-			}
2559
-		}
2560
-		$i++;
2561
-	}
2543
+            }
2544
+        } else {
2545
+            if(!is_writable($file)) {
2546
+                logThis('File ['.$file.'] not writable - saving for display');
2547
+                // don't warn yet - we're going to use this to check against replacement files
2548
+                $filesNotWritable[$i] = $file;
2549
+                $filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
2550
+                $owner = posix_getpwuid(fileowner($file));
2551
+                $group = posix_getgrgid(filegroup($file));
2552
+                $filesOut .= "<tr>".
2553
+                                "<td><span class='error'>{$file}</span></td>".
2554
+                                "<td>{$filesNWPerms[$i]}</td>".
2555
+                                "<td>".$owner['name']."</td>".
2556
+                                "<td>".$group['name']."</td>".
2557
+                                "</tr>";
2558
+            }
2559
+        }
2560
+        $i++;
2561
+    }
2562 2562
 
2563
-	$filesOut .= '</table></div>';
2564
-	// not a stop error
2565
-	$errors['files']['filesNotWritable'] = (count($filesNotWritable) > 0) ? true : false;
2566
-	if(count($filesNotWritable) < 1) {
2567
-		$filesOut = "{$mod_strings['LBL_UW_FILE_NO_ERRORS']}";
2568
-	}
2563
+    $filesOut .= '</table></div>';
2564
+    // not a stop error
2565
+    $errors['files']['filesNotWritable'] = (count($filesNotWritable) > 0) ? true : false;
2566
+    if(count($filesNotWritable) < 1) {
2567
+        $filesOut = "{$mod_strings['LBL_UW_FILE_NO_ERRORS']}";
2568
+    }
2569 2569
 
2570
-	return $filesOut;
2570
+    return $filesOut;
2571 2571
 }
2572 2572
 
2573 2573
 function deletePackageOnCancel(){
2574
-	global $mod_strings;
2575
-	global $sugar_config;
2576
-	list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
2577
-	logThis('running delete');
2574
+    global $mod_strings;
2575
+    global $sugar_config;
2576
+    list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
2577
+    logThis('running delete');
2578 2578
     if(!isset($_SESSION['install_file']) || ($_SESSION['install_file'] == "")) {
2579
-    	logThis('ERROR: trying to delete non-existent file: ['.$_REQUEST['install_file'].']');
2579
+        logThis('ERROR: trying to delete non-existent file: ['.$_REQUEST['install_file'].']');
2580 2580
         $error = $mod_strings['ERR_UW_NO_FILE_UPLOADED'];
2581 2581
     }
2582 2582
     // delete file in upgrades/patch
2583 2583
     $delete_me = "$base_upgrade_dir/patch/".basename(urldecode( $_REQUEST['install_file'] ));
2584 2584
     if(@unlink($delete_me)) {
2585
-    	//logThis('unlinking: '.$delete_me);
2585
+        //logThis('unlinking: '.$delete_me);
2586 2586
         $out = basename($delete_me).$mod_strings['LBL_UW_FILE_DELETED'];
2587 2587
     } else {
2588
-    	logThis('ERROR: could not delete ['.$delete_me.']');
2589
-		$error = $mod_strings['ERR_UW_FILE_NOT_DELETED'].$delete_me;
2588
+        logThis('ERROR: could not delete ['.$delete_me.']');
2589
+        $error = $mod_strings['ERR_UW_FILE_NOT_DELETED'].$delete_me;
2590 2590
     }
2591 2591
 
2592 2592
     if(!empty($error)) {
2593
-		$out = "<b><span class='error'>{$error}</span></b><br />";
2593
+        $out = "<b><span class='error'>{$error}</span></b><br />";
2594 2594
     }
2595 2595
 }
2596 2596
 
@@ -2609,465 +2609,465 @@  discard block
 block discarded – undo
2609 2609
 
2610 2610
 function parseAndExecuteSqlFile($sqlScript,$forStepQuery='',$resumeFromQuery='')
2611 2611
 {
2612
-	global $sugar_config;
2613
-	$alterTableSchema = '';
2614
-	$sqlErrors = array();
2615
-	if(!isset($_SESSION['sqlSkippedQueries'])){
2616
-		$_SESSION['sqlSkippedQueries'] = array();
2617
-	}
2618
-	$db = DBManagerFactory::getInstance();
2619
-	$disable_keys = ($db->dbType == "mysql"); // have to use old way for now for upgrades
2620
-	if(strpos($resumeFromQuery,",") != false){
2621
-		$resumeFromQuery = explode(",",$resumeFromQuery);
2622
-	}
2623
-	if(file_exists($sqlScript)) {
2624
-		$fp = fopen($sqlScript, 'r');
2625
-		$contents = stream_get_contents($fp);
2626
-		$anyScriptChanges =$contents;
2627
-		$resumeAfterFound = false;
2628
-		if(rewind($fp)) {
2629
-			$completeLine = '';
2630
-			$count = 0;
2631
-			while($line = fgets($fp)) {
2632
-				if(strpos($line, '--') === false) {
2633
-					$completeLine .= " ".trim($line);
2634
-					if(strpos($line, ';') !== false) {
2635
-						$query = '';
2636
-						$query = str_replace(';','',$completeLine);
2637
-						//if resume from query is not null then find out from where
2638
-						//it should start executing the query.
2639
-
2640
-						if($query != null && $resumeFromQuery != null){
2641
-							if(!$resumeAfterFound){
2642
-								if(strpos($query,",") != false){
2643
-									$queArray = explode(",",$query);
2644
-									for($i=0;$i<sizeof($resumeFromQuery);$i++){
2645
-										if(strcasecmp(trim($resumeFromQuery[$i]),trim($queArray[$i]))==0){
2646
-											$resumeAfterFound = true;
2647
-										} else {
2648
-											$resumeAfterFound = false;
2649
-											break;
2650
-										}
2651
-									}//for
2652
-
2653
-								}
2654
-								elseif(strcasecmp(trim($resumeFromQuery),trim($query))==0){
2655
-									$resumeAfterFound = true;
2656
-								}
2657
-							}
2658
-							if($resumeAfterFound){
2659
-								$count++;
2660
-							}
2661
-							// if $count=1 means it is just found so skip the query. Run the next one
2662
-							if($query != null && $resumeAfterFound && $count >1){
2663
-    							$tableName = getAlterTable($query);
2664
-								if($disable_keys)
2665
-								{
2666
-									handleExecuteSqlKeys($db, $tableName, true);
2667
-								}
2668
-								$db->query($query);
2669
-								if($db->checkError()){
2670
-									//put in the array to use later on
2671
-									$_SESSION['sqlSkippedQueries'][] = $query;
2672
-								}
2673
-								if($disable_keys)
2674
-								{
2675
-									handleExecuteSqlKeys($db, $tableName, false);
2676
-								}
2677
-								$progQuery[$forStepQuery]=$query;
2678
-								post_install_progress($progQuery,$action='set');
2679
-							}//if
2680
-						}
2681
-						elseif($query != null){
2682
-							$tableName = getAlterTable($query);
2683
-							if($disable_keys)
2684
-							{
2685
-								handleExecuteSqlKeys($db, $tableName, true);
2686
-							}
2687
-							$db->query($query);
2688
-							if($disable_keys)
2689
-							{
2690
-								handleExecuteSqlKeys($db, $tableName, false);
2691
-							}
2692
-							$progQuery[$forStepQuery]=$query;
2693
-							post_install_progress($progQuery,$action='set');
2694
-							if($db->checkError()){
2695
-								//put in the array to use later on
2696
-								$_SESSION['sqlSkippedQueries'][] = $query;
2697
-							}
2698
-						}
2699
-						$completeLine = '';
2700
-					}
2701
-				}
2702
-			}//while
2703
-		}
2704
-	}
2612
+    global $sugar_config;
2613
+    $alterTableSchema = '';
2614
+    $sqlErrors = array();
2615
+    if(!isset($_SESSION['sqlSkippedQueries'])){
2616
+        $_SESSION['sqlSkippedQueries'] = array();
2617
+    }
2618
+    $db = DBManagerFactory::getInstance();
2619
+    $disable_keys = ($db->dbType == "mysql"); // have to use old way for now for upgrades
2620
+    if(strpos($resumeFromQuery,",") != false){
2621
+        $resumeFromQuery = explode(",",$resumeFromQuery);
2622
+    }
2623
+    if(file_exists($sqlScript)) {
2624
+        $fp = fopen($sqlScript, 'r');
2625
+        $contents = stream_get_contents($fp);
2626
+        $anyScriptChanges =$contents;
2627
+        $resumeAfterFound = false;
2628
+        if(rewind($fp)) {
2629
+            $completeLine = '';
2630
+            $count = 0;
2631
+            while($line = fgets($fp)) {
2632
+                if(strpos($line, '--') === false) {
2633
+                    $completeLine .= " ".trim($line);
2634
+                    if(strpos($line, ';') !== false) {
2635
+                        $query = '';
2636
+                        $query = str_replace(';','',$completeLine);
2637
+                        //if resume from query is not null then find out from where
2638
+                        //it should start executing the query.
2639
+
2640
+                        if($query != null && $resumeFromQuery != null){
2641
+                            if(!$resumeAfterFound){
2642
+                                if(strpos($query,",") != false){
2643
+                                    $queArray = explode(",",$query);
2644
+                                    for($i=0;$i<sizeof($resumeFromQuery);$i++){
2645
+                                        if(strcasecmp(trim($resumeFromQuery[$i]),trim($queArray[$i]))==0){
2646
+                                            $resumeAfterFound = true;
2647
+                                        } else {
2648
+                                            $resumeAfterFound = false;
2649
+                                            break;
2650
+                                        }
2651
+                                    }//for
2652
+
2653
+                                }
2654
+                                elseif(strcasecmp(trim($resumeFromQuery),trim($query))==0){
2655
+                                    $resumeAfterFound = true;
2656
+                                }
2657
+                            }
2658
+                            if($resumeAfterFound){
2659
+                                $count++;
2660
+                            }
2661
+                            // if $count=1 means it is just found so skip the query. Run the next one
2662
+                            if($query != null && $resumeAfterFound && $count >1){
2663
+                                $tableName = getAlterTable($query);
2664
+                                if($disable_keys)
2665
+                                {
2666
+                                    handleExecuteSqlKeys($db, $tableName, true);
2667
+                                }
2668
+                                $db->query($query);
2669
+                                if($db->checkError()){
2670
+                                    //put in the array to use later on
2671
+                                    $_SESSION['sqlSkippedQueries'][] = $query;
2672
+                                }
2673
+                                if($disable_keys)
2674
+                                {
2675
+                                    handleExecuteSqlKeys($db, $tableName, false);
2676
+                                }
2677
+                                $progQuery[$forStepQuery]=$query;
2678
+                                post_install_progress($progQuery,$action='set');
2679
+                            }//if
2680
+                        }
2681
+                        elseif($query != null){
2682
+                            $tableName = getAlterTable($query);
2683
+                            if($disable_keys)
2684
+                            {
2685
+                                handleExecuteSqlKeys($db, $tableName, true);
2686
+                            }
2687
+                            $db->query($query);
2688
+                            if($disable_keys)
2689
+                            {
2690
+                                handleExecuteSqlKeys($db, $tableName, false);
2691
+                            }
2692
+                            $progQuery[$forStepQuery]=$query;
2693
+                            post_install_progress($progQuery,$action='set');
2694
+                            if($db->checkError()){
2695
+                                //put in the array to use later on
2696
+                                $_SESSION['sqlSkippedQueries'][] = $query;
2697
+                            }
2698
+                        }
2699
+                        $completeLine = '';
2700
+                    }
2701
+                }
2702
+            }//while
2703
+        }
2704
+    }
2705 2705
 }
2706 2706
 
2707 2707
 
2708 2708
 function getAlterTable($query){
2709
-	$query = strtolower($query);
2710
-	if (preg_match('/^\s*alter\s+table\s+/', $query)) {
2711
-		$sqlArray = explode(" ", $query);
2712
-		$key = array_search('table', $sqlArray);
2713
-		return $sqlArray[($key+1)];
2714
-	}else {
2715
-		return '';
2716
-	}
2709
+    $query = strtolower($query);
2710
+    if (preg_match('/^\s*alter\s+table\s+/', $query)) {
2711
+        $sqlArray = explode(" ", $query);
2712
+        $key = array_search('table', $sqlArray);
2713
+        return $sqlArray[($key+1)];
2714
+    }else {
2715
+        return '';
2716
+    }
2717 2717
 }
2718 2718
 
2719 2719
 function set_upgrade_vars(){
2720
-	logThis('setting session variables...');
2721
-	$upgrade_progress_dir = sugar_cached('upgrades/temp');
2722
-	if(!is_dir($upgrade_progress_dir)){
2723
-		mkdir_recursive($upgrade_progress_dir);
2724
-	}
2725
-	$upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2726
-	if(file_exists($upgrade_progress_file)){
2727
-		include($upgrade_progress_file);
2728
-	}
2729
-	else{
2730
-		fopen($upgrade_progress_file, 'w+');
2731
-	}
2732
-	if(!isset($upgrade_config) || $upgrade_config == null){
2733
-		$upgrade_config = array();
2734
-		$upgrade_config[1]['upgrade_vars']=array();
2735
-	}
2720
+    logThis('setting session variables...');
2721
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2722
+    if(!is_dir($upgrade_progress_dir)){
2723
+        mkdir_recursive($upgrade_progress_dir);
2724
+    }
2725
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2726
+    if(file_exists($upgrade_progress_file)){
2727
+        include($upgrade_progress_file);
2728
+    }
2729
+    else{
2730
+        fopen($upgrade_progress_file, 'w+');
2731
+    }
2732
+    if(!isset($upgrade_config) || $upgrade_config == null){
2733
+        $upgrade_config = array();
2734
+        $upgrade_config[1]['upgrade_vars']=array();
2735
+    }
2736 2736
     if(isset($upgrade_config[1]) && isset($upgrade_config[1]['upgrade_vars']) && !is_array($upgrade_config[1]['upgrade_vars'])){
2737
-    	$upgrade_config[1]['upgrade_vars'] = array();
2737
+        $upgrade_config[1]['upgrade_vars'] = array();
2738 2738
     }
2739 2739
 
2740
-	if(!isset($upgrade_vars) || $upgrade_vars == NULL){
2741
-		$upgrade_vars = array();
2742
-	}
2743
-	if(isset($_SESSION['unzip_dir']) && !empty($_SESSION['unzip_dir']) && file_exists($_SESSION['unzip_dir'])){
2744
-		$upgrade_vars['unzip_dir']=$_SESSION['unzip_dir'];
2745
-	}
2746
-	if(isset($_SESSION['install_file']) && !empty($_SESSION['install_file']) && file_exists($_SESSION['install_file'])){
2747
-		$upgrade_vars['install_file']=$_SESSION['install_file'];
2748
-	}
2749
-	if(isset($_SESSION['Upgraded451Wizard']) && !empty($_SESSION['Upgraded451Wizard'])){
2750
-		$upgrade_vars['Upgraded451Wizard']=$_SESSION['Upgraded451Wizard'];
2751
-	}
2752
-	if(isset($_SESSION['license_shown']) && !empty($_SESSION['license_shown'])){
2753
-		$upgrade_vars['license_shown']=$_SESSION['license_shown'];
2754
-	}
2755
-	if(isset($_SESSION['Initial_451to500_Step']) && !empty($_SESSION['Initial_451to500_Step'])){
2756
-		$upgrade_vars['Initial_451to500_Step']=$_SESSION['Initial_451to500_Step'];
2757
-	}
2758
-	if(isset($_SESSION['zip_from_dir']) && !empty($_SESSION['zip_from_dir'])){
2759
-		$upgrade_vars['zip_from_dir']=$_SESSION['zip_from_dir'];
2760
-	}
2761
-	//place into the upgrade_config array and rewrite config array only if new values are being inserted
2762
-	if(isset($upgrade_vars) && $upgrade_vars != null && sizeof($upgrade_vars) > 0){
2763
-		foreach($upgrade_vars as $key=>$val){
2764
-			if($key != null && $val != null){
2765
-				$upgrade_config[1]['upgrade_vars'][$key]=$upgrade_vars[$key];
2766
-			}
2767
-		}
2768
-		ksort($upgrade_config);
2769
-		if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
2770
-			$upgrade_progress_file)) {
2771
-		       //writing to the file
2772
-		}
2740
+    if(!isset($upgrade_vars) || $upgrade_vars == NULL){
2741
+        $upgrade_vars = array();
2742
+    }
2743
+    if(isset($_SESSION['unzip_dir']) && !empty($_SESSION['unzip_dir']) && file_exists($_SESSION['unzip_dir'])){
2744
+        $upgrade_vars['unzip_dir']=$_SESSION['unzip_dir'];
2745
+    }
2746
+    if(isset($_SESSION['install_file']) && !empty($_SESSION['install_file']) && file_exists($_SESSION['install_file'])){
2747
+        $upgrade_vars['install_file']=$_SESSION['install_file'];
2748
+    }
2749
+    if(isset($_SESSION['Upgraded451Wizard']) && !empty($_SESSION['Upgraded451Wizard'])){
2750
+        $upgrade_vars['Upgraded451Wizard']=$_SESSION['Upgraded451Wizard'];
2751
+    }
2752
+    if(isset($_SESSION['license_shown']) && !empty($_SESSION['license_shown'])){
2753
+        $upgrade_vars['license_shown']=$_SESSION['license_shown'];
2754
+    }
2755
+    if(isset($_SESSION['Initial_451to500_Step']) && !empty($_SESSION['Initial_451to500_Step'])){
2756
+        $upgrade_vars['Initial_451to500_Step']=$_SESSION['Initial_451to500_Step'];
2757
+    }
2758
+    if(isset($_SESSION['zip_from_dir']) && !empty($_SESSION['zip_from_dir'])){
2759
+        $upgrade_vars['zip_from_dir']=$_SESSION['zip_from_dir'];
2760
+    }
2761
+    //place into the upgrade_config array and rewrite config array only if new values are being inserted
2762
+    if(isset($upgrade_vars) && $upgrade_vars != null && sizeof($upgrade_vars) > 0){
2763
+        foreach($upgrade_vars as $key=>$val){
2764
+            if($key != null && $val != null){
2765
+                $upgrade_config[1]['upgrade_vars'][$key]=$upgrade_vars[$key];
2766
+            }
2767
+        }
2768
+        ksort($upgrade_config);
2769
+        if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
2770
+            $upgrade_progress_file)) {
2771
+                //writing to the file
2772
+        }
2773 2773
     }
2774 2774
 }
2775 2775
 
2776 2776
 function initialize_session_vars(){
2777
-  $upgrade_progress_dir = sugar_cached('upgrades/temp');
2778
-  $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2779
-  if(file_exists($upgrade_progress_file)){
2780
-  	include($upgrade_progress_file);
2781
-  	if(isset($upgrade_config) && $upgrade_config != null && is_array($upgrade_config) && sizeof($upgrade_config) >0){
2782
-	  	$currVarsArray=$upgrade_config[1]['upgrade_vars'];
2783
-	  	//print_r($currVarsArray);
2784
-	  	if(isset($currVarsArray) && $currVarsArray != null && is_array($currVarsArray) && sizeof($currVarsArray)>0){
2785
-	  		foreach($currVarsArray as $key=>$val){
2786
-	  			if($key != null && $val !=null){
2787
-		  			//set session variables
2788
-		  			$_SESSION[$key]=$val;
2789
-		  			//set varibales
2790
-					'$'.$key=$val;
2791
-	  			}
2792
-	  		}
2793
-	  	}
2794
-  	}
2795
-  }
2777
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2778
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2779
+    if(file_exists($upgrade_progress_file)){
2780
+        include($upgrade_progress_file);
2781
+        if(isset($upgrade_config) && $upgrade_config != null && is_array($upgrade_config) && sizeof($upgrade_config) >0){
2782
+            $currVarsArray=$upgrade_config[1]['upgrade_vars'];
2783
+            //print_r($currVarsArray);
2784
+            if(isset($currVarsArray) && $currVarsArray != null && is_array($currVarsArray) && sizeof($currVarsArray)>0){
2785
+                foreach($currVarsArray as $key=>$val){
2786
+                    if($key != null && $val !=null){
2787
+                        //set session variables
2788
+                        $_SESSION[$key]=$val;
2789
+                        //set varibales
2790
+                    '$'.$key=$val;
2791
+                    }
2792
+                }
2793
+            }
2794
+        }
2795
+    }
2796 2796
 }
2797 2797
 //track the upgrade progress on each step
2798 2798
 //track the upgrade progress on each step
2799 2799
 function set_upgrade_progress($currStep,$currState,$currStepSub='',$currStepSubState=''){
2800 2800
 
2801
-	$upgrade_progress_dir = sugar_cached('upgrades/temp');
2802
-	if(!is_dir($upgrade_progress_dir)){
2803
-		mkdir_recursive($upgrade_progress_dir);
2804
-	}
2805
-	$upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2806
-	if(file_exists($upgrade_progress_file)){
2807
-		include($upgrade_progress_file);
2808
-	}
2809
-	else{
2810
-		if(function_exists('sugar_fopen')){
2811
-			sugar_fopen($upgrade_progress_file, 'w+');
2812
-		}
2813
-		else{
2814
-			fopen($upgrade_progress_file, 'w+');
2815
-		}
2816
-	}
2817
-	if(!isset($upgrade_config) || $upgrade_config == null){
2818
-		$upgrade_config = array();
2819
-		$upgrade_config[1]['upgrade_vars']=array();
2820
-	}
2801
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2802
+    if(!is_dir($upgrade_progress_dir)){
2803
+        mkdir_recursive($upgrade_progress_dir);
2804
+    }
2805
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2806
+    if(file_exists($upgrade_progress_file)){
2807
+        include($upgrade_progress_file);
2808
+    }
2809
+    else{
2810
+        if(function_exists('sugar_fopen')){
2811
+            sugar_fopen($upgrade_progress_file, 'w+');
2812
+        }
2813
+        else{
2814
+            fopen($upgrade_progress_file, 'w+');
2815
+        }
2816
+    }
2817
+    if(!isset($upgrade_config) || $upgrade_config == null){
2818
+        $upgrade_config = array();
2819
+        $upgrade_config[1]['upgrade_vars']=array();
2820
+    }
2821 2821
     if(!is_array($upgrade_config[1]['upgrade_vars'])){
2822
-    	$upgrade_config[1]['upgrade_vars'] = array();
2823
-    }
2824
-   	if($currStep != null && $currState != null){
2825
-		if(sizeof($upgrade_config) > 0){
2826
-			if($currStepSub != null && $currStepSubState !=null){
2827
-				//check if new status to be set or update
2828
-				//get the latest in array. since it has sub components prepare an array
2829
-				if(!empty($upgrade_config[sizeof($upgrade_config)][$currStep]) && is_array($upgrade_config[sizeof($upgrade_config)][$currStep])){
2830
-					$latestStepSub = currSubStep($upgrade_config[sizeof($upgrade_config)][$currStep]);
2831
-					if($latestStepSub == $currStepSub){
2832
-						$upgrade_config[sizeof($upgrade_config)][$currStep][$latestStepSub]=$currStepSubState;
2833
-						$upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
2834
-					}
2835
-					else{
2836
-						$upgrade_config[sizeof($upgrade_config)][$currStep][$currStepSub]=$currStepSubState;
2837
-						$upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
2838
-					}
2839
-				}
2840
-				else{
2841
-					$currArray = array();
2842
-					$currArray[$currStep] = $currState;
2843
-					$currArray[$currStepSub] = $currStepSubState;
2844
-					$upgrade_config[sizeof($upgrade_config)+1][$currStep] = $currArray;
2845
-				}
2846
-			}
2847
-          else{
2848
-				//get the current upgrade progress
2849
-				$latestStep = get_upgrade_progress();
2850
-				//set the upgrade progress
2851
-				if($latestStep == $currStep){
2852
-					//update the current step with new progress status
2853
-					$upgrade_config[sizeof($upgrade_config)][$latestStep]=$currState;
2854
-				}
2855
-				else{
2856
-					//it's a new step
2857
-					$upgrade_config[sizeof($upgrade_config)+1][$currStep]=$currState;
2858
-				}
2859
-	            // now check if there elements within array substeps
2860
-          }
2861
-		}
2862
-		else{
2863
-			//set the upgrade progress  (just starting)
2864
-			$upgrade_config[sizeof($upgrade_config)+1][$currStep]= $currState;
2865
-		}
2822
+        $upgrade_config[1]['upgrade_vars'] = array();
2823
+    }
2824
+        if($currStep != null && $currState != null){
2825
+        if(sizeof($upgrade_config) > 0){
2826
+            if($currStepSub != null && $currStepSubState !=null){
2827
+                //check if new status to be set or update
2828
+                //get the latest in array. since it has sub components prepare an array
2829
+                if(!empty($upgrade_config[sizeof($upgrade_config)][$currStep]) && is_array($upgrade_config[sizeof($upgrade_config)][$currStep])){
2830
+                    $latestStepSub = currSubStep($upgrade_config[sizeof($upgrade_config)][$currStep]);
2831
+                    if($latestStepSub == $currStepSub){
2832
+                        $upgrade_config[sizeof($upgrade_config)][$currStep][$latestStepSub]=$currStepSubState;
2833
+                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
2834
+                    }
2835
+                    else{
2836
+                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStepSub]=$currStepSubState;
2837
+                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
2838
+                    }
2839
+                }
2840
+                else{
2841
+                    $currArray = array();
2842
+                    $currArray[$currStep] = $currState;
2843
+                    $currArray[$currStepSub] = $currStepSubState;
2844
+                    $upgrade_config[sizeof($upgrade_config)+1][$currStep] = $currArray;
2845
+                }
2846
+            }
2847
+            else{
2848
+                //get the current upgrade progress
2849
+                $latestStep = get_upgrade_progress();
2850
+                //set the upgrade progress
2851
+                if($latestStep == $currStep){
2852
+                    //update the current step with new progress status
2853
+                    $upgrade_config[sizeof($upgrade_config)][$latestStep]=$currState;
2854
+                }
2855
+                else{
2856
+                    //it's a new step
2857
+                    $upgrade_config[sizeof($upgrade_config)+1][$currStep]=$currState;
2858
+                }
2859
+                // now check if there elements within array substeps
2860
+            }
2861
+        }
2862
+        else{
2863
+            //set the upgrade progress  (just starting)
2864
+            $upgrade_config[sizeof($upgrade_config)+1][$currStep]= $currState;
2865
+        }
2866 2866
 
2867
-		if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
2868
-		$upgrade_progress_file)) {
2869
-	       //writing to the file
2870
-		}
2867
+        if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
2868
+        $upgrade_progress_file)) {
2869
+            //writing to the file
2870
+        }
2871 2871
 
2872
-   	}
2872
+        }
2873 2873
 }
2874 2874
 
2875 2875
 function get_upgrade_progress(){
2876
-	$upgrade_progress_dir = sugar_cached('upgrades/temp');
2877
-	$upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2878
-	$currState = '';
2879
-
2880
-	if(file_exists($upgrade_progress_file)){
2881
-		include($upgrade_progress_file);
2882
-		if(!isset($upgrade_config) || $upgrade_config == null){
2883
-			$upgrade_config = array();
2884
-		}
2885
-		if($upgrade_config != null && sizeof($upgrade_config) >1){
2886
-			$currArr = $upgrade_config[sizeof($upgrade_config)];
2887
-			if(is_array($currArr)){
2888
-			   foreach($currArr as $key=>$val){
2889
-					$currState = $key;
2890
-				}
2891
-			}
2892
-		}
2893
-	}
2894
-	return $currState;
2876
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2877
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2878
+    $currState = '';
2879
+
2880
+    if(file_exists($upgrade_progress_file)){
2881
+        include($upgrade_progress_file);
2882
+        if(!isset($upgrade_config) || $upgrade_config == null){
2883
+            $upgrade_config = array();
2884
+        }
2885
+        if($upgrade_config != null && sizeof($upgrade_config) >1){
2886
+            $currArr = $upgrade_config[sizeof($upgrade_config)];
2887
+            if(is_array($currArr)){
2888
+                foreach($currArr as $key=>$val){
2889
+                    $currState = $key;
2890
+                }
2891
+            }
2892
+        }
2893
+    }
2894
+    return $currState;
2895 2895
 }
2896 2896
 function currSubStep($currStep){
2897
-	$currSubStep = '';
2898
-	if(is_array($currStep)){
2899
-       foreach($currStep as $key=>$val){
2900
-		    if($key != null){
2901
-			$currState = $key;
2902
-		  	}
2903
-	   }
2904
-	}
2905
-	return $currState;
2897
+    $currSubStep = '';
2898
+    if(is_array($currStep)){
2899
+        foreach($currStep as $key=>$val){
2900
+            if($key != null){
2901
+            $currState = $key;
2902
+                }
2903
+        }
2904
+    }
2905
+    return $currState;
2906 2906
 }
2907 2907
 function currUpgradeState($currState){
2908
-	$currState = '';
2909
-	if(is_array($currState)){
2910
-       foreach($currState as $key=>$val){
2911
-			if(is_array($val)){
2912
-			  	foreach($val as $k=>$v){
2913
-			  		if($k != null){
2914
-						$currState = $k;
2915
-			  		}
2916
-			  	}
2917
-			}
2918
-			else{
2919
-				$currState = $key;
2920
-			}
2921
-		}
2922
-	}
2923
-	return $currState;
2908
+    $currState = '';
2909
+    if(is_array($currState)){
2910
+        foreach($currState as $key=>$val){
2911
+            if(is_array($val)){
2912
+                    foreach($val as $k=>$v){
2913
+                        if($k != null){
2914
+                        $currState = $k;
2915
+                        }
2916
+                    }
2917
+            }
2918
+            else{
2919
+                $currState = $key;
2920
+            }
2921
+        }
2922
+    }
2923
+    return $currState;
2924 2924
 }
2925 2925
 
2926 2926
 function didThisStepRunBefore($step,$SubStep=''){
2927
-	if($step == null) return;
2928
-	$upgrade_progress_dir = sugar_cached('upgrades/temp');
2929
-	$upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2930
-	$currState = '';
2931
-	$stepRan = false;
2932
-	if(file_exists($upgrade_progress_file)){
2933
-		include($upgrade_progress_file);
2934
-		if(isset($upgrade_config) && $upgrade_config != null && is_array($upgrade_config) && sizeof($upgrade_config) >0){
2935
-			for($i=1;$i<=sizeof($upgrade_config);$i++){
2936
-			  if(is_array($upgrade_config[$i])){
2937
-					foreach($upgrade_config[$i] as $key=>$val){
2938
-						if($key==$step){
2939
-							if(is_array($upgrade_config[$i][$step])){
2940
-								//now process
2941
-								foreach ($upgrade_config[$i][$step] as $k=>$v){
2942
-									if(is_array($v)){
2943
-										foreach($v as $k1=>$v1){
2944
-											if($SubStep != null){
2945
-												if($SubStep ==$k1 && $v1=='done'){
2946
-													$stepRan = true;
2947
-													break;
2948
-												}
2949
-											}
2950
-										}//foreach
2951
-									}
2952
-									elseif($SubStep !=null){
2953
-										if($SubStep==$k && $v=='done'){
2954
-											$stepRan = true;
2955
-											break;
2956
-										}
2957
-									}
2958
-									elseif($step==$k && $v=='done'){
2959
-										$stepRan = true;
2960
-										break;
2961
-									}
2962
-								}//foreach
2963
-							}
2964
-							elseif($val=='done'){
2965
-								$stepRan = true;
2966
-							}
2967
-						}
2968
-					}//foreach
2969
-				}
2970
-		 	}//for
2971
-	   	}
2972
-	}
2973
-	return $stepRan;
2927
+    if($step == null) return;
2928
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2929
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2930
+    $currState = '';
2931
+    $stepRan = false;
2932
+    if(file_exists($upgrade_progress_file)){
2933
+        include($upgrade_progress_file);
2934
+        if(isset($upgrade_config) && $upgrade_config != null && is_array($upgrade_config) && sizeof($upgrade_config) >0){
2935
+            for($i=1;$i<=sizeof($upgrade_config);$i++){
2936
+                if(is_array($upgrade_config[$i])){
2937
+                    foreach($upgrade_config[$i] as $key=>$val){
2938
+                        if($key==$step){
2939
+                            if(is_array($upgrade_config[$i][$step])){
2940
+                                //now process
2941
+                                foreach ($upgrade_config[$i][$step] as $k=>$v){
2942
+                                    if(is_array($v)){
2943
+                                        foreach($v as $k1=>$v1){
2944
+                                            if($SubStep != null){
2945
+                                                if($SubStep ==$k1 && $v1=='done'){
2946
+                                                    $stepRan = true;
2947
+                                                    break;
2948
+                                                }
2949
+                                            }
2950
+                                        }//foreach
2951
+                                    }
2952
+                                    elseif($SubStep !=null){
2953
+                                        if($SubStep==$k && $v=='done'){
2954
+                                            $stepRan = true;
2955
+                                            break;
2956
+                                        }
2957
+                                    }
2958
+                                    elseif($step==$k && $v=='done'){
2959
+                                        $stepRan = true;
2960
+                                        break;
2961
+                                    }
2962
+                                }//foreach
2963
+                            }
2964
+                            elseif($val=='done'){
2965
+                                $stepRan = true;
2966
+                            }
2967
+                        }
2968
+                    }//foreach
2969
+                }
2970
+                }//for
2971
+            }
2972
+    }
2973
+    return $stepRan;
2974 2974
 }
2975 2975
 
2976 2976
 
2977 2977
 
2978 2978
 //get and set post install status
2979 2979
 function post_install_progress($progArray='',$action=''){
2980
-	$upgrade_progress_dir = sugar_cached('upgrades/temp');
2981
-	$upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2980
+    $upgrade_progress_dir = sugar_cached('upgrades/temp');
2981
+    $upgrade_progress_file = $upgrade_progress_dir.'/upgrade_progress.php';
2982 2982
     if($action=='' || $action=='get'){
2983
-		//get the state of post install
2983
+        //get the state of post install
2984 2984
         $currProg = array();
2985
-		if(file_exists($upgrade_progress_file)){
2986
-			include($upgrade_progress_file);
2987
-			if(is_array($upgrade_config[sizeof($upgrade_config)]['commit']['post_install']) && sizeof($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'])>0){
2988
-				foreach($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'] as $k=>$v){
2989
-					$currProg[$k]=$v;
2990
-				}
2991
-			}
2992
-		}
2993
-		return $currProg;
2994
-	}
2995
-	elseif($action=='set'){
2996
-		if(!is_dir($upgrade_progress_dir)){
2997
-			mkdir($upgrade_progress_dir);
2998
-		}
2999
-		if(file_exists($upgrade_progress_file)){
3000
-			include($upgrade_progress_file);
3001
-		}
3002
-		else{
3003
-			fopen($upgrade_progress_file, 'w+');
3004
-		}
3005
-		if(!is_array($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'])){
3006
-			$upgrade_config[sizeof($upgrade_config)]['commit']['post_install']=array();
3007
-			$upgrade_config[sizeof($upgrade_config)]['commit']['post_install']['post_install'] = 'in_progress';
3008
-		}
3009
-		if($progArray != null && is_array($progArray)){
3010
-			foreach($progArray as $key=>$val){
3011
-				$upgrade_config[sizeof($upgrade_config)]['commit']['post_install'][$key]=$val;
3012
-			}
3013
-		}
3014
-		if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
3015
-		$upgrade_progress_file)) {
3016
-	       //writing to the file
3017
-		}
3018
-	}
2985
+        if(file_exists($upgrade_progress_file)){
2986
+            include($upgrade_progress_file);
2987
+            if(is_array($upgrade_config[sizeof($upgrade_config)]['commit']['post_install']) && sizeof($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'])>0){
2988
+                foreach($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'] as $k=>$v){
2989
+                    $currProg[$k]=$v;
2990
+                }
2991
+            }
2992
+        }
2993
+        return $currProg;
2994
+    }
2995
+    elseif($action=='set'){
2996
+        if(!is_dir($upgrade_progress_dir)){
2997
+            mkdir($upgrade_progress_dir);
2998
+        }
2999
+        if(file_exists($upgrade_progress_file)){
3000
+            include($upgrade_progress_file);
3001
+        }
3002
+        else{
3003
+            fopen($upgrade_progress_file, 'w+');
3004
+        }
3005
+        if(!is_array($upgrade_config[sizeof($upgrade_config)]['commit']['post_install'])){
3006
+            $upgrade_config[sizeof($upgrade_config)]['commit']['post_install']=array();
3007
+            $upgrade_config[sizeof($upgrade_config)]['commit']['post_install']['post_install'] = 'in_progress';
3008
+        }
3009
+        if($progArray != null && is_array($progArray)){
3010
+            foreach($progArray as $key=>$val){
3011
+                $upgrade_config[sizeof($upgrade_config)]['commit']['post_install'][$key]=$val;
3012
+            }
3013
+        }
3014
+        if(is_writable($upgrade_progress_file) && write_array_to_file( "upgrade_config", $upgrade_config,
3015
+        $upgrade_progress_file)) {
3016
+            //writing to the file
3017
+        }
3018
+    }
3019 3019
 }
3020 3020
 
3021 3021
 function repairDBForUpgrade($execute=false,$path=''){
3022 3022
 
3023
-	global $current_user, $beanFiles;
3024
-	global $dictionary;
3025
-	set_time_limit(3600);
3023
+    global $current_user, $beanFiles;
3024
+    global $dictionary;
3025
+    set_time_limit(3600);
3026 3026
 
3027
-	$db = &DBManagerFactory::getInstance();
3028
-	$sql = '';
3029
-	VardefManager::clearVardef();
3030
-	require_once('include/ListView/ListView.php');
3031
-	foreach ($beanFiles as $bean => $file) {
3032
-		require_once ($file);
3033
-		$focus = new $bean ();
3034
-		$sql .= $db->repairTable($focus, $execute);
3027
+    $db = &DBManagerFactory::getInstance();
3028
+    $sql = '';
3029
+    VardefManager::clearVardef();
3030
+    require_once('include/ListView/ListView.php');
3031
+    foreach ($beanFiles as $bean => $file) {
3032
+        require_once ($file);
3033
+        $focus = new $bean ();
3034
+        $sql .= $db->repairTable($focus, $execute);
3035 3035
 
3036
-	}
3037
-	//echo $sql;
3038
-	$olddictionary = $dictionary;
3039
-	unset ($dictionary);
3040
-	include ('modules/TableDictionary.php');
3041
-	foreach ($dictionary as $meta) {
3042
-		$tablename = $meta['table'];
3043
-		$fielddefs = $meta['fields'];
3044
-		$indices = $meta['indices'];
3045
-		$sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute);
3046
-	}
3047
-	 $qry_str = "";
3048
-	  foreach (explode("\n", $sql) as $line) {
3049
-		  if (!empty ($line) && substr($line, -2) != "*/") {
3050
-		  	$line .= ";";
3051
-		  }
3052
-	  	  $qry_str .= $line . "\n";
3053
-	   }
3054
-	  $sql = str_replace(
3055
-	  array(
3056
-	  	"\n",
3057
-		'&#039;',
3058
-	   ),
3059
-	  array(
3060
-	  	'',
3061
-		"'",
3062
-	  ),
3063
-	  preg_replace('#(/\*.+?\*/\n*)#', '', $qry_str)
3064
-	  );
3065
-	 logThis("*******START EXECUTING DB UPGRADE QUERIES***************",$path);
3066
-	 	logThis($sql,$path);
3067
-	 logThis("*******END EXECUTING DB UPGRADE QUERIES****************",$path);
3068
-	 if(!$execute){
3069
-	 	return $sql;
3070
-	 }
3036
+    }
3037
+    //echo $sql;
3038
+    $olddictionary = $dictionary;
3039
+    unset ($dictionary);
3040
+    include ('modules/TableDictionary.php');
3041
+    foreach ($dictionary as $meta) {
3042
+        $tablename = $meta['table'];
3043
+        $fielddefs = $meta['fields'];
3044
+        $indices = $meta['indices'];
3045
+        $sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute);
3046
+    }
3047
+        $qry_str = "";
3048
+        foreach (explode("\n", $sql) as $line) {
3049
+            if (!empty ($line) && substr($line, -2) != "*/") {
3050
+                $line .= ";";
3051
+            }
3052
+            $qry_str .= $line . "\n";
3053
+        }
3054
+        $sql = str_replace(
3055
+        array(
3056
+            "\n",
3057
+        '&#039;',
3058
+        ),
3059
+        array(
3060
+            '',
3061
+        "'",
3062
+        ),
3063
+        preg_replace('#(/\*.+?\*/\n*)#', '', $qry_str)
3064
+        );
3065
+        logThis("*******START EXECUTING DB UPGRADE QUERIES***************",$path);
3066
+            logThis($sql,$path);
3067
+        logThis("*******END EXECUTING DB UPGRADE QUERIES****************",$path);
3068
+        if(!$execute){
3069
+            return $sql;
3070
+        }
3071 3071
 }
3072 3072
 
3073 3073
 
@@ -3105,9 +3105,9 @@  discard block
 block discarded – undo
3105 3105
         $localization->createInvalidLocaleNameFormatUpgradeNotice();
3106 3106
     }
3107 3107
 
3108
-   	$db = &DBManagerFactory::getInstance();
3108
+        $db = &DBManagerFactory::getInstance();
3109 3109
     $result = $db->query("SELECT id FROM users where deleted = '0'");
3110
-   	while($row = $db->fetchByAssoc($result))
3110
+        while($row = $db->fetchByAssoc($result))
3111 3111
     {
3112 3112
         $current_user = new User();
3113 3113
         $current_user->retrieve($row['id']);
@@ -3123,9 +3123,9 @@  discard block
 block discarded – undo
3123 3123
 
3124 3124
         $changed = false;
3125 3125
         if(!$current_user->getPreference('calendar_publish_key')) {
3126
-        	// set publish key if not set already
3127
-        	$current_user->setPreference('calendar_publish_key', create_guid());
3128
-        	$changed = true;
3126
+            // set publish key if not set already
3127
+            $current_user->setPreference('calendar_publish_key', create_guid());
3128
+            $changed = true;
3129 3129
         }
3130 3130
 
3131 3131
 
@@ -3135,7 +3135,7 @@  discard block
 block discarded – undo
3135 3135
             $current_user->savePreferencesToDB();
3136 3136
         }
3137 3137
 
3138
-	} //while
3138
+    } //while
3139 3139
 }
3140 3140
 
3141 3141
 
@@ -3173,75 +3173,75 @@  discard block
 block discarded – undo
3173 3173
 function add_custom_modules_favorites_search(){
3174 3174
     $module_directories = scandir('modules');
3175 3175
 
3176
-	foreach($module_directories as $module_dir){
3177
-		if($module_dir == '.' || $module_dir == '..' || !is_dir("modules/{$module_dir}")){
3178
-			continue;
3179
-		}
3176
+    foreach($module_directories as $module_dir){
3177
+        if($module_dir == '.' || $module_dir == '..' || !is_dir("modules/{$module_dir}")){
3178
+            continue;
3179
+        }
3180
+
3181
+        $matches = array();
3182
+        preg_match('/^[a-z0-9]{1,5}_[a-z0-9_]+$/i' , $module_dir, $matches);
3183
+
3184
+        // Make sure the module was created by module builder
3185
+        if(empty($matches)){
3186
+            continue;
3187
+        }
3180 3188
 
3181
-		$matches = array();
3182
-		preg_match('/^[a-z0-9]{1,5}_[a-z0-9_]+$/i' , $module_dir, $matches);
3189
+        $full_module_dir = "modules/{$module_dir}/";
3190
+        $read_searchdefs_from = "{$full_module_dir}/metadata/searchdefs.php";
3191
+        $read_SearchFields_from = "{$full_module_dir}/metadata/SearchFields.php";
3192
+        $read_custom_SearchFields_from = "custom/{$full_module_dir}/metadata/SearchFields.php";
3183 3193
 
3184
-		// Make sure the module was created by module builder
3185
-		if(empty($matches)){
3186
-			continue;
3187
-		}
3194
+        // Studio can possibly override this file, so we check for a custom version of it
3195
+        if(file_exists("custom/{$full_module_dir}/metadata/searchdefs.php")){
3196
+            $read_searchdefs_from = "custom/{$full_module_dir}/metadata/searchdefs.php";
3197
+        }
3188 3198
 
3189
-		$full_module_dir = "modules/{$module_dir}/";
3190
-		$read_searchdefs_from = "{$full_module_dir}/metadata/searchdefs.php";
3191
-		$read_SearchFields_from = "{$full_module_dir}/metadata/SearchFields.php";
3192
-		$read_custom_SearchFields_from = "custom/{$full_module_dir}/metadata/SearchFields.php";
3199
+        if(file_exists($read_searchdefs_from) && file_exists($read_SearchFields_from)){
3200
+            $found_sf1 = false;
3201
+            $found_sf2 = false;
3202
+            require($read_searchdefs_from);
3203
+            foreach($searchdefs[$module_dir]['layout']['basic_search'] as $sf_array){
3204
+                if(isset($sf_array['name']) && $sf_array['name'] == 'favorites_only'){
3205
+                    $found_sf1 = true;
3206
+                }
3207
+            }
3193 3208
 
3194
-		// Studio can possibly override this file, so we check for a custom version of it
3195
-		if(file_exists("custom/{$full_module_dir}/metadata/searchdefs.php")){
3196
-			$read_searchdefs_from = "custom/{$full_module_dir}/metadata/searchdefs.php";
3197
-		}
3209
+            require($read_SearchFields_from);
3210
+            if(isset($searchFields[$module_dir]['favorites_only'])){
3211
+                $found_sf2 = true;
3212
+            }
3198 3213
 
3199
-		if(file_exists($read_searchdefs_from) && file_exists($read_SearchFields_from)){
3200
-			$found_sf1 = false;
3201
-			$found_sf2 = false;
3202
-			require($read_searchdefs_from);
3203
-			foreach($searchdefs[$module_dir]['layout']['basic_search'] as $sf_array){
3204
-				if(isset($sf_array['name']) && $sf_array['name'] == 'favorites_only'){
3205
-					$found_sf1 = true;
3206
-				}
3207
-			}
3208
-
3209
-			require($read_SearchFields_from);
3210
-			if(isset($searchFields[$module_dir]['favorites_only'])){
3211
-				$found_sf2 = true;
3212
-			}
3213
-
3214
-			if(!$found_sf1 && !$found_sf2){
3215
-				$searchdefs[$module_dir]['layout']['basic_search']['favorites_only'] = array('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',);
3216
-				$searchdefs[$module_dir]['layout']['advanced_search']['favorites_only'] = array('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',);
3217
-				$searchFields[$module_dir]['favorites_only'] = array(
3218
-					'query_type'=>'format',
3219
-					'operator' => 'subquery',
3220
-					'subquery' => 'SELECT sugarfavorites.record_id FROM sugarfavorites
3214
+            if(!$found_sf1 && !$found_sf2){
3215
+                $searchdefs[$module_dir]['layout']['basic_search']['favorites_only'] = array('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',);
3216
+                $searchdefs[$module_dir]['layout']['advanced_search']['favorites_only'] = array('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',);
3217
+                $searchFields[$module_dir]['favorites_only'] = array(
3218
+                    'query_type'=>'format',
3219
+                    'operator' => 'subquery',
3220
+                    'subquery' => 'SELECT sugarfavorites.record_id FROM sugarfavorites
3221 3221
 								WHERE sugarfavorites.deleted=0
3222 3222
 									and sugarfavorites.module = \''.$module_dir.'\'
3223 3223
 									and sugarfavorites.assigned_user_id = \'{0}\'',
3224
-					'db_field'=>array('id')
3225
-				);
3226
-
3227
-				if(!is_dir("custom/{$full_module_dir}/metadata")){
3228
-					mkdir_recursive("custom/{$full_module_dir}/metadata");
3229
-				}
3230
-				$success_sf1 = write_array_to_file('searchdefs', $searchdefs, "custom/{$full_module_dir}/metadata/searchdefs.php");
3231
-				$success_sf2 = write_array_to_file('searchFields', $searchFields, "{$full_module_dir}/metadata/SearchFields.php");
3232
-
3233
-				if(!$success_sf1){
3234
-					logThis("add_custom_modules_favorites_search failed for searchdefs.php for {$module_dir}");
3235
-				}
3236
-				if(!$success_sf2){
3237
-					logThis("add_custom_modules_favorites_search failed for SearchFields.php for {$module_dir}");
3238
-				}
3239
-				if($success_sf1 && $success_sf2){
3240
-					logThis("add_custom_modules_favorites_search successfully updated searchdefs and searchFields for {$module_dir}");
3241
-				}
3242
-			}
3243
-		}
3244
-	}
3224
+                    'db_field'=>array('id')
3225
+                );
3226
+
3227
+                if(!is_dir("custom/{$full_module_dir}/metadata")){
3228
+                    mkdir_recursive("custom/{$full_module_dir}/metadata");
3229
+                }
3230
+                $success_sf1 = write_array_to_file('searchdefs', $searchdefs, "custom/{$full_module_dir}/metadata/searchdefs.php");
3231
+                $success_sf2 = write_array_to_file('searchFields', $searchFields, "{$full_module_dir}/metadata/SearchFields.php");
3232
+
3233
+                if(!$success_sf1){
3234
+                    logThis("add_custom_modules_favorites_search failed for searchdefs.php for {$module_dir}");
3235
+                }
3236
+                if(!$success_sf2){
3237
+                    logThis("add_custom_modules_favorites_search failed for SearchFields.php for {$module_dir}");
3238
+                }
3239
+                if($success_sf1 && $success_sf2){
3240
+                    logThis("add_custom_modules_favorites_search successfully updated searchdefs and searchFields for {$module_dir}");
3241
+                }
3242
+            }
3243
+        }
3244
+    }
3245 3245
 }
3246 3246
 
3247 3247
 
@@ -3256,36 +3256,36 @@  discard block
 block discarded – undo
3256 3256
  */
3257 3257
 function upgradeModulesForTeamsets($filter=array()) {
3258 3258
     require('include/modules.php');
3259
-	foreach($beanList as $moduleName=>$beanName) {
3260
-		    if(!empty($filter) && array_search($moduleName, $filter) === false) {
3261
-		       continue;
3262
-		    }
3263
-	        if($moduleName == 'TeamMemberships' || $moduleName == 'ForecastOpportunities'){
3259
+    foreach($beanList as $moduleName=>$beanName) {
3260
+            if(!empty($filter) && array_search($moduleName, $filter) === false) {
3261
+                continue;
3262
+            }
3263
+            if($moduleName == 'TeamMemberships' || $moduleName == 'ForecastOpportunities'){
3264
+                continue;
3265
+            }
3266
+            $bean = loadBean($moduleName);
3267
+            if(empty($bean) ||
3268
+               empty($bean->table_name)) {
3264 3269
                 continue;
3265 3270
             }
3266
-			$bean = loadBean($moduleName);
3267
-			if(empty($bean) ||
3268
-			   empty($bean->table_name)) {
3269
-			   continue;
3270
-			}
3271 3271
 
3272
-			$FieldArray = $GLOBALS['db']->helper->get_columns($bean->table_name);
3273
-			if(!isset($FieldArray['team_id'])) {
3274
-			   continue;
3275
-			}
3272
+            $FieldArray = $GLOBALS['db']->helper->get_columns($bean->table_name);
3273
+            if(!isset($FieldArray['team_id'])) {
3274
+                continue;
3275
+            }
3276 3276
 
3277
-			upgradeTeamColumn($bean, 'team_id');
3277
+            upgradeTeamColumn($bean, 'team_id');
3278 3278
 
3279
-	} //foreach
3279
+    } //foreach
3280 3280
 
3281 3281
     //Upgrade users table
3282
-	$bean = loadBean('Users');
3283
-   	upgradeTeamColumn($bean, 'default_team');
3284
-	$result = $GLOBALS['db']->query("SELECT id FROM teams where deleted=0");
3285
-	while($row = $GLOBALS['db']->fetchByAssoc($result)) {
3286
-	      $teamset = new TeamSet();
3287
-	      $teamset->addTeams($row['id']);
3288
-	}
3282
+    $bean = loadBean('Users');
3283
+        upgradeTeamColumn($bean, 'default_team');
3284
+    $result = $GLOBALS['db']->query("SELECT id FROM teams where deleted=0");
3285
+    while($row = $GLOBALS['db']->fetchByAssoc($result)) {
3286
+            $teamset = new TeamSet();
3287
+            $teamset->addTeams($row['id']);
3288
+    }
3289 3289
 }
3290 3290
 
3291 3291
 
@@ -3298,87 +3298,87 @@  discard block
 block discarded – undo
3298 3298
  * @param $column_name The name of the column containing the default team_set_id value
3299 3299
  */
3300 3300
 function upgradeTeamColumn($bean, $column_name) {
3301
-	//first let's check to ensure that the team_set_id field is defined, if not it could be the case that this is an older
3302
-	//module that does not use the SugarObjects
3303
-	if(empty($bean->field_defs['team_set_id']) && $bean->module_dir != 'Trackers'){
3304
-
3305
-		//at this point we could assume that since we have a team_id defined and not a team_set_id that we need to
3306
-		//add that field and the corresponding relationships
3307
-		$object = $bean->object_name;
3308
-		$module = $bean->module_dir;
3309
-		$object_name = $object;
3310
-		$_object_name = strtolower($object_name);
3311
-
3312
-		if(!empty($GLOBALS['dictionary'][$object]['table'])){
3313
-			$table_name = $GLOBALS['dictionary'][$object]['table'];
3314
-		}else{
3315
-			$table_name = strtolower($module);
3316
-		}
3301
+    //first let's check to ensure that the team_set_id field is defined, if not it could be the case that this is an older
3302
+    //module that does not use the SugarObjects
3303
+    if(empty($bean->field_defs['team_set_id']) && $bean->module_dir != 'Trackers'){
3304
+
3305
+        //at this point we could assume that since we have a team_id defined and not a team_set_id that we need to
3306
+        //add that field and the corresponding relationships
3307
+        $object = $bean->object_name;
3308
+        $module = $bean->module_dir;
3309
+        $object_name = $object;
3310
+        $_object_name = strtolower($object_name);
3311
+
3312
+        if(!empty($GLOBALS['dictionary'][$object]['table'])){
3313
+            $table_name = $GLOBALS['dictionary'][$object]['table'];
3314
+        }else{
3315
+            $table_name = strtolower($module);
3316
+        }
3317 3317
 
3318
-		$path = 'include/SugarObjects/implements/team_security/vardefs.php';
3319
-		require($path);
3320
-		//go through each entry in the vardefs from team_security and unset anything that is already set in the core module
3321
-		//this will ensure we have the proper ordering.
3322
-		$fieldDiff = array_diff_assoc($vardefs['fields'], $GLOBALS['dictionary'][$bean->object_name]['fields']);
3323
-
3324
-		$file = 'custom/Extension/modules/' . $bean->module_dir. '/Ext/Vardefs/teams.php';
3325
-		$contents = "<?php\n";
3326
-		if(!empty($fieldDiff)){
3327
-			foreach($fieldDiff as $key => $val){
3328
-				$contents .= "\n\$GLOBALS['dictionary']['". $object . "']['fields']['". $key . "']=" . var_export_helper($val) . ";";
3329
-			}
3330
-		}
3331
-		$relationshipDiff = array_diff_assoc($vardefs['relationships'], $GLOBALS['dictionary'][$bean->object_name]['relationships']);
3332
-		if(!empty($relationshipDiff)){
3333
-			foreach($relationshipDiff as $key => $val){
3334
-				$contents .= "\n\$GLOBALS['dictionary']['". $object . "']['relationships']['". $key . "']=" . var_export_helper($val) . ";";
3335
-			}
3336
-		}
3337
-		$indexDiff = array_diff_assoc($vardefs['indices'], $GLOBALS['dictionary'][$bean->object_name]['indices']);
3338
-		if(!empty($indexDiff)){
3339
-			foreach($indexDiff as $key => $val){
3340
-					$contents .= "\n\$GLOBALS['dictionary']['". $object . "']['indices']['". $key . "']=" . var_export_helper($val) . ";";
3341
-			}
3342
-		}
3343
-		if( $fh = @sugar_fopen( $file, 'wt' ) )
3344
-	    {
3345
-	        fputs( $fh, $contents);
3346
-	        fclose( $fh );
3347
-	    }
3348
-
3349
-
3350
-		//we have written out the teams.php into custom/Extension/modules/{$module_dir}/Ext/Vardefs/teams.php'
3351
-		//now let's merge back into vardefs.ext.php
3352
-		require_once('ModuleInstall/ModuleInstaller.php');
3353
-		$mi = new ModuleInstaller();
3354
-		$mi->merge_files('Ext/Vardefs/', 'vardefs.ext.php');
3355
-		VardefManager::loadVardef($bean->module_dir, $bean->object_name, true);
3356
-		$bean->field_defs = $GLOBALS['dictionary'][$bean->object_name]['fields'];
3357
-	}
3318
+        $path = 'include/SugarObjects/implements/team_security/vardefs.php';
3319
+        require($path);
3320
+        //go through each entry in the vardefs from team_security and unset anything that is already set in the core module
3321
+        //this will ensure we have the proper ordering.
3322
+        $fieldDiff = array_diff_assoc($vardefs['fields'], $GLOBALS['dictionary'][$bean->object_name]['fields']);
3323
+
3324
+        $file = 'custom/Extension/modules/' . $bean->module_dir. '/Ext/Vardefs/teams.php';
3325
+        $contents = "<?php\n";
3326
+        if(!empty($fieldDiff)){
3327
+            foreach($fieldDiff as $key => $val){
3328
+                $contents .= "\n\$GLOBALS['dictionary']['". $object . "']['fields']['". $key . "']=" . var_export_helper($val) . ";";
3329
+            }
3330
+        }
3331
+        $relationshipDiff = array_diff_assoc($vardefs['relationships'], $GLOBALS['dictionary'][$bean->object_name]['relationships']);
3332
+        if(!empty($relationshipDiff)){
3333
+            foreach($relationshipDiff as $key => $val){
3334
+                $contents .= "\n\$GLOBALS['dictionary']['". $object . "']['relationships']['". $key . "']=" . var_export_helper($val) . ";";
3335
+            }
3336
+        }
3337
+        $indexDiff = array_diff_assoc($vardefs['indices'], $GLOBALS['dictionary'][$bean->object_name]['indices']);
3338
+        if(!empty($indexDiff)){
3339
+            foreach($indexDiff as $key => $val){
3340
+                    $contents .= "\n\$GLOBALS['dictionary']['". $object . "']['indices']['". $key . "']=" . var_export_helper($val) . ";";
3341
+            }
3342
+        }
3343
+        if( $fh = @sugar_fopen( $file, 'wt' ) )
3344
+        {
3345
+            fputs( $fh, $contents);
3346
+            fclose( $fh );
3347
+        }
3358 3348
 
3359
-	if(isset($bean->field_defs['team_set_id'])) {
3360
-		//Create the team_set_id column
3361
-		$FieldArray = $GLOBALS['db']->helper->get_columns($bean->table_name);
3362
-		if(!isset($FieldArray['team_set_id'])) {
3363
-			$GLOBALS['db']->addColumn($bean->table_name, $bean->field_defs['team_set_id']);
3364
-		}
3365
-		$indexArray =  $GLOBALS['db']->helper->get_indices($bean->table_name);
3349
+
3350
+        //we have written out the teams.php into custom/Extension/modules/{$module_dir}/Ext/Vardefs/teams.php'
3351
+        //now let's merge back into vardefs.ext.php
3352
+        require_once('ModuleInstall/ModuleInstaller.php');
3353
+        $mi = new ModuleInstaller();
3354
+        $mi->merge_files('Ext/Vardefs/', 'vardefs.ext.php');
3355
+        VardefManager::loadVardef($bean->module_dir, $bean->object_name, true);
3356
+        $bean->field_defs = $GLOBALS['dictionary'][$bean->object_name]['fields'];
3357
+    }
3358
+
3359
+    if(isset($bean->field_defs['team_set_id'])) {
3360
+        //Create the team_set_id column
3361
+        $FieldArray = $GLOBALS['db']->helper->get_columns($bean->table_name);
3362
+        if(!isset($FieldArray['team_set_id'])) {
3363
+            $GLOBALS['db']->addColumn($bean->table_name, $bean->field_defs['team_set_id']);
3364
+        }
3365
+        $indexArray =  $GLOBALS['db']->helper->get_indices($bean->table_name);
3366 3366
 
3367 3367
         $indexName = getValidDBName('idx_'.strtolower($bean->table_name).'_tmst_id', true, 34);
3368 3368
         $indexDef = array(
3369
-					 array(
3370
-						'name' => $indexName,
3371
-						'type' => 'index',
3372
-						'fields' => array('team_set_id')
3373
-					 )
3374
-				   );
3375
-		if(!isset($indexArray[$indexName])) {
3376
-			$GLOBALS['db']->addIndexes($bean->table_name, $indexDef);
3377
-		}
3369
+                        array(
3370
+                        'name' => $indexName,
3371
+                        'type' => 'index',
3372
+                        'fields' => array('team_set_id')
3373
+                        )
3374
+                    );
3375
+        if(!isset($indexArray[$indexName])) {
3376
+            $GLOBALS['db']->addIndexes($bean->table_name, $indexDef);
3377
+        }
3378 3378
 
3379
-		//Update the table's team_set_id column to have the same values as team_id
3380
-	    $GLOBALS['db']->query("UPDATE {$bean->table_name} SET team_set_id = {$column_name}");
3381
-	}
3379
+        //Update the table's team_set_id column to have the same values as team_id
3380
+        $GLOBALS['db']->query("UPDATE {$bean->table_name} SET team_set_id = {$column_name}");
3381
+    }
3382 3382
 }
3383 3383
 
3384 3384
 /**
@@ -3406,43 +3406,43 @@  discard block
 block discarded – undo
3406 3406
     $result = $GLOBALS['db']->query("SELECT id, user_name, first_name, last_name FROM users where deleted=0");
3407 3407
 
3408 3408
     while($row = $GLOBALS['db']->fetchByAssoc($result)) {
3409
-    	$results2 = $GLOBALS['db']->query("SELECT id FROM teams WHERE name = '({$row['user_name']})'");
3410
-    	$assoc = '';
3411
-  		if(!$assoc = $GLOBALS['db']->fetchByAssoc($results2)) {
3412
-  			//if team does not exist, then lets create the team for this user
3413
-  			$team = new Team();
3414
-			$user = new User();
3415
-  			$user->retrieve($row['id']);
3416
-			$team->new_user_created($user);
3417
-			$team_id = $team->id;
3418
-  		}else{
3419
-  			$team_id =$assoc['id'];
3420
-  		}
3421
-
3422
-  			//upgrade the team
3423
-  			$name = is_null($row['first_name'])?'':$row['first_name'];
3424
-			$name_2 = is_null($row['last_name'])?'':$row['last_name'];
3425
-			$associated_user_id = $row['id'];
3426
-
3427
-			//Bug 32914
3428
-			//Ensure team->name is not empty by using team->name_2 if available
3429
-			if(empty($name) && !empty($name_2)) {
3430
-			   $name = $name_2;
3431
-			   $name_2 = '';
3432
-			}
3433
-
3434
-			$query = "UPDATE teams SET name = '{$name}', name_2 = '{$name_2}', associated_user_id = '{$associated_user_id}' WHERE id = '{$team_id}'";
3435
-			$GLOBALS['db']->query($query);
3409
+        $results2 = $GLOBALS['db']->query("SELECT id FROM teams WHERE name = '({$row['user_name']})'");
3410
+        $assoc = '';
3411
+            if(!$assoc = $GLOBALS['db']->fetchByAssoc($results2)) {
3412
+                //if team does not exist, then lets create the team for this user
3413
+                $team = new Team();
3414
+            $user = new User();
3415
+                $user->retrieve($row['id']);
3416
+            $team->new_user_created($user);
3417
+            $team_id = $team->id;
3418
+            }else{
3419
+                $team_id =$assoc['id'];
3420
+            }
3421
+
3422
+                //upgrade the team
3423
+                $name = is_null($row['first_name'])?'':$row['first_name'];
3424
+            $name_2 = is_null($row['last_name'])?'':$row['last_name'];
3425
+            $associated_user_id = $row['id'];
3426
+
3427
+            //Bug 32914
3428
+            //Ensure team->name is not empty by using team->name_2 if available
3429
+            if(empty($name) && !empty($name_2)) {
3430
+                $name = $name_2;
3431
+                $name_2 = '';
3432
+            }
3433
+
3434
+            $query = "UPDATE teams SET name = '{$name}', name_2 = '{$name_2}', associated_user_id = '{$associated_user_id}' WHERE id = '{$team_id}'";
3435
+            $GLOBALS['db']->query($query);
3436 3436
     } //while
3437 3437
 
3438 3438
     //Update the team_set_id and default_team columns
3439 3439
     $ce_to_pro_or_ent = (isset($_SESSION['upgrade_from_flavor']) && ($_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarPro' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarEnt' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarCorp' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarUlt'));
3440 3440
 
3441 3441
     //Update team_set_id
3442
-	if($ce_to_pro_or_ent) {
3443
-	   $GLOBALS['db']->query("update users set team_set_id = (select teams.id from teams where teams.associated_user_id = users.id)");
3444
-	   $GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.associated_user_id = users.id)");
3445
-	}
3442
+    if($ce_to_pro_or_ent) {
3443
+        $GLOBALS['db']->query("update users set team_set_id = (select teams.id from teams where teams.associated_user_id = users.id)");
3444
+        $GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.associated_user_id = users.id)");
3445
+    }
3446 3446
 
3447 3447
 }
3448 3448
 
@@ -3480,15 +3480,15 @@  discard block
 block discarded – undo
3480 3480
 
3481 3481
             if(!empty($newModuleList))
3482 3482
             {
3483
-	            //grab the existing system tabs
3484
-	            $tabs = $newTB->get_system_tabs();
3483
+                //grab the existing system tabs
3484
+                $tabs = $newTB->get_system_tabs();
3485 3485
 
3486
-	            //add the new tabs to the array
3487
-	            foreach($newModuleList as $nm ){
3488
-	              $tabs[$nm] = $nm;
3489
-	            }
3486
+                //add the new tabs to the array
3487
+                foreach($newModuleList as $nm ){
3488
+                    $tabs[$nm] = $nm;
3489
+                }
3490 3490
 
3491
-	            $newTB->set_system_tabs($tabs);
3491
+                $newTB->set_system_tabs($tabs);
3492 3492
             }
3493 3493
             logThis('module tabs updated',$path);
3494 3494
         }
@@ -3504,242 +3504,242 @@  discard block
 block discarded – undo
3504 3504
      * have been affected.
3505 3505
      *
3506 3506
      */
3507
-	function fix_dropdown_list() {
3507
+    function fix_dropdown_list() {
3508 3508
         if(file_exists('custom/include/language')) {
3509
-           $files = array();
3510
-           $affected_modules = array();
3511
-           $affected_keys = array();
3512
-
3513
-           getFiles($files, 'custom/include/language', '/\.php$/i');
3514
-           foreach($files as $file) {
3515
-
3516
-              if(file_exists($file . '.bak')) {
3517
-              	 $bak_mod_time = filemtime($file . '.bak');
3518
-              	 $php_mod_time = filemtime($file);
3519
-              	 //We're saying if the .php file was modified 30 seconds no more than php.bak file then we
3520
-              	 //run these additional cleanup checks
3521
-              	 if($php_mod_time - $bak_mod_time < 30) {
3522
-
3523
-              	 	$app_list_strings = array();
3524
-              	 	$GLOBALS['app_list_strings'] = array();
3525
-              	 	require($file . '.bak');
3526
-              	 	$bak_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3527
-
3528
-              	 	$app_list_strings = array();
3529
-              	 	$GLOBALS['app_list_strings'] = array();
3530
-              	 	require($file);
3531
-              	 	$php_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3532
-
3533
-              	 	//Get the file contents
3534
-              	 	$contents = file_get_contents($file);
3535
-
3536
-              	 	//Now simulate a fix for the file before we compare w/ the .php file
3537
-              	 	//we also append to the $contents
3538
-              	 	foreach($bak_app_list_strings as $key=>$entry) {
3539
-						   if(preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) {
3540
-						   	  $new_key = preg_replace('/[^A-Za-z_]/', '_', $key);
3541
-						   	  $bak_app_list_strings[$new_key] = $bak_app_list_strings[$key];
3542
-						   	  unset($bak_app_list_strings[$key]);
3543
-						   	  //Now if the entry doesn't exists in the .php file, then add to contents
3544
-						   	  if(!isset($php_app_list_strings[$new_key])) {
3545
-						   	  	 $contents .= "\n\$GLOBALS['app_list_strings']['{$new_key}'] = " . var_export_helper($bak_app_list_strings[$new_key]) . ";";
3546
-						   	  }
3547
-						   } //if
3548
-              	 	} //foreach
3549
-
3550
-              	 	//Now load the .php file to do the comparison
3551
-              	 	foreach($php_app_list_strings as $key=>$entry) {
3552
-              	 		if(isset($bak_app_list_strings[$key])) {
3553
-              	 			$diff = array_diff($bak_app_list_strings[$key], $entry);
3554
-              	 			if(!empty($diff)) {
3555
-              	 			   //There is a difference, so copy the $bak_app_list_strings version into the .php file
3556
-              	 			   $contents .= "\n\$GLOBALS['app_list_strings']['{$key}'] = " . var_export_helper($bak_app_list_strings[$key]) . ";";
3557
-              	 			} //if
3558
-              	 		} //if
3559
-              	 	} //foreach
3560
-
3561
-              	 	//Now write out the file contents
3562
-              	 	//Create backup just in case
3563
-              	 	copy($file, $file . '.php_bak');
3564
- 					$fp = @sugar_fopen($file, 'w');
3565
-	                if($fp) {
3566
-		               fwrite($fp, $contents);
3567
-		               fclose($fp);
3568
-	                } else {
3569
-	                   $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list for {$file}");
3570
-	                } //if-else
3571
-              	 }
3572
-              }
3573
-
3574
-              unset($GLOBALS['app_strings']);
3575
-              unset($GLOBALS['app_list_strings']);
3576
-              $app_list_strings = array();
3577
-           	  require($file);
3578
-           	  $touched = false;
3579
-           	  $contents = file_get_contents($file);
3580
-           	  if ( !isset($GLOBALS['app_list_strings']) ) {
3581
-           	      $GLOBALS['app_list_strings'] = $app_list_strings;
3582
-           	  }
3583
-           	  else {
3584
-           	      $GLOBALS['app_list_strings'] = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3585
-           	  }
3586
-
3587
-           	  if(isset($GLOBALS['app_list_strings']) && is_array($GLOBALS['app_list_strings'])) {
3588
-           	  	 foreach($GLOBALS['app_list_strings'] as $key=>$entry) {
3589
-           	  	 	if(preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) {
3590
-           	  	 	   $result = $GLOBALS['db']->query("SELECT custom_module FROM fields_meta_data WHERE ext1 = '{$key}'");
3591
-           	  	 	   if(!empty($result)) {
3592
-           	  	 	   	  while($row = $GLOBALS['db']->fetchByAssoc($result)) {
3593
-           	  	 	   	  	    $custom_module = $row['custom_module'];
3594
-           	  	 	   	  	    if(!empty($GLOBALS['beanList'][$custom_module])) {
3595
-           	  	 	   	           $affected_modules[$custom_module] = $GLOBALS['beanList'][$custom_module];
3596
-           	  	 	   	  	    }
3597
-           	  	 	   	  } //while
3598
-           	  	 	   }
3599
-
3600
-           	  	 	   //Replace all invalid characters with '_' character
3601
-	           	  	   $new_key = preg_replace('/[^A-Za-z_]/', '_', $key);
3602
-	           	  	   $affected_keys[$key] = $new_key;
3603
-
3604
-           	  	 	   $GLOBALS['app_list_strings'][$new_key] = $GLOBALS['app_list_strings'][$key];
3605
-           	  	 	   unset($GLOBALS['app_list_strings'][$key]);
3606
-
3607
-           	  	 	   $pattern_match = "/(\[\s*\'{$key}\'\s*\])/";
3608
-           	  	 	   $new_key = "['{$new_key}']";
3609
-           	  	 	   $out = preg_replace($pattern_match, $new_key, $contents);
3610
-           	  	 	   $contents = $out;
3611
-           	  	 	   $touched = true;
3612
-           	  	 	} //if
3613
-           	  	 } //foreach
3614
-
3615
-                 //This is a check for g => h instances where the file contents were incorrectly written
3616
-                 //and also fixes the scenario where via a UI upgrade, the app_list_strings were incorrectly
3617
-                 //merged with app_list_strings variables declared elsewhere
3618
-           	  	 if(!$touched) {
3619
-           	  	 	   if(preg_match('/\$GLOBALS\s*\[\s*[\"|\']app_list_strings[\"|\']\s*\]\s*=\s*array\s*\(/', $contents)) {
3620
-           	  	 	   	  //Now also remove all the non-custom labels that were added
3621
-           	  	 	   	  if(preg_match('/language\/([^\.]+)\.lang\.php$/', $file, $matches)) {
3622
-           	  	 	   	        $language = $matches[1];
3623
-
3624
-           	  	 	   	        $app_list_strings = array();
3625
-
3626
-           	  	                if(file_exists("include/language/$language.lang.php")) {
3627
-								   include("include/language/$language.lang.php");
3628
-								}
3629
-								if(file_exists("include/language/$language.lang.override.php")) {
3630
-								   $app_list_strings =  _mergeCustomAppListStrings("include/language/$language.lang.override.php" , $app_list_strings) ;
3631
-								}
3632
-								if(file_exists("custom/application/Ext/Language/$language.ext.lang.php")) {
3633
-								   $app_list_strings =  _mergeCustomAppListStrings("custom/application/Ext/Language/$language.ext.lang.php" , $app_list_strings) ;
3634
-								}
3635
-								if(file_exists("custom/application/Ext/Language/$language.lang.ext.php")) {
3636
-								   $app_list_strings =  _mergeCustomAppListStrings("custom/application/Ext/Language/$language.lang.ext.php" , $app_list_strings) ;
3637
-								}
3638
-
3639
-								$all_non_custom_include_language_strings = $app_strings;
3640
-								$all_non_custom_include_language_list_strings = $app_list_strings;
3641
-
3642
-								$unset_keys = array();
3643
-								if(!empty($GLOBALS['app_list_strings'])) {
3644
-									foreach($GLOBALS['app_list_strings'] as $key=>$value) {
3645
-										$diff = array();
3646
-										if(isset($all_non_custom_include_language_list_strings[$key])) {
3647
-											$diff = array_diff($all_non_custom_include_language_list_strings[$key], $GLOBALS['app_list_strings'][$key]);
3648
-										}
3649
-
3650
-										if(!empty($all_non_custom_include_language_list_strings[$key]) && empty($diff)) {
3651
-											$unset_keys[] = $key;
3652
-										}
3653
-									}
3654
-								}
3655
-
3656
-								foreach($unset_keys as $key) {
3657
-									unset($GLOBALS['app_list_strings'][$key]);
3658
-								}
3659
-
3660
-								if(!empty($GLOBALS['app_strings'])) {
3661
-	           	  	 	   	  		foreach($GLOBALS['app_strings'] as $key=>$value) {
3662
-										if(!empty($all_non_custom_include_language_strings[$key])) {
3663
-										   unset($GLOBALS['app_strings'][$key]);
3664
-										}
3665
-	           	  	 	   	  		}
3666
-								}
3667
-           	  	 	   	  } //if(preg_match...)
3668
-
3669
-			              $out = "<?php \n";
3670
-			              if(!empty($GLOBALS['app_strings'])) {
3671
-				             foreach($GLOBALS['app_strings'] as $key=>$entry) {
3672
-				                     $out .= "\n\$GLOBALS['app_strings']['$key']=" . var_export_helper($entry) . ";";
3673
-				             }
3674
-			              }
3675
-
3676
-						  foreach($GLOBALS['app_list_strings'] as $key=>$entry) {
3677
-								  $out .= "\n\$GLOBALS['app_list_strings']['$key']=" . var_export_helper($entry) . ";";
3678
-						  } //foreach
3679
-
3680
-						  $touched = true;
3681
-           	  	 	   } //if(preg_match...)
3682
-           	  	 } //if(!$touched)
3683
-
3684
-           	  	 if($touched) {
3685
-	           	  	 //Create a backup just in case
3686
-			         copy($file, $file . '.bak');
3687
-	             	 $fp = @sugar_fopen($file, 'w');
3688
-	                 if($fp) {
3689
-		               fwrite($fp, $out);
3690
-		               fclose($fp);
3691
-	                 } else {
3692
-	                   //If we can't update the file, just return
3693
-	                   $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list.");
3694
-	                   return;
3695
-	                 }
3696
-           	  	 } //if($touched)
3697
-           	  } //if
3698
-
3699
-           } //foreach($files)
3700
-
3701
-           //Update db entries (the order matters here... need to process database changes first)
3702
-           if(!empty($affected_keys)) {
3703
-           	  foreach($affected_keys as $old_key=>$new_key) {
3704
-           	  	 	  $GLOBALS['db']->query("UPDATE fields_meta_data SET ext1 = '{$new_key}' WHERE ext1 = '{$old_key}'");
3705
-           	  }
3706
-           }
3707
-
3708
-           //Update vardef files for affected modules
3709
-           if(!empty($affected_modules)) {
3710
-           	  foreach($affected_modules as $module=>$object) {
3711
-           	  	  VardefManager::refreshVardefs($module, $object);
3712
-           	  }
3713
-           }
3509
+            $files = array();
3510
+            $affected_modules = array();
3511
+            $affected_keys = array();
3512
+
3513
+            getFiles($files, 'custom/include/language', '/\.php$/i');
3514
+            foreach($files as $file) {
3515
+
3516
+                if(file_exists($file . '.bak')) {
3517
+                    $bak_mod_time = filemtime($file . '.bak');
3518
+                    $php_mod_time = filemtime($file);
3519
+                    //We're saying if the .php file was modified 30 seconds no more than php.bak file then we
3520
+                    //run these additional cleanup checks
3521
+                    if($php_mod_time - $bak_mod_time < 30) {
3522
+
3523
+                        $app_list_strings = array();
3524
+                        $GLOBALS['app_list_strings'] = array();
3525
+                        require($file . '.bak');
3526
+                        $bak_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3527
+
3528
+                        $app_list_strings = array();
3529
+                        $GLOBALS['app_list_strings'] = array();
3530
+                        require($file);
3531
+                        $php_app_list_strings = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3532
+
3533
+                        //Get the file contents
3534
+                        $contents = file_get_contents($file);
3535
+
3536
+                        //Now simulate a fix for the file before we compare w/ the .php file
3537
+                        //we also append to the $contents
3538
+                        foreach($bak_app_list_strings as $key=>$entry) {
3539
+                            if(preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) {
3540
+                                    $new_key = preg_replace('/[^A-Za-z_]/', '_', $key);
3541
+                                    $bak_app_list_strings[$new_key] = $bak_app_list_strings[$key];
3542
+                                    unset($bak_app_list_strings[$key]);
3543
+                                    //Now if the entry doesn't exists in the .php file, then add to contents
3544
+                                    if(!isset($php_app_list_strings[$new_key])) {
3545
+                                        $contents .= "\n\$GLOBALS['app_list_strings']['{$new_key}'] = " . var_export_helper($bak_app_list_strings[$new_key]) . ";";
3546
+                                    }
3547
+                            } //if
3548
+                        } //foreach
3549
+
3550
+                        //Now load the .php file to do the comparison
3551
+                        foreach($php_app_list_strings as $key=>$entry) {
3552
+                            if(isset($bak_app_list_strings[$key])) {
3553
+                                $diff = array_diff($bak_app_list_strings[$key], $entry);
3554
+                                if(!empty($diff)) {
3555
+                                    //There is a difference, so copy the $bak_app_list_strings version into the .php file
3556
+                                    $contents .= "\n\$GLOBALS['app_list_strings']['{$key}'] = " . var_export_helper($bak_app_list_strings[$key]) . ";";
3557
+                                } //if
3558
+                            } //if
3559
+                        } //foreach
3560
+
3561
+                        //Now write out the file contents
3562
+                        //Create backup just in case
3563
+                        copy($file, $file . '.php_bak');
3564
+                        $fp = @sugar_fopen($file, 'w');
3565
+                    if($fp) {
3566
+                        fwrite($fp, $contents);
3567
+                        fclose($fp);
3568
+                    } else {
3569
+                        $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list for {$file}");
3570
+                    } //if-else
3571
+                    }
3572
+                }
3573
+
3574
+                unset($GLOBALS['app_strings']);
3575
+                unset($GLOBALS['app_list_strings']);
3576
+                $app_list_strings = array();
3577
+                    require($file);
3578
+                    $touched = false;
3579
+                    $contents = file_get_contents($file);
3580
+                    if ( !isset($GLOBALS['app_list_strings']) ) {
3581
+                        $GLOBALS['app_list_strings'] = $app_list_strings;
3582
+                    }
3583
+                    else {
3584
+                        $GLOBALS['app_list_strings'] = array_merge($app_list_strings, $GLOBALS['app_list_strings']);
3585
+                    }
3586
+
3587
+                    if(isset($GLOBALS['app_list_strings']) && is_array($GLOBALS['app_list_strings'])) {
3588
+                        foreach($GLOBALS['app_list_strings'] as $key=>$entry) {
3589
+                            if(preg_match('/([^A-Za-z_])/', $key, $matches) && is_array($entry)) {
3590
+                                $result = $GLOBALS['db']->query("SELECT custom_module FROM fields_meta_data WHERE ext1 = '{$key}'");
3591
+                                if(!empty($result)) {
3592
+                                    while($row = $GLOBALS['db']->fetchByAssoc($result)) {
3593
+                                            $custom_module = $row['custom_module'];
3594
+                                            if(!empty($GLOBALS['beanList'][$custom_module])) {
3595
+                                            $affected_modules[$custom_module] = $GLOBALS['beanList'][$custom_module];
3596
+                                            }
3597
+                                    } //while
3598
+                                }
3599
+
3600
+                                //Replace all invalid characters with '_' character
3601
+                            $new_key = preg_replace('/[^A-Za-z_]/', '_', $key);
3602
+                            $affected_keys[$key] = $new_key;
3603
+
3604
+                                $GLOBALS['app_list_strings'][$new_key] = $GLOBALS['app_list_strings'][$key];
3605
+                                unset($GLOBALS['app_list_strings'][$key]);
3606
+
3607
+                                $pattern_match = "/(\[\s*\'{$key}\'\s*\])/";
3608
+                                $new_key = "['{$new_key}']";
3609
+                                $out = preg_replace($pattern_match, $new_key, $contents);
3610
+                                $contents = $out;
3611
+                                $touched = true;
3612
+                            } //if
3613
+                        } //foreach
3614
+
3615
+                    //This is a check for g => h instances where the file contents were incorrectly written
3616
+                    //and also fixes the scenario where via a UI upgrade, the app_list_strings were incorrectly
3617
+                    //merged with app_list_strings variables declared elsewhere
3618
+                        if(!$touched) {
3619
+                                if(preg_match('/\$GLOBALS\s*\[\s*[\"|\']app_list_strings[\"|\']\s*\]\s*=\s*array\s*\(/', $contents)) {
3620
+                                    //Now also remove all the non-custom labels that were added
3621
+                                    if(preg_match('/language\/([^\.]+)\.lang\.php$/', $file, $matches)) {
3622
+                                            $language = $matches[1];
3623
+
3624
+                                            $app_list_strings = array();
3625
+
3626
+                                        if(file_exists("include/language/$language.lang.php")) {
3627
+                                    include("include/language/$language.lang.php");
3628
+                                }
3629
+                                if(file_exists("include/language/$language.lang.override.php")) {
3630
+                                    $app_list_strings =  _mergeCustomAppListStrings("include/language/$language.lang.override.php" , $app_list_strings) ;
3631
+                                }
3632
+                                if(file_exists("custom/application/Ext/Language/$language.ext.lang.php")) {
3633
+                                    $app_list_strings =  _mergeCustomAppListStrings("custom/application/Ext/Language/$language.ext.lang.php" , $app_list_strings) ;
3634
+                                }
3635
+                                if(file_exists("custom/application/Ext/Language/$language.lang.ext.php")) {
3636
+                                    $app_list_strings =  _mergeCustomAppListStrings("custom/application/Ext/Language/$language.lang.ext.php" , $app_list_strings) ;
3637
+                                }
3638
+
3639
+                                $all_non_custom_include_language_strings = $app_strings;
3640
+                                $all_non_custom_include_language_list_strings = $app_list_strings;
3641
+
3642
+                                $unset_keys = array();
3643
+                                if(!empty($GLOBALS['app_list_strings'])) {
3644
+                                    foreach($GLOBALS['app_list_strings'] as $key=>$value) {
3645
+                                        $diff = array();
3646
+                                        if(isset($all_non_custom_include_language_list_strings[$key])) {
3647
+                                            $diff = array_diff($all_non_custom_include_language_list_strings[$key], $GLOBALS['app_list_strings'][$key]);
3648
+                                        }
3649
+
3650
+                                        if(!empty($all_non_custom_include_language_list_strings[$key]) && empty($diff)) {
3651
+                                            $unset_keys[] = $key;
3652
+                                        }
3653
+                                    }
3654
+                                }
3655
+
3656
+                                foreach($unset_keys as $key) {
3657
+                                    unset($GLOBALS['app_list_strings'][$key]);
3658
+                                }
3659
+
3660
+                                if(!empty($GLOBALS['app_strings'])) {
3661
+                                                foreach($GLOBALS['app_strings'] as $key=>$value) {
3662
+                                        if(!empty($all_non_custom_include_language_strings[$key])) {
3663
+                                            unset($GLOBALS['app_strings'][$key]);
3664
+                                        }
3665
+                                                }
3666
+                                }
3667
+                                    } //if(preg_match...)
3668
+
3669
+                            $out = "<?php \n";
3670
+                            if(!empty($GLOBALS['app_strings'])) {
3671
+                                foreach($GLOBALS['app_strings'] as $key=>$entry) {
3672
+                                        $out .= "\n\$GLOBALS['app_strings']['$key']=" . var_export_helper($entry) . ";";
3673
+                                }
3674
+                            }
3675
+
3676
+                            foreach($GLOBALS['app_list_strings'] as $key=>$entry) {
3677
+                                    $out .= "\n\$GLOBALS['app_list_strings']['$key']=" . var_export_helper($entry) . ";";
3678
+                            } //foreach
3679
+
3680
+                            $touched = true;
3681
+                                } //if(preg_match...)
3682
+                        } //if(!$touched)
3683
+
3684
+                        if($touched) {
3685
+                            //Create a backup just in case
3686
+                        copy($file, $file . '.bak');
3687
+                        $fp = @sugar_fopen($file, 'w');
3688
+                        if($fp) {
3689
+                        fwrite($fp, $out);
3690
+                        fclose($fp);
3691
+                        } else {
3692
+                        //If we can't update the file, just return
3693
+                        $GLOBALS['log']->error("Unable to update file contents in fix_dropdown_list.");
3694
+                        return;
3695
+                        }
3696
+                        } //if($touched)
3697
+                    } //if
3698
+
3699
+            } //foreach($files)
3700
+
3701
+            //Update db entries (the order matters here... need to process database changes first)
3702
+            if(!empty($affected_keys)) {
3703
+                    foreach($affected_keys as $old_key=>$new_key) {
3704
+                            $GLOBALS['db']->query("UPDATE fields_meta_data SET ext1 = '{$new_key}' WHERE ext1 = '{$old_key}'");
3705
+                    }
3706
+            }
3707
+
3708
+            //Update vardef files for affected modules
3709
+            if(!empty($affected_modules)) {
3710
+                    foreach($affected_modules as $module=>$object) {
3711
+                        VardefManager::refreshVardefs($module, $object);
3712
+                    }
3713
+            }
3714 3714
         }
3715
-	}
3715
+    }
3716 3716
 
3717 3717
 
3718
-	function update_iframe_dashlets(){
3719
-		require_once(sugar_cached('dashlets/dashlets.php'));
3720
-
3721
-		$db = DBManagerFactory::getInstance();
3722
-		$query = "SELECT id, contents, assigned_user_id FROM user_preferences WHERE deleted = 0 AND category = 'Home'";
3723
-		$result = $db->query($query, true, "Unable to update new default dashlets! ");
3724
-		while ($row = $db->fetchByAssoc($result)) {
3725
-			$content = unserialize(base64_decode($row['contents']));
3726
-			$assigned_user_id = $row['assigned_user_id'];
3727
-			$record_id = $row['id'];
3728
-
3729
-			$current_user = new User();
3730
-			$current_user->retrieve($row['assigned_user_id']);
3731
-
3732
-			if(!empty($content['dashlets']) && !empty($content['pages'])){
3733
-				$originalDashlets = $content['dashlets'];
3734
-				foreach($originalDashlets as $key => $ds){
3735
-				    if(!empty($ds['options']['url']) && stristr($ds['options']['url'],'https://www.sugarcrm.com/crm/product/gopro')){
3736
-						unset($originalDashlets[$key]);
3737
-					}
3738
-				}
3739
-				$current_user->setPreference('dashlets', $originalDashlets, 0, 'Home');
3740
-			}
3741
-		}
3742
-	}
3718
+    function update_iframe_dashlets(){
3719
+        require_once(sugar_cached('dashlets/dashlets.php'));
3720
+
3721
+        $db = DBManagerFactory::getInstance();
3722
+        $query = "SELECT id, contents, assigned_user_id FROM user_preferences WHERE deleted = 0 AND category = 'Home'";
3723
+        $result = $db->query($query, true, "Unable to update new default dashlets! ");
3724
+        while ($row = $db->fetchByAssoc($result)) {
3725
+            $content = unserialize(base64_decode($row['contents']));
3726
+            $assigned_user_id = $row['assigned_user_id'];
3727
+            $record_id = $row['id'];
3728
+
3729
+            $current_user = new User();
3730
+            $current_user->retrieve($row['assigned_user_id']);
3731
+
3732
+            if(!empty($content['dashlets']) && !empty($content['pages'])){
3733
+                $originalDashlets = $content['dashlets'];
3734
+                foreach($originalDashlets as $key => $ds){
3735
+                    if(!empty($ds['options']['url']) && stristr($ds['options']['url'],'https://www.sugarcrm.com/crm/product/gopro')){
3736
+                        unset($originalDashlets[$key]);
3737
+                    }
3738
+                }
3739
+                $current_user->setPreference('dashlets', $originalDashlets, 0, 'Home');
3740
+            }
3741
+        }
3742
+    }
3743 3743
 
3744 3744
 
3745 3745
     /**
@@ -3748,22 +3748,22 @@  discard block
 block discarded – undo
3748 3748
      * This method attempts to convert date type image to text on Microsoft SQL Server.
3749 3749
      * This method could NOT be used in any other type of datebases.
3750 3750
      */
3751
-	function convertImageToText($table_name,$column_name){
3752
-		$set_lang = "SET LANGUAGE us_english";
3753
-		$GLOBALS['db']->query($set_lang);
3754
-	    if($GLOBALS['db']->lastError()){
3751
+    function convertImageToText($table_name,$column_name){
3752
+        $set_lang = "SET LANGUAGE us_english";
3753
+        $GLOBALS['db']->query($set_lang);
3754
+        if($GLOBALS['db']->lastError()){
3755 3755
             logThis('An error occurred when performing this query-->'.$set_lang);
3756 3756
         }
3757
-       $q="SELECT data_type
3757
+        $q="SELECT data_type
3758 3758
         FROM INFORMATION_SCHEMA.Tables T JOIN INFORMATION_SCHEMA.Columns C
3759 3759
         ON T.TABLE_NAME = C.TABLE_NAME where T.TABLE_NAME = '$table_name' and C.COLUMN_NAME = '$column_name'";
3760
-       $res= $GLOBALS['db']->query($q);
3761
-       if($GLOBALS['db']->lastError()){
3760
+        $res= $GLOBALS['db']->query($q);
3761
+        if($GLOBALS['db']->lastError()){
3762 3762
             logThis('An error occurred when performing this query-->'.$q);
3763 3763
         }
3764
-       $row= $GLOBALS['db']->fetchByAssoc($res);
3764
+        $row= $GLOBALS['db']->fetchByAssoc($res);
3765 3765
 
3766
-     if(trim(strtolower($row['data_type'])) == 'image'){
3766
+        if(trim(strtolower($row['data_type'])) == 'image'){
3767 3767
         $addContent_temp = "alter table {$table_name} add {$column_name}_temp text null";
3768 3768
         $GLOBALS['db']->query($addContent_temp);
3769 3769
         if($GLOBALS['db']->lastError()){
@@ -3772,7 +3772,7 @@  discard block
 block discarded – undo
3772 3772
         $qN = "select count=datalength({$column_name}), id, {$column_name} from {$table_name}";
3773 3773
         $result = $GLOBALS['db']->query($qN);
3774 3774
         while($row = $GLOBALS['db']->fetchByAssoc($result)){
3775
-           if($row['count'] >8000){
3775
+            if($row['count'] >8000){
3776 3776
                 $contentLength = $row['count'];
3777 3777
                 $start = 1;
3778 3778
                 $next=8000;
@@ -3795,15 +3795,15 @@  discard block
 block discarded – undo
3795 3795
                 if($GLOBALS['db']->lastError()){
3796 3796
                     logThis('An error occurred when performing this query-->'.$addContentDataText);
3797 3797
                 }
3798
-           }
3799
-           else{
3798
+            }
3799
+            else{
3800 3800
                 $addContentDataText="update {$table_name} set {$column_name}_temp =
3801 3801
                 convert(varchar(max), convert(varbinary(8000), {$column_name})) where id= '{$row['id']}'";
3802 3802
                 $GLOBALS['db']->query($addContentDataText);
3803 3803
                 if($GLOBALS['db']->lastError()){
3804 3804
                     logThis('An error occurred when performing this query-->'.$addContentDataText);
3805 3805
                 }
3806
-           }
3806
+            }
3807 3807
         }
3808 3808
         //drop the contents now and change contents_temp to contents
3809 3809
         $dropColumn = "alter table {$table_name} drop column {$column_name}";
@@ -3816,66 +3816,66 @@  discard block
 block discarded – undo
3816 3816
         if($GLOBALS['db']->lastError()){
3817 3817
             logThis('An error occurred when performing this query-->'.$changeColumnName);
3818 3818
         }
3819
-     }
3819
+        }
3820 3820
     }
3821 3821
 
3822
-	 /**
3823
-     * clearHelpFiles
3824
-     * This method attempts to delete all English inline help files.
3825
-     * This method was introduced by 5.5.0RC2.
3826
-     */
3822
+        /**
3823
+         * clearHelpFiles
3824
+         * This method attempts to delete all English inline help files.
3825
+         * This method was introduced by 5.5.0RC2.
3826
+         */
3827 3827
     function clearHelpFiles(){
3828
-		$modulePath = clean_path(getcwd() . '/modules');
3829
-		$allHelpFiles = array();
3830
-		getFiles($allHelpFiles, $modulePath, "/en_us.help.*/");
3831
-
3832
-		foreach( $allHelpFiles as $the_file ){
3833
-	        if( is_file( $the_file ) ){
3834
-	            unlink( $the_file );
3835
-	            logThis("Deleted file: $the_file");
3836
-	        }
3837
-	    }
3838
-	}
3828
+        $modulePath = clean_path(getcwd() . '/modules');
3829
+        $allHelpFiles = array();
3830
+        getFiles($allHelpFiles, $modulePath, "/en_us.help.*/");
3831
+
3832
+        foreach( $allHelpFiles as $the_file ){
3833
+            if( is_file( $the_file ) ){
3834
+                unlink( $the_file );
3835
+                logThis("Deleted file: $the_file");
3836
+            }
3837
+        }
3838
+    }
3839 3839
 
3840 3840
 
3841 3841
 
3842
-	/**
3843
-	 * upgradeDateTimeFields
3844
-	 *
3845
-	 * This method came from bug: 39757 where the date_end field is a date field and not a datetime field
3846
-	 * which prevents you from performing timezone offset calculations once the data has been saved.
3847
-	 *
3848
-	 * @param path String location to log file, empty by default
3849
-	 */
3850
-	function upgradeDateTimeFields($path)
3851
-	{
3852
-		//bug: 39757
3853
-		global $db;
3854
-		$meetingsSql = "UPDATE meetings SET date_end = ".$db->convert("date_start", 'add_time', array('duration_hours', 'duration_minutes'));
3855
-		$callsSql = "UPDATE calls SET date_end = ".$db->convert("date_start", 'add_time', array('duration_hours', 'duration_minutes'));
3856
-    	logThis('upgradeDateTimeFields Meetings SQL:' . $meetingsSql, $path);
3857
-		$db->query($meetingsSql);
3858
-
3859
-		logThis('upgradeDateTimeFields Calls SQL:' . $callsSql, $path);
3860
-		$db->query($callsSql);
3861
-	}
3842
+    /**
3843
+     * upgradeDateTimeFields
3844
+     *
3845
+     * This method came from bug: 39757 where the date_end field is a date field and not a datetime field
3846
+     * which prevents you from performing timezone offset calculations once the data has been saved.
3847
+     *
3848
+     * @param path String location to log file, empty by default
3849
+     */
3850
+    function upgradeDateTimeFields($path)
3851
+    {
3852
+        //bug: 39757
3853
+        global $db;
3854
+        $meetingsSql = "UPDATE meetings SET date_end = ".$db->convert("date_start", 'add_time', array('duration_hours', 'duration_minutes'));
3855
+        $callsSql = "UPDATE calls SET date_end = ".$db->convert("date_start", 'add_time', array('duration_hours', 'duration_minutes'));
3856
+        logThis('upgradeDateTimeFields Meetings SQL:' . $meetingsSql, $path);
3857
+        $db->query($meetingsSql);
3858
+
3859
+        logThis('upgradeDateTimeFields Calls SQL:' . $callsSql, $path);
3860
+        $db->query($callsSql);
3861
+    }
3862 3862
 
3863
-	/**
3864
-	 * upgradeDocumentTypeFields
3865
-	 *
3866
-	 */
3867
-	function upgradeDocumentTypeFields($path){
3868
-		//bug: 39757
3869
-		global $db;
3870
-
3871
-		$documentsSql = "UPDATE documents SET doc_type = 'Sugar' WHERE doc_type IS NULL";
3872
-		$meetingsSql = "UPDATE meetings SET type = 'Sugar' WHERE type IS NULL";
3873
-
3874
-		logThis('upgradeDocumentTypeFields Documents SQL:' . $documentsSql, $path);
3875
-		$db->query($documentsSql);
3876
-		logThis('upgradeDocumentTypeFields Meetings SQL:' . $meetingsSql, $path);
3877
-		$db->query($meetingsSql);
3878
-	}
3863
+    /**
3864
+     * upgradeDocumentTypeFields
3865
+     *
3866
+     */
3867
+    function upgradeDocumentTypeFields($path){
3868
+        //bug: 39757
3869
+        global $db;
3870
+
3871
+        $documentsSql = "UPDATE documents SET doc_type = 'Sugar' WHERE doc_type IS NULL";
3872
+        $meetingsSql = "UPDATE meetings SET type = 'Sugar' WHERE type IS NULL";
3873
+
3874
+        logThis('upgradeDocumentTypeFields Documents SQL:' . $documentsSql, $path);
3875
+        $db->query($documentsSql);
3876
+        logThis('upgradeDocumentTypeFields Meetings SQL:' . $meetingsSql, $path);
3877
+        $db->query($meetingsSql);
3878
+    }
3879 3879
 
3880 3880
 
3881 3881
 /**
@@ -3893,131 +3893,131 @@  discard block
 block discarded – undo
3893 3893
  */
3894 3894
 function merge_config_si_settings($write_to_upgrade_log=false, $config_location='', $config_si_location='', $path='')
3895 3895
 {
3896
-	if(!empty($config_location) && !file_exists($config_location))
3897
-	{
3898
-		if($write_to_upgrade_log)
3899
-		{
3900
-	       logThis('config.php file specified in ' . $config_si_location . ' could not be found.  Skip merging', $path);
3901
-		}
3902
-	    return false;
3903
-	} else if(empty($config_location)) {
3904
-		global $argv;
3905
-		//We are assuming this is from the silentUpgrade scripts so argv[3] will point to SugarCRM install location
3906
-		if(isset($argv[3]) && is_dir($argv[3]))
3907
-		{
3908
-			$config_location = $argv[3] . DIRECTORY_SEPARATOR . 'config.php';
3909
-		}
3910
-	}
3896
+    if(!empty($config_location) && !file_exists($config_location))
3897
+    {
3898
+        if($write_to_upgrade_log)
3899
+        {
3900
+            logThis('config.php file specified in ' . $config_si_location . ' could not be found.  Skip merging', $path);
3901
+        }
3902
+        return false;
3903
+    } else if(empty($config_location)) {
3904
+        global $argv;
3905
+        //We are assuming this is from the silentUpgrade scripts so argv[3] will point to SugarCRM install location
3906
+        if(isset($argv[3]) && is_dir($argv[3]))
3907
+        {
3908
+            $config_location = $argv[3] . DIRECTORY_SEPARATOR . 'config.php';
3909
+        }
3910
+    }
3911 3911
 
3912
-	//If config_location is still empty or if the file cannot be found, skip merging
3913
-	if(empty($config_location) || !file_exists($config_location))
3914
-	{
3915
-	   if($write_to_upgrade_log)
3916
-	   {
3917
-	   	  logThis('config.php file at (' . $config_location . ') could not be found.  Skip merging.', $path);
3918
-	   }
3919
-	   return false;
3920
-	} else {
3921
-	   if($write_to_upgrade_log)
3922
-	   {
3923
-	      logThis('Loading config.php file at (' . $config_location . ') for merging.', $path);
3924
-	   }
3925
-
3926
-	   include($config_location);
3927
-	   if(empty($sugar_config))
3928
-	   {
3929
-	   	  if($write_to_upgrade_log)
3930
-		  {
3931
-	   	     logThis('config.php contents are empty.  Skip merging.', $path);
3932
-		  }
3933
-	   	  return false;
3934
-	   }
3935
-	}
3912
+    //If config_location is still empty or if the file cannot be found, skip merging
3913
+    if(empty($config_location) || !file_exists($config_location))
3914
+    {
3915
+        if($write_to_upgrade_log)
3916
+        {
3917
+                logThis('config.php file at (' . $config_location . ') could not be found.  Skip merging.', $path);
3918
+        }
3919
+        return false;
3920
+    } else {
3921
+        if($write_to_upgrade_log)
3922
+        {
3923
+            logThis('Loading config.php file at (' . $config_location . ') for merging.', $path);
3924
+        }
3936 3925
 
3937
-	if(!empty($config_si_location) && !file_exists($config_si_location))
3938
-	{
3939
-		if($write_to_upgrade_log)
3940
-		{
3941
-	       logThis('config_si.php file specified in ' . $config_si_location . ' could not be found.  Skip merging', $path);
3942
-		}
3943
-	    return false;
3944
-	} else if(empty($config_si_location)) {
3945
-		if(isset($argv[0]) && is_file($argv[0]))
3946
-		{
3947
-			$php_file = $argv[0];
3948
-			$p_info = pathinfo($php_file);
3949
-			$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ?  $p_info['dirname'] . DIRECTORY_SEPARATOR : '';
3950
-			$config_si_location = $php_dir . 'config_si.php';
3951
-		}
3952
-	}
3926
+        include($config_location);
3927
+        if(empty($sugar_config))
3928
+        {
3929
+                if($write_to_upgrade_log)
3930
+            {
3931
+                logThis('config.php contents are empty.  Skip merging.', $path);
3932
+            }
3933
+                return false;
3934
+        }
3935
+    }
3953 3936
 
3954
-	//If config_si_location is still empty or if the file cannot be found, skip merging
3955
-	if(empty($config_si_location) || !file_exists($config_si_location))
3956
-	{
3957
-	   if($write_to_upgrade_log)
3958
-	   {
3959
-	      logThis('config_si.php file at (' . $config_si_location . ') could not be found.  Skip merging.', $path);
3960
-	   }
3961
-	   return false;
3962
-	} else {
3963
-	   if($write_to_upgrade_log)
3964
-	   {
3965
-	      logThis('Loading config_si.php file at (' . $config_si_location . ') for merging.', $path);
3966
-	   }
3967
-
3968
-	   include($config_si_location);
3969
-	   if(empty($sugar_config_si))
3970
-	   {
3971
-	      if($write_to_upgrade_log)
3972
-		  {
3973
-	   	     logThis('config_si.php contents are empty.  Skip merging.', $path);
3974
-		  }
3975
-	   	  return false;
3976
-	   }
3977
-	}
3937
+    if(!empty($config_si_location) && !file_exists($config_si_location))
3938
+    {
3939
+        if($write_to_upgrade_log)
3940
+        {
3941
+            logThis('config_si.php file specified in ' . $config_si_location . ' could not be found.  Skip merging', $path);
3942
+        }
3943
+        return false;
3944
+    } else if(empty($config_si_location)) {
3945
+        if(isset($argv[0]) && is_file($argv[0]))
3946
+        {
3947
+            $php_file = $argv[0];
3948
+            $p_info = pathinfo($php_file);
3949
+            $php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ?  $p_info['dirname'] . DIRECTORY_SEPARATOR : '';
3950
+            $config_si_location = $php_dir . 'config_si.php';
3951
+        }
3952
+    }
3978 3953
 
3979
-	//Now perform the merge operation
3980
-	$modified = false;
3981
-	foreach($sugar_config_si as $key=>$value)
3982
-	{
3983
-		if(!preg_match('/^setup_/', $key) && !isset($sugar_config[$key]))
3984
-		{
3985
-		   if($write_to_upgrade_log)
3986
-		   {
3987
-		      logThis('Merge key (' . $key . ') with value (' . $value . ')', $path);
3988
-		   }
3989
-		   $sugar_config[$key] = $value;
3990
-		   $modified = true;
3991
-		}
3992
-	}
3954
+    //If config_si_location is still empty or if the file cannot be found, skip merging
3955
+    if(empty($config_si_location) || !file_exists($config_si_location))
3956
+    {
3957
+        if($write_to_upgrade_log)
3958
+        {
3959
+            logThis('config_si.php file at (' . $config_si_location . ') could not be found.  Skip merging.', $path);
3960
+        }
3961
+        return false;
3962
+    } else {
3963
+        if($write_to_upgrade_log)
3964
+        {
3965
+            logThis('Loading config_si.php file at (' . $config_si_location . ') for merging.', $path);
3966
+        }
3993 3967
 
3994
-	if($modified)
3995
-	{
3996
-		if($write_to_upgrade_log)
3997
-		{
3998
-	       logThis('Update config.php file with new values', $path);
3999
-		}
3968
+        include($config_si_location);
3969
+        if(empty($sugar_config_si))
3970
+        {
3971
+            if($write_to_upgrade_log)
3972
+            {
3973
+                logThis('config_si.php contents are empty.  Skip merging.', $path);
3974
+            }
3975
+                return false;
3976
+        }
3977
+    }
4000 3978
 
4001
-	    if(!write_array_to_file("sugar_config", $sugar_config, $config_location)) {
4002
-	       if($write_to_upgrade_log)
4003
-		   {
4004
-	    	  logThis('*** ERROR: could not write to config.php', $path);
4005
-		   }
4006
-		   return false;
4007
-		}
4008
-	} else {
4009
-	   if($write_to_upgrade_log)
4010
-	   {
4011
-	      logThis('config.php values are in sync with config_si.php values.  Skipped merging.', $path);
4012
-	   }
4013
-	   return false;
4014
-	}
3979
+    //Now perform the merge operation
3980
+    $modified = false;
3981
+    foreach($sugar_config_si as $key=>$value)
3982
+    {
3983
+        if(!preg_match('/^setup_/', $key) && !isset($sugar_config[$key]))
3984
+        {
3985
+            if($write_to_upgrade_log)
3986
+            {
3987
+                logThis('Merge key (' . $key . ') with value (' . $value . ')', $path);
3988
+            }
3989
+            $sugar_config[$key] = $value;
3990
+            $modified = true;
3991
+        }
3992
+    }
4015 3993
 
4016
-	if($write_to_upgrade_log)
4017
-	{
4018
-	   logThis('End merge_config_si_settings', $path);
4019
-	}
4020
-	return true;
3994
+    if($modified)
3995
+    {
3996
+        if($write_to_upgrade_log)
3997
+        {
3998
+            logThis('Update config.php file with new values', $path);
3999
+        }
4000
+
4001
+        if(!write_array_to_file("sugar_config", $sugar_config, $config_location)) {
4002
+            if($write_to_upgrade_log)
4003
+            {
4004
+                logThis('*** ERROR: could not write to config.php', $path);
4005
+            }
4006
+            return false;
4007
+        }
4008
+    } else {
4009
+        if($write_to_upgrade_log)
4010
+        {
4011
+            logThis('config.php values are in sync with config_si.php values.  Skipped merging.', $path);
4012
+        }
4013
+        return false;
4014
+    }
4015
+
4016
+    if($write_to_upgrade_log)
4017
+    {
4018
+        logThis('End merge_config_si_settings', $path);
4019
+    }
4020
+    return true;
4021 4021
 }
4022 4022
 
4023 4023
 
@@ -4032,7 +4032,7 @@  discard block
 block discarded – undo
4032 4032
     remove_linkedin_config();
4033 4033
 
4034 4034
     if(!ConnectorUtils::updateMetaDataFiles()) {
4035
-       $GLOBALS['log']->fatal('Cannot update metadata files for connectors');
4035
+        $GLOBALS['log']->fatal('Cannot update metadata files for connectors');
4036 4036
     }
4037 4037
 
4038 4038
     //Delete the custom connectors.php file if it exists so that it may be properly rebuilt
@@ -4275,10 +4275,10 @@  discard block
 block discarded – undo
4275 4275
  */
4276 4276
 function add_unified_search_to_custom_modules_vardefs()
4277 4277
 {
4278
-	if(file_exists($cachefile = sugar_cached('modules/unified_search_modules.php')))
4279
-	{
4280
-	   unlink($cachefile);
4281
-	}
4278
+    if(file_exists($cachefile = sugar_cached('modules/unified_search_modules.php')))
4279
+    {
4280
+        unlink($cachefile);
4281
+    }
4282 4282
 
4283 4283
 }
4284 4284
 
@@ -4287,51 +4287,51 @@  discard block
 block discarded – undo
4287 4287
  */
4288 4288
 function upgradeSugarCache($file)
4289 4289
 {
4290
-	global $sugar_config;
4291
-	$cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp'));
4290
+    global $sugar_config;
4291
+    $cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp'));
4292 4292
 
4293
-	unzip($file, $cacheUploadUpgradesTemp);
4293
+    unzip($file, $cacheUploadUpgradesTemp);
4294 4294
 
4295
-	if(!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
4296
-		logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
4297
-		return;
4298
-	} else {
4299
-		include(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"));
4300
-	}
4295
+    if(!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
4296
+        logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
4297
+        return;
4298
+    } else {
4299
+        include(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"));
4300
+    }
4301 4301
 
4302
-	$from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
4303
-	$allFiles = array();
4304
-	if(file_exists("$from_dir/include/SugarCache")) {
4305
-		$allFiles = findAllFiles("$from_dir/include/SugarCache", $allFiles);
4306
-	}
4307
-	if(file_exists("$from_dir/include/database")) {
4308
-		$allFiles = findAllFiles("$from_dir/include/database", $allFiles);
4309
-	}
4310
-	if(file_exists("$from_dir/include/utils/external_cache.php")) {
4311
-		$allFiles[] = "$from_dir/include/utils/external_cache.php";
4312
-	}
4313
-	if(file_exists("$from_dir/include/utils/sugar_file_utils.php")) {
4314
-		$allFiles[] = "$from_dir/include/utils/sugar_file_utils.php";
4315
-	}
4316
-	if(file_exists("$from_dir/include/utils/sugar_file_utils.php")) {
4317
-		$allFiles[] = "$from_dir/include/utils/sugar_file_utils.php";
4318
-	}
4319
-	if(file_exists("$from_dir/include/utils/autoloader.php")) {
4320
-		$allFiles[] = "$from_dir/include/utils/autoloader.php";
4321
-	}
4302
+    $from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
4303
+    $allFiles = array();
4304
+    if(file_exists("$from_dir/include/SugarCache")) {
4305
+        $allFiles = findAllFiles("$from_dir/include/SugarCache", $allFiles);
4306
+    }
4307
+    if(file_exists("$from_dir/include/database")) {
4308
+        $allFiles = findAllFiles("$from_dir/include/database", $allFiles);
4309
+    }
4310
+    if(file_exists("$from_dir/include/utils/external_cache.php")) {
4311
+        $allFiles[] = "$from_dir/include/utils/external_cache.php";
4312
+    }
4313
+    if(file_exists("$from_dir/include/utils/sugar_file_utils.php")) {
4314
+        $allFiles[] = "$from_dir/include/utils/sugar_file_utils.php";
4315
+    }
4316
+    if(file_exists("$from_dir/include/utils/sugar_file_utils.php")) {
4317
+        $allFiles[] = "$from_dir/include/utils/sugar_file_utils.php";
4318
+    }
4319
+    if(file_exists("$from_dir/include/utils/autoloader.php")) {
4320
+        $allFiles[] = "$from_dir/include/utils/autoloader.php";
4321
+    }
4322 4322
 
4323
-	foreach($allFiles as $k => $file) {
4324
-		$destFile = str_replace($from_dir."/", "", $file);
4325
-       if(!is_dir(dirname($destFile))) {
4326
-			mkdir_recursive(dirname($destFile)); // make sure the directory exists
4327
-		}
4328
-		if ( stristr($file,'uw_main.tpl') )
4323
+    foreach($allFiles as $k => $file) {
4324
+        $destFile = str_replace($from_dir."/", "", $file);
4325
+        if(!is_dir(dirname($destFile))) {
4326
+            mkdir_recursive(dirname($destFile)); // make sure the directory exists
4327
+        }
4328
+        if ( stristr($file,'uw_main.tpl') )
4329 4329
             logThis('Skipping "'.$file.'" - file copy will during commit step.');
4330 4330
         else {
4331 4331
             logThis('updating UpgradeWizard code: '.$destFile);
4332 4332
             copy_recursive($file, $destFile);
4333 4333
         }
4334
-	}
4334
+    }
4335 4335
 }
4336 4336
 
4337 4337
 /**
@@ -4342,10 +4342,10 @@  discard block
 block discarded – undo
4342 4342
  */
4343 4343
 function unlinkUpgradeFiles($version)
4344 4344
 {
4345
-	if(!isset($version))
4346
-	{
4347
-	   return;
4348
-	}
4345
+    if(!isset($version))
4346
+    {
4347
+        return;
4348
+    }
4349 4349
 
4350 4350
     //First check if we even have the scripts_for_patch/files_to_remove directory
4351 4351
     require_once('modules/UpgradeWizard/UpgradeRemoval.php');
@@ -4362,18 +4362,18 @@  discard block
 block discarded – undo
4362 4362
 
4363 4363
     if(isset($_SESSION['unzip_dir']) && file_exists($_SESSION['unzip_dir'].'/scripts/files_to_remove'))
4364 4364
     {
4365
-       $files_to_remove = glob($_SESSION['unzip_dir'].'/scripts/files_to_remove/*.php');
4366
-
4367
-       foreach($files_to_remove as $script)
4368
-       {
4369
-       		if(preg_match('/UpgradeRemoval(\d+)x\.php/', $script, $matches))
4370
-       		{
4371
-       	   	   $upgradeClass = 'UpgradeRemoval' . $matches[1] . 'x';
4372
-       	   	   require_once($_SESSION['unzip_dir'].'/scripts/files_to_remove/' . $upgradeClass . '.php');
4373
-               if (class_exists($upgradeClass) == false)
4374
-               {
4375
-                   continue;
4376
-               }
4365
+        $files_to_remove = glob($_SESSION['unzip_dir'].'/scripts/files_to_remove/*.php');
4366
+
4367
+        foreach($files_to_remove as $script)
4368
+        {
4369
+                if(preg_match('/UpgradeRemoval(\d+)x\.php/', $script, $matches))
4370
+                {
4371
+                        $upgradeClass = 'UpgradeRemoval' . $matches[1] . 'x';
4372
+                        require_once($_SESSION['unzip_dir'].'/scripts/files_to_remove/' . $upgradeClass . '.php');
4373
+                if (class_exists($upgradeClass) == false)
4374
+                {
4375
+                    continue;
4376
+                }
4377 4377
 
4378 4378
                 //Check to make sure we should load and run this UpgradeRemoval instance
4379 4379
                 $upgradeInstance = new $upgradeClass();
@@ -4384,45 +4384,45 @@  discard block
 block discarded – undo
4384 4384
                     $files = $upgradeInstance->getFilesToRemove($version);
4385 4385
                     foreach($files as $file)
4386 4386
                     {
4387
-                       logThis($file);
4387
+                        logThis($file);
4388 4388
                     }
4389 4389
                     $upgradeInstance->processFilesToRemove($files);
4390 4390
                 }
4391
-       	    }
4392
-       }
4391
+                }
4392
+        }
4393 4393
     }
4394 4394
 
4395 4395
     //Check if we have a custom directory
4396 4396
     if(file_exists('custom/scripts/files_to_remove'))
4397 4397
     {
4398
-       //Now find
4399
-       $files_to_remove = glob('custom/scripts/files_to_remove/*.php');
4400
-
4401
-       foreach($files_to_remove as $script)
4402
-       {
4403
-       	   if(preg_match('/\/files_to_remove\/(.*?)\.php$/', $script, $matches))
4404
-       	   {
4405
-       	   	   require_once($script);
4406
-       	   	   $upgradeClass  = $matches[1];
4407
-
4408
-       	   	   if(!class_exists($upgradeClass))
4409
-       	   	   {
4410
-       	   	   	  continue;
4411
-       	   	   }
4412
-
4413
-       	   	   $upgradeInstance = new $upgradeClass();
4414
-       	   	   if($upgradeInstance instanceof UpgradeRemoval)
4415
-       	   	   {
4416
-       	   	   	  	  logThis('Running Custom UpgradeRemoval instance ' . $upgradeClass);
4417
-	       	   	   	  $files = $upgradeInstance->getFilesToRemove($version);
4418
-	       	   	   	  foreach($files as $file)
4419
-	       	   	   	  {
4420
-	       	   	   	  	 logThis($file);
4421
-	       	   	   	  }
4422
-	       	   	   	  $upgradeInstance->processFilesToRemove($files);
4423
-       	   	   }
4424
-       	   }
4425
-       }
4398
+        //Now find
4399
+        $files_to_remove = glob('custom/scripts/files_to_remove/*.php');
4400
+
4401
+        foreach($files_to_remove as $script)
4402
+        {
4403
+                if(preg_match('/\/files_to_remove\/(.*?)\.php$/', $script, $matches))
4404
+                {
4405
+                        require_once($script);
4406
+                        $upgradeClass  = $matches[1];
4407
+
4408
+                        if(!class_exists($upgradeClass))
4409
+                        {
4410
+                            continue;
4411
+                        }
4412
+
4413
+                        $upgradeInstance = new $upgradeClass();
4414
+                        if($upgradeInstance instanceof UpgradeRemoval)
4415
+                        {
4416
+                                    logThis('Running Custom UpgradeRemoval instance ' . $upgradeClass);
4417
+                                $files = $upgradeInstance->getFilesToRemove($version);
4418
+                                foreach($files as $file)
4419
+                                {
4420
+                                    logThis($file);
4421
+                                }
4422
+                                $upgradeInstance->processFilesToRemove($files);
4423
+                        }
4424
+                }
4425
+        }
4426 4426
     }
4427 4427
 
4428 4428
 }
@@ -4436,7 +4436,7 @@  discard block
 block discarded – undo
4436 4436
      * @param string $ensureUnique
4437 4437
      * @return string Valid column name trimmed to right length and with invalid characters removed
4438 4438
      */
4439
-     function getValidDBName ($name, $ensureUnique = false, $maxLen = 30)
4439
+        function getValidDBName ($name, $ensureUnique = false, $maxLen = 30)
4440 4440
     {
4441 4441
         // first strip any invalid characters - all but alphanumerics and -
4442 4442
         $name = preg_replace ( '/[^\w-]+/i', '', $name ) ;
@@ -4485,10 +4485,10 @@  discard block
 block discarded – undo
4485 4485
 function whetherNeedToSkipDir($dir, $skipDirs)
4486 4486
 {
4487 4487
     foreach($skipDirs as $skipMe) {
4488
-		if(strpos( clean_path($dir), $skipMe ) !== false) {
4489
-			return true;
4490
-		}
4491
-	}
4488
+        if(strpos( clean_path($dir), $skipMe ) !== false) {
4489
+            return true;
4490
+        }
4491
+    }
4492 4492
     return false;
4493 4493
 }
4494 4494
 
@@ -4523,21 +4523,21 @@  discard block
 block discarded – undo
4523 4523
         closedir($dh);
4524 4524
     }
4525 4525
 
4526
-     // add all theme custom image directories
4526
+        // add all theme custom image directories
4527 4527
     $custom_themes_dir = "custom/themes";
4528 4528
     if (is_dir($custom_themes_dir)) {
4529
-         if($dh = opendir($custom_themes_dir))
4530
-         {
4531
-             while (($dir = readdir($dh)) !== false)
4532
-             {
4533
-                 //Since the custom theme directories don't require an images directory
4534
-                 // we check for it implicitly
4535
-                 if ($dir != "." && $dir != ".." && is_dir('custom/themes/'.$dir."/images")) {
4536
-                     $sb->addDirectory($dir, "custom/themes/{$dir}/images");
4537
-                 }
4538
-             }
4539
-             closedir($dh);
4540
-         }
4529
+            if($dh = opendir($custom_themes_dir))
4530
+            {
4531
+                while (($dir = readdir($dh)) !== false)
4532
+                {
4533
+                    //Since the custom theme directories don't require an images directory
4534
+                    // we check for it implicitly
4535
+                    if ($dir != "." && $dir != ".." && is_dir('custom/themes/'.$dir."/images")) {
4536
+                        $sb->addDirectory($dir, "custom/themes/{$dir}/images");
4537
+                    }
4538
+                }
4539
+                closedir($dh);
4540
+            }
4541 4541
     }
4542 4542
 
4543 4543
     // generate the sprite goodies
@@ -4558,40 +4558,40 @@  discard block
 block discarded – undo
4558 4558
  */
4559 4559
 function repairSearchFields($globString='modules/*/metadata/SearchFields.php', $path='')
4560 4560
 {
4561
-	if(!empty($path))
4562
-	{
4563
-		logThis('Begin repairSearchFields', $path);
4564
-	}
4561
+    if(!empty($path))
4562
+    {
4563
+        logThis('Begin repairSearchFields', $path);
4564
+    }
4565 4565
 
4566
-	require_once('include/dir_inc.php');
4567
-	require_once('modules/DynamicFields/templates/Fields/TemplateRange.php');
4568
-	require('include/modules.php');
4569
-
4570
-	global $beanList;
4571
-	$searchFieldsFiles = glob($globString);
4572
-
4573
-	foreach($searchFieldsFiles as $file)
4574
-	{
4575
-		if(preg_match('/modules\/(.*?)\/metadata\/SearchFields\.php/', $file, $matches) && isset($beanList[$matches[1]]))
4576
-		{
4577
-			$module = $matches[1];
4578
-			$beanName = $beanList[$module];
4579
-			VardefManager::loadVardef($module, $beanName);
4580
-			if(isset($GLOBALS['dictionary'][$beanName]['fields']))
4581
-			{
4582
-				if(!empty($path))
4583
-				{
4584
-					logThis('Calling TemplateRange::repairCustomSearchFields for module ' . $module, $path);
4585
-				}
4586
-				TemplateRange::repairCustomSearchFields($GLOBALS['dictionary'][$beanName]['fields'], $module);
4587
-			}
4588
-		}
4589
-	}
4566
+    require_once('include/dir_inc.php');
4567
+    require_once('modules/DynamicFields/templates/Fields/TemplateRange.php');
4568
+    require('include/modules.php');
4590 4569
 
4591
-	if(!empty($path))
4592
-	{
4593
-		logThis('End repairSearchFields', $path);
4594
-	}
4570
+    global $beanList;
4571
+    $searchFieldsFiles = glob($globString);
4572
+
4573
+    foreach($searchFieldsFiles as $file)
4574
+    {
4575
+        if(preg_match('/modules\/(.*?)\/metadata\/SearchFields\.php/', $file, $matches) && isset($beanList[$matches[1]]))
4576
+        {
4577
+            $module = $matches[1];
4578
+            $beanName = $beanList[$module];
4579
+            VardefManager::loadVardef($module, $beanName);
4580
+            if(isset($GLOBALS['dictionary'][$beanName]['fields']))
4581
+            {
4582
+                if(!empty($path))
4583
+                {
4584
+                    logThis('Calling TemplateRange::repairCustomSearchFields for module ' . $module, $path);
4585
+                }
4586
+                TemplateRange::repairCustomSearchFields($GLOBALS['dictionary'][$beanName]['fields'], $module);
4587
+            }
4588
+        }
4589
+    }
4590
+
4591
+    if(!empty($path))
4592
+    {
4593
+        logThis('End repairSearchFields', $path);
4594
+    }
4595 4595
 }
4596 4596
 
4597 4597
 /**
Please login to merge, or discard this patch.
modules/ProjectTask/views/view.list.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 require_once('include/MVC/View/views/view.list.php');
52 52
 
53
-class ProjectTaskViewList extends ViewList{
54
- 	function __construct(){
53
+class ProjectTaskViewList extends ViewList {
54
+ 	function __construct() {
55 55
  		parent::__construct();
56 56
 
57 57
  	}
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
61 61
      */
62
-    function ProjectTaskViewList(){
62
+    function ProjectTaskViewList() {
63 63
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
64
-        if(isset($GLOBALS['log'])) {
64
+        if (isset($GLOBALS['log'])) {
65 65
             $GLOBALS['log']->deprecated($deprecatedMessage);
66 66
         }
67 67
         else {
@@ -71,48 +71,48 @@  discard block
 block discarded – undo
71 71
     }
72 72
 
73 73
 
74
- 	function display(){
75
- 		if(!$this->bean->ACLAccess('list')){
74
+ 	function display() {
75
+ 		if (!$this->bean->ACLAccess('list')) {
76 76
  			ACLController::displayNoAccess();
77 77
  			return;
78 78
  		}
79 79
         $module = $GLOBALS['module'];
80 80
  	    $metadataFile = null;
81 81
         $foundViewDefs = false;
82
-        if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
83
-            $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
82
+        if (file_exists('custom/modules/'.$module.'/metadata/listviewdefs.php')) {
83
+            $metadataFile = 'custom/modules/'.$module.'/metadata/listviewdefs.php';
84 84
             $foundViewDefs = true;
85
-        }else{
86
-            if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
85
+        } else {
86
+            if (file_exists('custom/modules/'.$module.'/metadata/metafiles.php')) {
87 87
                 require_once('custom/modules/'.$module.'/metadata/metafiles.php');
88
-                if(!empty($metafiles[$module]['listviewdefs'])){
88
+                if (!empty($metafiles[$module]['listviewdefs'])) {
89 89
                     $metadataFile = $metafiles[$module]['listviewdefs'];
90 90
                     $foundViewDefs = true;
91 91
                 }
92
-            }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
92
+            }elseif (file_exists('modules/'.$module.'/metadata/metafiles.php')) {
93 93
                 require_once('modules/'.$module.'/metadata/metafiles.php');
94
-                if(!empty($metafiles[$module]['listviewdefs'])){
94
+                if (!empty($metafiles[$module]['listviewdefs'])) {
95 95
                     $metadataFile = $metafiles[$module]['listviewdefs'];
96 96
                     $foundViewDefs = true;
97 97
                 }
98 98
             }
99 99
         }
100
-        if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
100
+        if (!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')) {
101 101
                 $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
102 102
         }
103 103
         require_once($metadataFile);
104 104
 
105 105
 		$seed = $this->bean;
106
-        if(!empty($this->bean->object_name) && isset($_REQUEST[$module.'2_'.strtoupper($this->bean->object_name).'_offset'])) {//if you click the pagination button, it will populate the search criteria here
107
-            if(!empty($_REQUEST['current_query_by_page'])) {//The code support multi browser tabs pagination
106
+        if (!empty($this->bean->object_name) && isset($_REQUEST[$module.'2_'.strtoupper($this->bean->object_name).'_offset'])) {//if you click the pagination button, it will populate the search criteria here
107
+            if (!empty($_REQUEST['current_query_by_page'])) {//The code support multi browser tabs pagination
108 108
                 $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'request_data', 'current_query_by_page', $module.'2_'.strtoupper($this->bean->object_name).'_ORDER_BY');
109
-		        if(isset($_REQUEST['lvso'])){
109
+		        if (isset($_REQUEST['lvso'])) {
110 110
 		        	$blockVariables[] = 'lvso';
111 111
 		        }
112 112
 
113 113
                 $current_query_by_page = sugar_unserialize(base64_decode($_REQUEST['current_query_by_page']));
114
-                foreach($current_query_by_page as $search_key=>$search_value) {
115
-                    if($search_key != $module.'2_'.strtoupper($this->bean->object_name).'_offset' && !in_array($search_key, $blockVariables)) {
114
+                foreach ($current_query_by_page as $search_key=>$search_value) {
115
+                    if ($search_key != $module.'2_'.strtoupper($this->bean->object_name).'_offset' && !in_array($search_key, $blockVariables)) {
116 116
                         if (!is_array($search_value)) {
117 117
                             $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value);
118 118
                         }
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
             }
128 128
         }
129 129
 
130
-        if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
131
-            if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
130
+        if (!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') {
131
+            if (empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query'] != 'true')) {
132 132
                 $this->saved_search = loadBean('SavedSearch');
133 133
                 $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
134 134
                 $this->saved_search->populateRequest();
135 135
             }
136
-            elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
136
+            elseif (!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
137 137
                 $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
138 138
                 unset($_REQUEST['saved_search_select']);
139 139
                 unset($_REQUEST['saved_search_select_name']);
@@ -142,25 +142,25 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$lv = new ListViewSmarty();
144 144
 		$displayColumns = array();
145
-		if(!empty($_REQUEST['displayColumns'])) {
146
-		    foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
147
-		        if(!empty($listViewDefs[$module][$col]))
145
+		if (!empty($_REQUEST['displayColumns'])) {
146
+		    foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
147
+		        if (!empty($listViewDefs[$module][$col]))
148 148
 		            $displayColumns[$col] = $listViewDefs[$module][$col];
149 149
 		    }
150 150
 		}
151 151
 		else {
152
-		    foreach($listViewDefs[$module] as $col => $params) {
153
-		        if(!empty($params['default']) && $params['default'])
152
+		    foreach ($listViewDefs[$module] as $col => $params) {
153
+		        if (!empty($params['default']) && $params['default'])
154 154
 		            $displayColumns[$col] = $params;
155 155
 		    }
156 156
 		}
157 157
 
158
-        $params = array( 'massupdate' => true, 'export' => true);
158
+        $params = array('massupdate' => true, 'export' => true);
159 159
 
160
-		if(!empty($_REQUEST['orderBy'])) {
160
+		if (!empty($_REQUEST['orderBy'])) {
161 161
 		    $params['orderBy'] = $_REQUEST['orderBy'];
162 162
 		    $params['overrideOrder'] = true;
163
-		    if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
163
+		    if (!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
164 164
 		}
165 165
 		$lv->displayColumns = $displayColumns;
166 166
 
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 
170 170
 		$searchForm = null;
171 171
 	 	$storeQuery = new StoreQuery();
172
-		if(!isset($_REQUEST['query'])){
172
+		if (!isset($_REQUEST['query'])) {
173 173
 			$storeQuery->loadQuery($this->module);
174 174
 			$storeQuery->populateRequest();
175
-		}else{
175
+		} else {
176 176
 			$storeQuery->saveFromRequest($this->module);
177 177
 		}
178 178
 
179 179
 		//search
180 180
 		$view = 'basic_search';
181
-		if(!empty($_REQUEST['search_form_view']))
181
+		if (!empty($_REQUEST['search_form_view']))
182 182
 			$view = $_REQUEST['search_form_view'];
183 183
 		$headers = true;
184
-		if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
184
+		if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
185 185
 			$headers = false;
186
-		elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
187
-        	if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
186
+		elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
187
+        	if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
188 188
 				$view = 'advanced_search';
189
-			}else {
189
+			} else {
190 190
 				$view = 'basic_search';
191 191
 			}
192 192
 		}
193 193
 
194 194
 		$use_old_search = true;
195
-		if(file_exists('modules/'.$this->module.'/SearchForm.html')){
195
+		if (file_exists('modules/'.$this->module.'/SearchForm.html')) {
196 196
 			require_once('include/SearchForm/SearchForm.php');
197 197
 			$searchForm = new SearchForm($this->module, $this->seed);
198
-		}else{
198
+		} else {
199 199
 			$use_old_search = false;
200 200
 			require_once('include/SearchForm/SearchForm2.php');
201 201
 
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 			}
215 215
 
216 216
 
217
-			if(!empty($metafiles[$this->module]['searchfields']))
217
+			if (!empty($metafiles[$this->module]['searchfields']))
218 218
                 require($metafiles[$this->module]['searchfields']);
219
-			elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
219
+			elseif (file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
220 220
                 require('modules/'.$this->module.'/metadata/SearchFields.php');
221 221
 
222 222
 
@@ -225,27 +225,27 @@  discard block
 block discarded – undo
225 225
 			$searchForm->lv = $lv;
226 226
 		}
227 227
 
228
-		if(isset($this->options['show_title']) && $this->options['show_title']) {
228
+		if (isset($this->options['show_title']) && $this->options['show_title']) {
229 229
 			$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
230 230
 			echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
231 231
 		}
232 232
 
233 233
 		$where = '';
234
-		if(isset($_REQUEST['query']))
234
+		if (isset($_REQUEST['query']))
235 235
 		{
236 236
 			// we have a query
237
-	    	if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
237
+	    	if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
238 238
 	       		$searchForm->populateFromArray($storeQuery->query);
239 239
 	    	}
240 240
 	    	else {
241 241
                 $searchForm->populateFromRequest();
242 242
 	    	}
243 243
 			$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
244
-			if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
244
+			if (count($where_clauses) > 0)$where = '('.implode(' ) AND ( ', $where_clauses).')';
245 245
 			$GLOBALS['log']->info("List View Where Clause: $where");
246 246
 		}
247
-		if($use_old_search){
248
-			switch($view) {
247
+		if ($use_old_search) {
248
+			switch ($view) {
249 249
 				case 'basic_search':
250 250
 			    	$searchForm->setup();
251 251
 			        $searchForm->displayBasic($headers);
@@ -258,19 +258,19 @@  discard block
 block discarded – undo
258 258
 			     	echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
259 259
 			       break;
260 260
 			}
261
-		}else{
261
+		} else {
262 262
 			echo $searchForm->display($headers);
263 263
 		}
264
-		if(!$headers)
264
+		if (!$headers)
265 265
 			return;
266 266
          /*
267 267
          * Bug 50575 - related search columns not inluded in query in a proper way
268 268
          */
269 269
          $lv->searchColumns = $searchForm->searchColumns;
270 270
 
271
-		if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
271
+		if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
272 272
             //Bug 58841 - mass update form was not displayed for non-admin users that should have access
273
-            if(ACLController::checkAccess($module, 'massupdate') || ACLController::checkAccess($module, 'export'))
273
+            if (ACLController::checkAccess($module, 'massupdate') || ACLController::checkAccess($module, 'export'))
274 274
             {
275 275
                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
276 276
             }
Please login to merge, or discard this patch.
Braces   +43 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 /*********************************************************************************
5 7
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -63,8 +65,7 @@  discard block
 block discarded – undo
63 65
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
64 66
         if(isset($GLOBALS['log'])) {
65 67
             $GLOBALS['log']->deprecated($deprecatedMessage);
66
-        }
67
-        else {
68
+        } else {
68 69
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
69 70
         }
70 71
         self::__construct();
@@ -82,14 +83,14 @@  discard block
 block discarded – undo
82 83
         if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
83 84
             $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
84 85
             $foundViewDefs = true;
85
-        }else{
86
+        } else{
86 87
             if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
87 88
                 require_once('custom/modules/'.$module.'/metadata/metafiles.php');
88 89
                 if(!empty($metafiles[$module]['listviewdefs'])){
89 90
                     $metadataFile = $metafiles[$module]['listviewdefs'];
90 91
                     $foundViewDefs = true;
91 92
                 }
92
-            }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
93
+            } elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
93 94
                 require_once('modules/'.$module.'/metadata/metafiles.php');
94 95
                 if(!empty($metafiles[$module]['listviewdefs'])){
95 96
                     $metadataFile = $metafiles[$module]['listviewdefs'];
@@ -115,8 +116,7 @@  discard block
 block discarded – undo
115 116
                     if($search_key != $module.'2_'.strtoupper($this->bean->object_name).'_offset' && !in_array($search_key, $blockVariables)) {
116 117
                         if (!is_array($search_value)) {
117 118
                             $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value);
118
-                        }
119
-                        else {
119
+                        } else {
120 120
                             foreach ($search_value as $key=>&$val) {
121 121
                                 $val = $GLOBALS['db']->quote($val);
122 122
                             }
@@ -132,8 +132,7 @@  discard block
 block discarded – undo
132 132
                 $this->saved_search = loadBean('SavedSearch');
133 133
                 $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
134 134
                 $this->saved_search->populateRequest();
135
-            }
136
-            elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
135
+            } elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
137 136
                 $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
138 137
                 unset($_REQUEST['saved_search_select']);
139 138
                 unset($_REQUEST['saved_search_select_name']);
@@ -144,14 +143,15 @@  discard block
 block discarded – undo
144 143
 		$displayColumns = array();
145 144
 		if(!empty($_REQUEST['displayColumns'])) {
146 145
 		    foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
147
-		        if(!empty($listViewDefs[$module][$col]))
148
-		            $displayColumns[$col] = $listViewDefs[$module][$col];
146
+		        if(!empty($listViewDefs[$module][$col])) {
147
+		        		            $displayColumns[$col] = $listViewDefs[$module][$col];
148
+		        }
149 149
 		    }
150
-		}
151
-		else {
150
+		} else {
152 151
 		    foreach($listViewDefs[$module] as $col => $params) {
153
-		        if(!empty($params['default']) && $params['default'])
154
-		            $displayColumns[$col] = $params;
152
+		        if(!empty($params['default']) && $params['default']) {
153
+		        		            $displayColumns[$col] = $params;
154
+		        }
155 155
 		    }
156 156
 		}
157 157
 
@@ -160,7 +160,9 @@  discard block
 block discarded – undo
160 160
 		if(!empty($_REQUEST['orderBy'])) {
161 161
 		    $params['orderBy'] = $_REQUEST['orderBy'];
162 162
 		    $params['overrideOrder'] = true;
163
-		    if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
163
+		    if(!empty($_REQUEST['sortOrder'])) {
164
+		        $params['sortOrder'] = $_REQUEST['sortOrder'];
165
+		    }
164 166
 		}
165 167
 		$lv->displayColumns = $displayColumns;
166 168
 
@@ -172,21 +174,22 @@  discard block
 block discarded – undo
172 174
 		if(!isset($_REQUEST['query'])){
173 175
 			$storeQuery->loadQuery($this->module);
174 176
 			$storeQuery->populateRequest();
175
-		}else{
177
+		} else{
176 178
 			$storeQuery->saveFromRequest($this->module);
177 179
 		}
178 180
 
179 181
 		//search
180 182
 		$view = 'basic_search';
181
-		if(!empty($_REQUEST['search_form_view']))
182
-			$view = $_REQUEST['search_form_view'];
183
+		if(!empty($_REQUEST['search_form_view'])) {
184
+					$view = $_REQUEST['search_form_view'];
185
+		}
183 186
 		$headers = true;
184
-		if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
185
-			$headers = false;
186
-		elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
187
+		if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
188
+					$headers = false;
189
+		} elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
187 190
         	if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
188 191
 				$view = 'advanced_search';
189
-			}else {
192
+			} else {
190 193
 				$view = 'basic_search';
191 194
 			}
192 195
 		}
@@ -195,7 +198,7 @@  discard block
 block discarded – undo
195 198
 		if(file_exists('modules/'.$this->module.'/SearchForm.html')){
196 199
 			require_once('include/SearchForm/SearchForm.php');
197 200
 			$searchForm = new SearchForm($this->module, $this->seed);
198
-		}else{
201
+		} else{
199 202
 			$use_old_search = false;
200 203
 			require_once('include/SearchForm/SearchForm2.php');
201 204
 
@@ -203,21 +206,20 @@  discard block
 block discarded – undo
203 206
 			if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
204 207
 			{
205 208
 			    require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
206
-			}
207
-			elseif (!empty($metafiles[$this->module]['searchdefs']))
209
+			} elseif (!empty($metafiles[$this->module]['searchdefs']))
208 210
 			{
209 211
 				require_once($metafiles[$this->module]['searchdefs']);
210
-			}
211
-			elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
212
+			} elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
212 213
 			{
213 214
 			    require_once('modules/'.$this->module.'/metadata/searchdefs.php');
214 215
 			}
215 216
 
216 217
 
217
-			if(!empty($metafiles[$this->module]['searchfields']))
218
-                require($metafiles[$this->module]['searchfields']);
219
-			elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
220
-                require('modules/'.$this->module.'/metadata/SearchFields.php');
218
+			if(!empty($metafiles[$this->module]['searchfields'])) {
219
+			                require($metafiles[$this->module]['searchfields']);
220
+			} elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
221
+			                require('modules/'.$this->module.'/metadata/SearchFields.php');
222
+			}
221 223
 
222 224
 
223 225
 			$searchForm = new SearchForm($this->seed, $this->module, $this->action);
@@ -236,12 +238,13 @@  discard block
 block discarded – undo
236 238
 			// we have a query
237 239
 	    	if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
238 240
 	       		$searchForm->populateFromArray($storeQuery->query);
239
-	    	}
240
-	    	else {
241
+	    	} else {
241 242
                 $searchForm->populateFromRequest();
242 243
 	    	}
243 244
 			$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
244
-			if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
245
+			if (count($where_clauses) > 0 ) {
246
+			    $where = '('. implode(' ) AND ( ', $where_clauses) . ')';
247
+			}
245 248
 			$GLOBALS['log']->info("List View Where Clause: $where");
246 249
 		}
247 250
 		if($use_old_search){
@@ -258,11 +261,12 @@  discard block
 block discarded – undo
258 261
 			     	echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
259 262
 			       break;
260 263
 			}
261
-		}else{
264
+		} else{
262 265
 			echo $searchForm->display($headers);
263 266
 		}
264
-		if(!$headers)
265
-			return;
267
+		if(!$headers) {
268
+					return;
269
+		}
266 270
          /*
267 271
          * Bug 50575 - related search columns not inluded in query in a proper way
268 272
          */
@@ -273,8 +277,7 @@  discard block
 block discarded – undo
273 277
             if(ACLController::checkAccess($module, 'massupdate') || ACLController::checkAccess($module, 'export'))
274 278
             {
275 279
                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
276
-            }
277
-            else
280
+            } else
278 281
             {
279 282
                 $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
280 283
             }
Please login to merge, or discard this patch.
modules/ProjectTask/Dashlets/MyProjectTaskDashlet/MyProjectTaskDashlet.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         parent::__construct($id, $def);
54 54
 
55
-        if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT_TASKS', 'ProjectTask');
55
+        if (empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT_TASKS', 'ProjectTask');
56 56
 
57 57
         $this->searchFields = $dashletData['MyProjectTaskDashlet']['searchFields'];
58 58
         $this->columns = $dashletData['MyProjectTaskDashlet']['columns'];
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
65 65
      */
66
-    function MyProjectTaskDashlet($id, $def = null){
66
+    function MyProjectTaskDashlet($id, $def = null) {
67 67
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
68
-        if(isset($GLOBALS['log'])) {
68
+        if (isset($GLOBALS['log'])) {
69 69
             $GLOBALS['log']->deprecated($deprecatedMessage);
70 70
         }
71 71
         else {
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $resultArray = parent::buildWhere();
81 81
 
82
-        $resultArray[] = $this->seedBean->table_name . '.' . "percent_complete != 100";
82
+        $resultArray[] = $this->seedBean->table_name.'.'."percent_complete != 100";
83 83
 
84 84
         return $resultArray;
85 85
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -52,7 +54,9 @@  discard block
 block discarded – undo
52 54
 
53 55
         parent::__construct($id, $def);
54 56
 
55
-        if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT_TASKS', 'ProjectTask');
57
+        if(empty($def['title'])) {
58
+            $this->title = translate('LBL_LIST_MY_PROJECT_TASKS', 'ProjectTask');
59
+        }
56 60
 
57 61
         $this->searchFields = $dashletData['MyProjectTaskDashlet']['searchFields'];
58 62
         $this->columns = $dashletData['MyProjectTaskDashlet']['columns'];
@@ -67,8 +71,7 @@  discard block
 block discarded – undo
67 71
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
68 72
         if(isset($GLOBALS['log'])) {
69 73
             $GLOBALS['log']->deprecated($deprecatedMessage);
70
-        }
71
-        else {
74
+        } else {
72 75
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
73 76
         }
74 77
         self::__construct($id, $def);
Please login to merge, or discard this patch.
modules/ProjectTask/ProjectTask.php 2 patches
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	/*
100 100
 	 *
101 101
 	 */
102
-    public function __construct($init=true)
102
+    public function __construct($init = true)
103 103
 	{
104 104
 		parent::__construct();
105 105
 		if ($init) {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			$this->utilization = 100;
108 108
 
109 109
 			global $current_user;
110
-			if(empty($current_user))
110
+			if (empty($current_user))
111 111
 			{
112 112
 				$this->assigned_user_id = 1;
113 113
 				$admin_user = new User();
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
     /**
127 127
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
128 128
      */
129
-    public function ProjectTask($init=true){
129
+    public function ProjectTask($init = true) {
130 130
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
131
-        if(isset($GLOBALS['log'])) {
131
+        if (isset($GLOBALS['log'])) {
132 132
             $GLOBALS['log']->deprecated($deprecatedMessage);
133 133
         }
134 134
         else {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         }
155 155
 
156 156
         $id = parent::save($check_notify);
157
-        if($this->_skipParentUpdate == false)
157
+        if ($this->_skipParentUpdate == false)
158 158
         {
159 159
             $this->updateStatistic();
160 160
         }
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 		$return_value = '';
213 213
 
214 214
 		$query  = "SELECT name, assigned_user_id FROM {$this->table_name} WHERE id='{$depends_on_id}'";
215
-		$result = $this->db->query($query,true," Error filling in additional detail fields: ");
215
+		$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
216 216
 		$row = $this->db->fetchByAssoc($result);
217
-		if($row != null)
217
+		if ($row != null)
218 218
 		{
219 219
 			$this->depends_on_name_owner = $row['assigned_user_id'];
220 220
 			$this->depends_on_name_mod = 'ProjectTask';
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
         $return_value = '';
230 230
 
231 231
         $query  = "SELECT name, assigned_user_id FROM project WHERE id='{$project_id}'";
232
-        $result = $this->db->query($query,true," Error filling in additional detail fields: ");
232
+        $result = $this->db->query($query, true, " Error filling in additional detail fields: ");
233 233
         $row = $this->db->fetchByAssoc($result);
234
-        if($row != null)
234
+        if ($row != null)
235 235
         {
236 236
             //$this->parent_name_owner = $row['assigned_user_id'];
237 237
             //$this->parent_name_mod = 'Project';
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 		$return_value = '';
249 249
 
250 250
 		$query  = "SELECT name, assigned_user_id FROM project WHERE id='{$parent_id}'";
251
-		$result = $this->db->query($query,true," Error filling in additional detail fields: ");
251
+		$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
252 252
 		$row = $this->db->fetchByAssoc($result);
253
-		if($row != null)
253
+		if ($row != null)
254 254
 		{
255 255
 			$this->parent_name_owner = $row['assigned_user_id'];
256 256
 			$this->parent_name_mod = 'Project';
@@ -263,26 +263,26 @@  discard block
 block discarded – undo
263 263
 	/*
264 264
 	 *
265 265
 	 */
266
-	function build_generic_where_clause ($the_query_string)
266
+	function build_generic_where_clause($the_query_string)
267 267
 	{
268 268
 		$where_clauses = array();
269 269
 		$the_query_string = $GLOBALS['db']->quote($the_query_string);
270 270
 		array_push($where_clauses, "project_task.name like '$the_query_string%'");
271 271
 
272 272
 		$the_where = "";
273
-		foreach($where_clauses as $clause)
273
+		foreach ($where_clauses as $clause)
274 274
 		{
275
-			if($the_where != "") $the_where .= " or ";
275
+			if ($the_where != "") $the_where .= " or ";
276 276
 			$the_where .= $clause;
277 277
 		}
278 278
 
279 279
 		return $the_where;
280 280
 	}
281 281
 
282
-	function get_list_view_data(){
282
+	function get_list_view_data() {
283 283
 		global $action, $currentModule, $focus, $current_module_strings, $app_list_strings, $timedate, $locale;
284 284
 		$today = $timedate->handle_offset(date($GLOBALS['timedate']->get_db_date_time_format(), time()), $timedate->dbDayFormat, true);
285
-		$task_fields =$this->get_list_view_array();
285
+		$task_fields = $this->get_list_view_array();
286 286
 		//$date_due = $timedate->to_db_date($task_fields['DATE_DUE'],false);
287 287
         if (isset($this->parent_type))
288 288
 			$task_fields['PARENT_MODULE'] = $this->parent_type;
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 		}
302 302
         */
303 303
 
304
-        if ( !isset($task_fields["FIRST_NAME"]) )
304
+        if (!isset($task_fields["FIRST_NAME"]))
305 305
             $task_fields["FIRST_NAME"] = '';
306
-        if ( !isset($task_fields["LAST_NAME"]) )
306
+        if (!isset($task_fields["LAST_NAME"]))
307 307
             $task_fields["LAST_NAME"] = '';
308
-		$task_fields['CONTACT_NAME']= $locale->getLocaleFormattedName($task_fields["FIRST_NAME"],$task_fields["LAST_NAME"]);
308
+		$task_fields['CONTACT_NAME'] = $locale->getLocaleFormattedName($task_fields["FIRST_NAME"], $task_fields["LAST_NAME"]);
309 309
 		$task_fields['TITLE'] = '';
310 310
 		if (!empty($task_fields['CONTACT_NAME'])) {
311 311
 			$task_fields['TITLE'] .= $current_module_strings['LBL_LIST_CONTACT'].": ".$task_fields['CONTACT_NAME'];
@@ -314,28 +314,28 @@  discard block
 block discarded – undo
314 314
 		return $task_fields;
315 315
 	}
316 316
 
317
-	function bean_implements($interface){
318
-		switch($interface){
317
+	function bean_implements($interface) {
318
+		switch ($interface) {
319 319
 			case 'ACL':return true;
320 320
 		}
321 321
 		return false;
322 322
 	}
323
-	function listviewACLHelper(){
323
+	function listviewACLHelper() {
324 324
 		$array_assign = parent::listviewACLHelper();
325 325
 		$is_owner = false;
326 326
 		$in_group = false; //SECURITY GROUPS
327
-		if(!empty($this->parent_name)){
327
+		if (!empty($this->parent_name)) {
328 328
 
329
-			if(!empty($this->parent_name_owner)){
329
+			if (!empty($this->parent_name_owner)) {
330 330
 				global $current_user;
331 331
 				$is_owner = $current_user->id == $this->parent_name_owner;
332 332
 			}
333 333
 			/* BEGIN - SECURITY GROUPS */
334 334
 			//parent_name_owner not being set for whatever reason so we need to figure this out
335
-			else if(!empty($this->parent_type) && !empty($this->parent_id)) {
335
+			else if (!empty($this->parent_type) && !empty($this->parent_id)) {
336 336
 				global $current_user;
337
-                $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id);
338
-                if($parent_bean !== false) {
337
+                $parent_bean = BeanFactory::getBean($this->parent_type, $this->parent_id);
338
+                if ($parent_bean !== false) {
339 339
                 	$is_owner = $current_user->id == $parent_bean->assigned_user_id;
340 340
                 }
341 341
 			}
@@ -347,59 +347,59 @@  discard block
 block discarded – undo
347 347
 			/**
348 348
 			if(ACLController::checkAccess('Project', 'view', $is_owner)){
349 349
 			*/
350
-			if(ACLController::checkAccess('Project', 'view', $is_owner, 'module', $in_group)){
350
+			if (ACLController::checkAccess('Project', 'view', $is_owner, 'module', $in_group)) {
351 351
         	/* END - SECURITY GROUPS */
352 352
 				$array_assign['PARENT'] = 'a';
353
-			}else{
353
+			} else {
354 354
 				$array_assign['PARENT'] = 'span';
355 355
 			}
356 356
 		$is_owner = false;
357
-		if(!empty($this->depends_on_name)){
357
+		if (!empty($this->depends_on_name)) {
358 358
 
359
-			if(!empty($this->depends_on_name_owner)){
359
+			if (!empty($this->depends_on_name_owner)) {
360 360
 				global $current_user;
361 361
 				$is_owner = $current_user->id == $this->depends_on_name_owner;
362 362
 			}
363 363
 		}
364
-			if( ACLController::checkAccess('ProjectTask', 'view', $is_owner)){
364
+			if (ACLController::checkAccess('ProjectTask', 'view', $is_owner)) {
365 365
 				$array_assign['PARENT_TASK'] = 'a';
366
-			}else{
366
+			} else {
367 367
 				$array_assign['PARENT_TASK'] = 'span';
368 368
 			}
369 369
 
370 370
 		return $array_assign;
371 371
 	}
372 372
 
373
-    function create_export_query($order_by, $where, $relate_link_join='')
373
+    function create_export_query($order_by, $where, $relate_link_join = '')
374 374
     {
375 375
         $custom_join = $this->getCustomJoin(true, true, $where);
376 376
         $custom_join['join'] .= $relate_link_join;
377 377
 		$query = "SELECT
378 378
 				project_task.*,
379 379
                 users.user_name as assigned_user_name ";
380
-        $query .=  $custom_join['select'];
380
+        $query .= $custom_join['select'];
381 381
 
382 382
         $query .= " FROM project_task LEFT JOIN project ON project_task.project_id=project.id AND project.deleted=0 ";
383 383
 
384
-        $query .=  $custom_join['join'];
384
+        $query .= $custom_join['join'];
385 385
         $query .= " LEFT JOIN users
386 386
                    	ON project_task.assigned_user_id=users.id ";
387 387
 
388 388
         $where_auto = " project_task.deleted=0 ";
389 389
 
390
-        if($where != "")
390
+        if ($where != "")
391 391
         	$query .= "where ($where) AND ".$where_auto;
392 392
         else
393 393
             $query .= "where ".$where_auto;
394 394
 
395
-        if(!empty($order_by)){
395
+        if (!empty($order_by)) {
396 396
            	//check to see if order by variable already has table name by looking for dot "."
397 397
            	$table_defined_already = strpos($order_by, ".");
398 398
 
399
-	        if($table_defined_already === false){
399
+	        if ($table_defined_already === false) {
400 400
 	        	//table not defined yet, define accounts to avoid "ambigous column" SQL error
401 401
 	        	$query .= " ORDER BY $order_by";
402
-	        }else{
402
+	        } else {
403 403
 	        	//table already defined, just add it to end of query
404 404
 	            $query .= " ORDER BY $order_by";
405 405
 	        }
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             {
430 430
                 $subProjectTasks = $parentProjectTask->getAllSubProjectTasks();
431 431
                 $tasks = array();
432
-                foreach($subProjectTasks as &$task)
432
+                foreach ($subProjectTasks as &$task)
433 433
                 {
434 434
                     array_push($tasks, $task->toArray(true));
435 435
                 }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         $cumulativePercentage = 0;
478 478
         if ($totalHours != 0)
479 479
         {
480
-            $cumulativePercentage = round(($cumulativeDone/$totalHours) * 100);
480
+            $cumulativePercentage = round(($cumulativeDone / $totalHours) * 100);
481 481
         }
482 482
         return $cumulativePercentage;
483 483
     }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     function getProjectTaskParent()
490 490
     {
491 491
 
492
-        $projectTaskParent=false;
492
+        $projectTaskParent = false;
493 493
 
494 494
         if (!empty($this->parent_task_id) && !empty($this->project_id))
495 495
         {
@@ -520,25 +520,25 @@  discard block
 block discarded – undo
520 520
 
521 521
             $result = $this->db->query($query, true, "Error retrieving child project tasks");
522 522
 
523
-            $projectTasks=array();
524
-            while($row = $this->db->fetchByAssoc($result))
523
+            $projectTasks = array();
524
+            while ($row = $this->db->fetchByAssoc($result))
525 525
             {
526 526
                 $projectTasks[$row['id']]['project_task_id'] = $row['project_task_id'];
527 527
                 $projectTasks[$row['id']]['parent_task_id'] = $row['parent_task_id'];
528 528
             }
529 529
 
530 530
             $potentialParentTaskIds[$this->project_task_id] = $this->project_task_id;
531
-            $actualParentTaskIds=array();
532
-            $subProjectTasks=array();
531
+            $actualParentTaskIds = array();
532
+            $subProjectTasks = array();
533 533
 
534
-            $startProjectTasksCount=0;
535
-            $endProjectTasksCount=0;
534
+            $startProjectTasksCount = 0;
535
+            $endProjectTasksCount = 0;
536 536
 
537 537
             //get all child tasks
538 538
             $run = true;
539 539
             while ($run)
540 540
             {
541
-                $count=0;
541
+                $count = 0;
542 542
 
543 543
                 foreach ($projectTasks as $id=>$values)
544 544
                 {
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
                         $potentialParentTaskIds[$values['project_task_id']] = $values['project_task_id'];
548 548
                         $actualParentTaskIds[$values['parent_task_id']] = $values['parent_task_id'];
549 549
 
550
-                        $subProjectTasks[$id]=$values;
551
-                        $count=$count+1;
550
+                        $subProjectTasks[$id] = $values;
551
+                        $count = $count + 1;
552 552
                     }
553 553
                 }
554 554
 
@@ -564,10 +564,10 @@  discard block
 block discarded – undo
564 564
                 }
565 565
             }
566 566
 
567
-            foreach($subProjectTasks as $id=>$values)
567
+            foreach ($subProjectTasks as $id=>$values)
568 568
             {
569 569
                 //ignore tasks that are parents
570
-                if(!in_array($values['project_task_id'], $actualParentTaskIds))
570
+                if (!in_array($values['project_task_id'], $actualParentTaskIds))
571 571
                 {
572 572
                     $projectTaskBean = BeanFactory::getBean('ProjectTask', $id);
573 573
                     array_push($projectTasksBeans, $projectTaskBean);
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
 	 * @param $project_id integer value of the project_id associated with this ProjectTask instance
590 590
 	 * @return total integer value of the count of project tasks, 0 if none found
591 591
 	 */
592
-    private function getNumberOfTasksInProject($project_id='')
592
+    private function getNumberOfTasksInProject($project_id = '')
593 593
     {
594
-    	if(!empty($project_id))
594
+    	if (!empty($project_id))
595 595
     	{
596 596
 	        $query = "SELECT count(project_task_id) AS total FROM project_task WHERE project_id = '{$project_id}'";
597 597
 	        $result = $this->db->query($query, true);
598
-	        if($result)
598
+	        if ($result)
599 599
 	        {
600 600
 		        $row = $this->db->fetchByAssoc($result);
601
-		        if(!empty($row['total']))
601
+		        if (!empty($row['total']))
602 602
 		        {
603 603
 		           return $row['total'];
604 604
 		        }
@@ -634,19 +634,19 @@  discard block
 block discarded – undo
634 634
         $query = $this->create_new_list_query('', "project_id = {$db->quoted($this->project_id)}");
635 635
         $this->disable_row_level_security = false;
636 636
         $res = $db->query($query);
637
-        while($row = $db->fetchByAssoc($res))
637
+        while ($row = $db->fetchByAssoc($res))
638 638
         {
639 639
             array_push($list, $row);
640 640
         }
641 641
         // fill in $tree
642
-        foreach($list as $k => &$v)
642
+        foreach ($list as $k => &$v)
643 643
         {
644
-            if(isset($v['project_task_id']) && $v['project_task_id'] != '')
644
+            if (isset($v['project_task_id']) && $v['project_task_id'] != '')
645 645
             {
646 646
                 $tree[$v['project_task_id']] = $v['parent_task_id'];
647
-                if(isset($v['parent_task_id']) && $v['parent_task_id'])
647
+                if (isset($v['parent_task_id']) && $v['parent_task_id'])
648 648
                 {
649
-                    if(!isset($nodes[$v['parent_task_id']]))
649
+                    if (!isset($nodes[$v['parent_task_id']]))
650 650
                     {
651 651
                         $nodes[$v['parent_task_id']] = 1;
652 652
                     }
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
         }
656 656
         unset($v);
657 657
         // fill in $nodes array
658
-        foreach($nodes as $k => &$v)
658
+        foreach ($nodes as $k => &$v)
659 659
         {
660 660
             $run = true;
661 661
             $i = $k;
662
-            while($run)
662
+            while ($run)
663 663
             {
664
-                if(isset($tree[$i]) &&  $tree[$i]!= '')
664
+                if (isset($tree[$i]) && $tree[$i] != '')
665 665
                 {
666 666
                     $i = $tree[$i];
667 667
                     $v++;
@@ -675,24 +675,24 @@  discard block
 block discarded – undo
675 675
         arsort($nodes);
676 676
         unset($v);
677 677
         // calculating of percentages and comparing calculated value with database one
678
-        foreach($nodes as $k => &$v)
678
+        foreach ($nodes as $k => &$v)
679 679
         {
680 680
             $currRow = null;
681 681
             $currChildren = array();
682 682
             $run = true;
683 683
             $tmp = array();
684 684
             $i = $k;
685
-            while($run)
685
+            while ($run)
686 686
             {
687
-                foreach($list as $id => &$taskRow)
687
+                foreach ($list as $id => &$taskRow)
688 688
                 {
689
-                    if($taskRow['project_task_id'] == $i && $currRow === null)
689
+                    if ($taskRow['project_task_id'] == $i && $currRow === null)
690 690
                     {
691 691
                         $currRow = $id;
692 692
                     }
693
-                    if($taskRow['parent_task_id'] == $i)
693
+                    if ($taskRow['parent_task_id'] == $i)
694 694
                     {
695
-                        if(!in_array($taskRow['project_task_id'], array_keys($nodes)))
695
+                        if (!in_array($taskRow['project_task_id'], array_keys($nodes)))
696 696
                         {
697 697
                             array_push($currChildren, $taskRow);
698 698
                         }
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
                     }
704 704
                 }
705 705
                 unset($taskRow);
706
-                if(count($tmp) == 0)
706
+                if (count($tmp) == 0)
707 707
                 {
708 708
                     $run = false;
709 709
                 }
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                 }
714 714
             }
715 715
             $subres = $this->_calculateCompletePercent($currChildren);
716
-            if($subres != $list[$currRow]['percent_complete'])
716
+            if ($subres != $list[$currRow]['percent_complete'])
717 717
             {
718 718
                 $list[$currRow]['percent_complete'] = $subres;
719 719
                 array_push($changed, $currRow);
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
         }
722 722
         unset($v);
723 723
         // updating data in database for changed tasks
724
-        foreach($changed as $k => &$v)
724
+        foreach ($changed as $k => &$v)
725 725
         {
726 726
             $task = BeanFactory::getBean('ProjectTask');
727 727
             $task->populateFromRow($list[$v]);
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 function getUtilizationDropdown($focus, $field, $value, $view) {
735 735
 	global $app_list_strings;
736 736
 
737
-	if($view == 'EditView') {
737
+	if ($view == 'EditView') {
738 738
 		global $app_list_strings;
739 739
         $html = '<select name="'.$field.'">';
740 740
         $html .= get_select_options_with_id($app_list_strings['project_task_utilization_options'], $value);
Please login to merge, or discard this patch.
Braces   +30 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -113,8 +115,7 @@  discard block
 block discarded – undo
113 115
 				$admin_user = new User();
114 116
 				$admin_user->retrieve($this->assigned_user_id);
115 117
 				$this->assigned_user_name = $admin_user->user_name;
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$this->assigned_user_id = $current_user->id;
120 121
 				$this->assigned_user_name = $current_user->user_name;
@@ -130,8 +131,7 @@  discard block
 block discarded – undo
130 131
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
131 132
         if(isset($GLOBALS['log'])) {
132 133
             $GLOBALS['log']->deprecated($deprecatedMessage);
133
-        }
134
-        else {
134
+        } else {
135 135
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
136 136
         }
137 137
         self::__construct($init);
@@ -272,7 +272,9 @@  discard block
 block discarded – undo
272 272
 		$the_where = "";
273 273
 		foreach($where_clauses as $clause)
274 274
 		{
275
-			if($the_where != "") $the_where .= " or ";
275
+			if($the_where != "") {
276
+			    $the_where .= " or ";
277
+			}
276 278
 			$the_where .= $clause;
277 279
 		}
278 280
 
@@ -284,8 +286,9 @@  discard block
 block discarded – undo
284 286
 		$today = $timedate->handle_offset(date($GLOBALS['timedate']->get_db_date_time_format(), time()), $timedate->dbDayFormat, true);
285 287
 		$task_fields =$this->get_list_view_array();
286 288
 		//$date_due = $timedate->to_db_date($task_fields['DATE_DUE'],false);
287
-        if (isset($this->parent_type))
288
-			$task_fields['PARENT_MODULE'] = $this->parent_type;
289
+        if (isset($this->parent_type)) {
290
+        			$task_fields['PARENT_MODULE'] = $this->parent_type;
291
+        }
289 292
 
290 293
 		/*
291 294
         if ($this->status != "Completed" && $this->status != "Deferred" ) {
@@ -301,10 +304,12 @@  discard block
 block discarded – undo
301 304
 		}
302 305
         */
303 306
 
304
-        if ( !isset($task_fields["FIRST_NAME"]) )
305
-            $task_fields["FIRST_NAME"] = '';
306
-        if ( !isset($task_fields["LAST_NAME"]) )
307
-            $task_fields["LAST_NAME"] = '';
307
+        if ( !isset($task_fields["FIRST_NAME"]) ) {
308
+                    $task_fields["FIRST_NAME"] = '';
309
+        }
310
+        if ( !isset($task_fields["LAST_NAME"]) ) {
311
+                    $task_fields["LAST_NAME"] = '';
312
+        }
308 313
 		$task_fields['CONTACT_NAME']= $locale->getLocaleFormattedName($task_fields["FIRST_NAME"],$task_fields["LAST_NAME"]);
309 314
 		$task_fields['TITLE'] = '';
310 315
 		if (!empty($task_fields['CONTACT_NAME'])) {
@@ -350,7 +355,7 @@  discard block
 block discarded – undo
350 355
 			if(ACLController::checkAccess('Project', 'view', $is_owner, 'module', $in_group)){
351 356
         	/* END - SECURITY GROUPS */
352 357
 				$array_assign['PARENT'] = 'a';
353
-			}else{
358
+			} else{
354 359
 				$array_assign['PARENT'] = 'span';
355 360
 			}
356 361
 		$is_owner = false;
@@ -363,7 +368,7 @@  discard block
 block discarded – undo
363 368
 		}
364 369
 			if( ACLController::checkAccess('ProjectTask', 'view', $is_owner)){
365 370
 				$array_assign['PARENT_TASK'] = 'a';
366
-			}else{
371
+			} else{
367 372
 				$array_assign['PARENT_TASK'] = 'span';
368 373
 			}
369 374
 
@@ -387,10 +392,11 @@  discard block
 block discarded – undo
387 392
 
388 393
         $where_auto = " project_task.deleted=0 ";
389 394
 
390
-        if($where != "")
391
-        	$query .= "where ($where) AND ".$where_auto;
392
-        else
393
-            $query .= "where ".$where_auto;
395
+        if($where != "") {
396
+                	$query .= "where ($where) AND ".$where_auto;
397
+        } else {
398
+                    $query .= "where ".$where_auto;
399
+        }
394 400
 
395 401
         if(!empty($order_by)){
396 402
            	//check to see if order by variable already has table name by looking for dot "."
@@ -399,7 +405,7 @@  discard block
 block discarded – undo
399 405
 	        if($table_defined_already === false){
400 406
 	        	//table not defined yet, define accounts to avoid "ambigous column" SQL error
401 407
 	        	$query .= " ORDER BY $order_by";
402
-	        }else{
408
+	        } else{
403 409
 	        	//table already defined, just add it to end of query
404 410
 	            $query .= " ORDER BY $order_by";
405 411
 	        }
@@ -466,8 +472,7 @@  discard block
 block discarded – undo
466 472
             {
467 473
                 $totalHours += $value['duration'];
468 474
                 $cumulativeDone += $value['duration'] * ($value['percent_complete'] / 100);
469
-            }
470
-            else
475
+            } else
471 476
             {
472 477
                 $totalHours += ($value['duration'] * 8);
473 478
                 $cumulativeDone += ($value['duration'] * 8) * ($value['percent_complete'] / 100);
@@ -557,8 +562,7 @@  discard block
 block discarded – undo
557 562
                 if ($startProjectTasksCount == $endProjectTasksCount)
558 563
                 {
559 564
                     $run = false;
560
-                }
561
-                else
565
+                } else
562 566
                 {
563 567
                     $startProjectTasksCount = $endProjectTasksCount;
564 568
                 }
@@ -665,8 +669,7 @@  discard block
 block discarded – undo
665 669
                 {
666 670
                     $i = $tree[$i];
667 671
                     $v++;
668
-                }
669
-                else
672
+                } else
670 673
                 {
671 674
                     $run = false;
672 675
                 }
@@ -695,8 +698,7 @@  discard block
 block discarded – undo
695 698
                         if(!in_array($taskRow['project_task_id'], array_keys($nodes)))
696 699
                         {
697 700
                             array_push($currChildren, $taskRow);
698
-                        }
699
-                        else
701
+                        } else
700 702
                         {
701 703
                             array_push($tmp, $taskRow['project_task_id']);
702 704
                         }
@@ -706,8 +708,7 @@  discard block
 block discarded – undo
706 708
                 if(count($tmp) == 0)
707 709
                 {
708 710
                     $run = false;
709
-                }
710
-                else
711
+                } else
711 712
                 {
712 713
                     $i = array_shift($tmp);
713 714
                 }
Please login to merge, or discard this patch.
modules/CampaignLog/CampaignLog.php 2 patches
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     /**
72 72
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
73 73
      */
74
-    public function CampaignLog(){
74
+    public function CampaignLog() {
75 75
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
76
-        if(isset($GLOBALS['log'])) {
76
+        if (isset($GLOBALS['log'])) {
77 77
             $GLOBALS['log']->deprecated($deprecatedMessage);
78 78
         }
79 79
         else {
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
 
86
-    function get_list_view_data(){
86
+    function get_list_view_data() {
87 87
         global $locale;
88 88
         $temp_array = $this->get_list_view_array();
89 89
         //make sure that both items in array are set to some value, else return null
90
-        if(!(isset($temp_array['TARGET_TYPE']) && $temp_array['TARGET_TYPE']!= '') || !(isset($temp_array['TARGET_ID']) && $temp_array['TARGET_ID']!= ''))
90
+        if (!(isset($temp_array['TARGET_TYPE']) && $temp_array['TARGET_TYPE'] != '') || !(isset($temp_array['TARGET_ID']) && $temp_array['TARGET_ID'] != ''))
91 91
         {   //needed values to construct query are empty/null, so return null
92 92
             $GLOBALS['log']->debug("CampaignLog.php:get_list_view_data: temp_array['TARGET_TYPE'] and/or temp_array['TARGET_ID'] are empty, return null");
93 93
             $emptyArr = array();
@@ -96,28 +96,28 @@  discard block
 block discarded – undo
96 96
 
97 97
         $table = strtolower($temp_array['TARGET_TYPE']);
98 98
 
99
-        if($temp_array['TARGET_TYPE']=='Accounts'){
99
+        if ($temp_array['TARGET_TYPE'] == 'Accounts') {
100 100
             $query = "select name from $table where id = ".$this->db->quoted($temp_array['TARGET_ID']);
101
-        }else{
102
-            $query = "select first_name, last_name, ".$this->db->concat($table, array('first_name', 'last_name'))." name from $table" .
101
+        } else {
102
+            $query = "select first_name, last_name, ".$this->db->concat($table, array('first_name', 'last_name'))." name from $table".
103 103
                 " where id = ".$this->db->quoted($temp_array['TARGET_ID']);
104 104
         }
105
-        $result=$this->db->query($query);
106
-        $row=$this->db->fetchByAssoc($result);
105
+        $result = $this->db->query($query);
106
+        $row = $this->db->fetchByAssoc($result);
107 107
 
108 108
         if ($row) {
109
-            if($temp_array['TARGET_TYPE']=='Accounts'){
110
-                $temp_array['RECIPIENT_NAME']=$row['name'];
111
-            }else{
109
+            if ($temp_array['TARGET_TYPE'] == 'Accounts') {
110
+                $temp_array['RECIPIENT_NAME'] = $row['name'];
111
+            } else {
112 112
                 $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '');
113
-                $temp_array['RECIPIENT_NAME']=$full_name;
113
+                $temp_array['RECIPIENT_NAME'] = $full_name;
114 114
             }
115 115
         }
116
-        $temp_array['RECIPIENT_EMAIL']=$this->retrieve_email_address($temp_array['TARGET_ID']);
116
+        $temp_array['RECIPIENT_EMAIL'] = $this->retrieve_email_address($temp_array['TARGET_ID']);
117 117
 
118
-        $query = 'select name from email_marketing where id = \'' . $temp_array['MARKETING_ID'] . '\'';
119
-        $result=$this->db->query($query);
120
-        $row=$this->db->fetchByAssoc($result);
118
+        $query = 'select name from email_marketing where id = \''.$temp_array['MARKETING_ID'].'\'';
119
+        $result = $this->db->query($query);
120
+        $row = $this->db->fetchByAssoc($result);
121 121
 
122 122
         if ($row)
123 123
         {
@@ -127,21 +127,21 @@  discard block
 block discarded – undo
127 127
         return $temp_array;
128 128
     }
129 129
 
130
-    function retrieve_email_address($trgt_id = ''){
130
+    function retrieve_email_address($trgt_id = '') {
131 131
         $return_str = '';
132
-        if(!empty($trgt_id)){
132
+        if (!empty($trgt_id)) {
133 133
             $qry  = " select eabr.primary_address, ea.email_address";
134 134
             $qry .= " from email_addresses ea ";
135 135
             $qry .= " Left Join email_addr_bean_rel eabr on eabr.email_address_id = ea.id ";
136 136
             $qry .= " where eabr.bean_id = '{$trgt_id}' ";
137 137
             $qry .= " and ea.deleted = 0 ";
138
-            $qry .= " and eabr.deleted = 0" ;
138
+            $qry .= " and eabr.deleted = 0";
139 139
             $qry .= " order by primary_address desc ";
140 140
 
141
-            $result=$this->db->query($qry);
142
-            $row=$this->db->fetchByAssoc($result);
141
+            $result = $this->db->query($qry);
142
+            $row = $this->db->fetchByAssoc($result);
143 143
 
144
-            if (!empty($row['email_address'])){
144
+            if (!empty($row['email_address'])) {
145 145
                 $return_str = $row['email_address'];
146 146
             }
147 147
         }
@@ -154,51 +154,51 @@  discard block
 block discarded – undo
154 154
     //this function is called statically by the campaign_log subpanel.
155 155
     static function get_related_name($related_id, $related_type) {
156 156
         global $locale;
157
-        $db= DBManagerFactory::getInstance();
157
+        $db = DBManagerFactory::getInstance();
158 158
         if ($related_type == 'Emails') {
159
-            $query="SELECT name from emails where id='$related_id'";
160
-            $result=$db->query($query);
161
-            $row=$db->fetchByAssoc($result);
159
+            $query = "SELECT name from emails where id='$related_id'";
160
+            $result = $db->query($query);
161
+            $row = $db->fetchByAssoc($result);
162 162
             if ($row != null) {
163 163
                 return $row['name'];
164 164
             }
165 165
         }
166 166
         if ($related_type == 'Contacts') {
167
-            $query="SELECT first_name, last_name from contacts where id='$related_id'";
168
-            $result=$db->query($query);
169
-            $row=$db->fetchByAssoc($result);
167
+            $query = "SELECT first_name, last_name from contacts where id='$related_id'";
168
+            $result = $db->query($query);
169
+            $row = $db->fetchByAssoc($result);
170 170
             if ($row != null) {
171 171
                 return $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
172 172
             }
173 173
         }
174 174
         if ($related_type == 'Leads') {
175
-            $query="SELECT first_name, last_name from leads where id='$related_id'";
176
-            $result=$db->query($query);
177
-            $row=$db->fetchByAssoc($result);
175
+            $query = "SELECT first_name, last_name from leads where id='$related_id'";
176
+            $result = $db->query($query);
177
+            $row = $db->fetchByAssoc($result);
178 178
             if ($row != null) {
179 179
                 return $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
180 180
             }
181 181
         }
182 182
         if ($related_type == 'Prospects') {
183
-            $query="SELECT first_name, last_name from prospects where id='$related_id'";
184
-            $result=$db->query($query);
185
-            $row=$db->fetchByAssoc($result);
183
+            $query = "SELECT first_name, last_name from prospects where id='$related_id'";
184
+            $result = $db->query($query);
185
+            $row = $db->fetchByAssoc($result);
186 186
             if ($row != null) {
187 187
                 return $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
188 188
             }
189 189
         }
190 190
         if ($related_type == 'CampaignTrackers') {
191
-            $query="SELECT tracker_url from campaign_trkrs where id='$related_id'";
192
-            $result=$db->query($query);
193
-            $row=$db->fetchByAssoc($result);
191
+            $query = "SELECT tracker_url from campaign_trkrs where id='$related_id'";
192
+            $result = $db->query($query);
193
+            $row = $db->fetchByAssoc($result);
194 194
             if ($row != null) {
195
-                return $row['tracker_url'] ;
195
+                return $row['tracker_url'];
196 196
             }
197 197
         }
198 198
         if ($related_type == 'Accounts') {
199
-            $query="SELECT name from accounts where id='$related_id'";
200
-            $result=$db->query($query);
201
-            $row=$db->fetchByAssoc($result);
199
+            $query = "SELECT name from accounts where id='$related_id'";
200
+            $result = $db->query($query);
201
+            $row = $db->fetchByAssoc($result);
202 202
             if ($row != null) {
203 203
                 return $row['name'];
204 204
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -75,8 +77,7 @@  discard block
 block discarded – undo
75 77
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
76 78
         if(isset($GLOBALS['log'])) {
77 79
             $GLOBALS['log']->deprecated($deprecatedMessage);
78
-        }
79
-        else {
80
+        } else {
80 81
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
81 82
         }
82 83
         self::__construct();
@@ -98,7 +99,7 @@  discard block
 block discarded – undo
98 99
 
99 100
         if($temp_array['TARGET_TYPE']=='Accounts'){
100 101
             $query = "select name from $table where id = ".$this->db->quoted($temp_array['TARGET_ID']);
101
-        }else{
102
+        } else{
102 103
             $query = "select first_name, last_name, ".$this->db->concat($table, array('first_name', 'last_name'))." name from $table" .
103 104
                 " where id = ".$this->db->quoted($temp_array['TARGET_ID']);
104 105
         }
@@ -108,7 +109,7 @@  discard block
 block discarded – undo
108 109
         if ($row) {
109 110
             if($temp_array['TARGET_TYPE']=='Accounts'){
110 111
                 $temp_array['RECIPIENT_NAME']=$row['name'];
111
-            }else{
112
+            } else{
112 113
                 $full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '');
113 114
                 $temp_array['RECIPIENT_NAME']=$full_name;
114 115
             }
Please login to merge, or discard this patch.
modules/CampaignLog/Popup_picker.php 3 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 {
56 56
 
57 57
 
58
-	/*
58
+    /*
59 59
 	 *
60 60
 	 */
61
-	function __construct()
62
-	{
63
-	}
61
+    function __construct()
62
+    {
63
+    }
64 64
 
65 65
     /**
66 66
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
@@ -77,117 +77,117 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
 
80
-	/*
81
-	 *
82
-	 */
83
-	function _get_where_clause()
84
-	{
85
-		$where = '';
86
-		if(isset($_REQUEST['query']))
87
-		{
88
-			$where_clauses = array();
89
-			append_where_clause($where_clauses, "target_id", "campaign_log.target_id");
90
-			//append_where_clause($where_clauses, "last_name", "prospects.last_name");
91
-
92
-			$where = generate_where_statement($where_clauses);
93
-			if (!empty($where))
94
-				$where.=" AND ";
95
-			$where .=" activity_type='targeted'";
96
-
97
-		}
98
-
99
-		return $where;
100
-	}
101
-
102
-	/**
80
+    /*
103 81
 	 *
104 82
 	 */
105
-	function process_page()
106
-	{
107
-		global $theme;
108
-		global $mod_strings;
109
-		global $app_strings;
110
-		global $app_list_strings;
111
-		global $currentModule;
112
-		global $sugar_version, $sugar_config;
113
-
114
-		$output_html = '';
115
-		$where = '';
116
-
117
-		$where = $this->_get_where_clause();
118
-
119
-
120
-
121
-		$first_name = empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name'];
122
-		$last_name = empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name'];
123
-
124
-		$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
125
-		$hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
126
-
127
-		$button  = "<form action='index.php' method='post' name='form' id='form'>\n";
128
-		//START:FOR MULTI-SELECT
129
-		$multi_select=false;
130
-		if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
131
-			$multi_select=true;
132
-			$button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('Prospects',document.MassUpdate,'mass[]','" .$app_strings['ERR_NOTHING_SELECTED']."');\" title='"
133
-				.$app_strings['LBL_SELECT_BUTTON_TITLE']."' value='  "
134
-				.$app_strings['LBL_SELECT_BUTTON_LABEL']."  ' />\n";
135
-		}
136
-		//END:FOR MULTI-SELECT
137
-		if(!$hide_clear_button)
138
-		{
139
-			$button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
140
-				.$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value='  "
141
-				.$app_strings['LBL_CLEAR_BUTTON_LABEL']."  ' />\n";
142
-		}
143
-		$button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='"
144
-			.$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accesskey='"
145
-			.$app_strings['LBL_CANCEL_BUTTON_KEY']."' value='  "
146
-			.$app_strings['LBL_CANCEL_BUTTON_LABEL']."  ' />\n";
147
-		$button .= "</form>\n";
148
-
149
-		$form = new XTemplate('modules/CampaignLog/Popup_picker.html');
150
-		$form->assign('MOD', $mod_strings);
151
-		$form->assign('APP', $app_strings);
152
-		$form->assign('THEME', $theme);
153
-		$form->assign('MODULE_NAME', $currentModule);
154
-		$form->assign('request_data', $request_data);
155
-
156
-
157
-		ob_start();
158
-		insert_popup_header($theme);
159
-		$output_html .= ob_get_contents();
160
-		ob_end_clean();
161
-
162
-		//$output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
163
-
164
-		$form->parse('main.SearchHeader');
165
-		$output_html .= $form->text('main.SearchHeader');
166
-
167
-		// Reset the sections that are already in the page so that they do not print again later.
168
-		$form->reset('main.SearchHeader');
169
-
170
-		// create the listview
171
-		$seed_bean = new CampaignLog();
172
-		$ListView = new ListView();
173
-		$ListView->show_export_button = false;
174
-		$ListView->process_for_popups = true;
175
-		$ListView->setXTemplate($form);
176
-		$ListView->multi_select_popup=$multi_select;  //FOR MULTI-SELECT
177
-		if ($multi_select) $ListView->xTemplate->assign("TAG_TYPE","SPAN"); else  $ListView->xTemplate->assign("TAG_TYPE","A");//FOR MULTI-SELECT
178
-		//$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']); //FOR MULTI-SELECT
179
-		//$ListView->setHeaderText($button); //FOR MULTI-SELECT
180
-		$ListView->setQuery($where, '', 'campaign_name1', 'CAMPAIGNLOG');
181
-		$ListView->setModStrings($mod_strings);
182
-
183
-		ob_start();
184
-		$output_html .= get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], $button, false); //FOR MULTI-SELECT
185
-		$ListView->processListView($seed_bean, 'main', 'CAMPAIGNLOG');
186
-		$output_html .= ob_get_contents();
187
-		ob_end_clean();
188
-
189
-		$output_html .= insert_popup_footer();
190
-		return $output_html;
191
-	}
83
+    function _get_where_clause()
84
+    {
85
+        $where = '';
86
+        if(isset($_REQUEST['query']))
87
+        {
88
+            $where_clauses = array();
89
+            append_where_clause($where_clauses, "target_id", "campaign_log.target_id");
90
+            //append_where_clause($where_clauses, "last_name", "prospects.last_name");
91
+
92
+            $where = generate_where_statement($where_clauses);
93
+            if (!empty($where))
94
+                $where.=" AND ";
95
+            $where .=" activity_type='targeted'";
96
+
97
+        }
98
+
99
+        return $where;
100
+    }
101
+
102
+    /**
103
+     *
104
+     */
105
+    function process_page()
106
+    {
107
+        global $theme;
108
+        global $mod_strings;
109
+        global $app_strings;
110
+        global $app_list_strings;
111
+        global $currentModule;
112
+        global $sugar_version, $sugar_config;
113
+
114
+        $output_html = '';
115
+        $where = '';
116
+
117
+        $where = $this->_get_where_clause();
118
+
119
+
120
+
121
+        $first_name = empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name'];
122
+        $last_name = empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name'];
123
+
124
+        $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
125
+        $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
126
+
127
+        $button  = "<form action='index.php' method='post' name='form' id='form'>\n";
128
+        //START:FOR MULTI-SELECT
129
+        $multi_select=false;
130
+        if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
131
+            $multi_select=true;
132
+            $button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('Prospects',document.MassUpdate,'mass[]','" .$app_strings['ERR_NOTHING_SELECTED']."');\" title='"
133
+                .$app_strings['LBL_SELECT_BUTTON_TITLE']."' value='  "
134
+                .$app_strings['LBL_SELECT_BUTTON_LABEL']."  ' />\n";
135
+        }
136
+        //END:FOR MULTI-SELECT
137
+        if(!$hide_clear_button)
138
+        {
139
+            $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
140
+                .$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value='  "
141
+                .$app_strings['LBL_CLEAR_BUTTON_LABEL']."  ' />\n";
142
+        }
143
+        $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='"
144
+            .$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accesskey='"
145
+            .$app_strings['LBL_CANCEL_BUTTON_KEY']."' value='  "
146
+            .$app_strings['LBL_CANCEL_BUTTON_LABEL']."  ' />\n";
147
+        $button .= "</form>\n";
148
+
149
+        $form = new XTemplate('modules/CampaignLog/Popup_picker.html');
150
+        $form->assign('MOD', $mod_strings);
151
+        $form->assign('APP', $app_strings);
152
+        $form->assign('THEME', $theme);
153
+        $form->assign('MODULE_NAME', $currentModule);
154
+        $form->assign('request_data', $request_data);
155
+
156
+
157
+        ob_start();
158
+        insert_popup_header($theme);
159
+        $output_html .= ob_get_contents();
160
+        ob_end_clean();
161
+
162
+        //$output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
163
+
164
+        $form->parse('main.SearchHeader');
165
+        $output_html .= $form->text('main.SearchHeader');
166
+
167
+        // Reset the sections that are already in the page so that they do not print again later.
168
+        $form->reset('main.SearchHeader');
169
+
170
+        // create the listview
171
+        $seed_bean = new CampaignLog();
172
+        $ListView = new ListView();
173
+        $ListView->show_export_button = false;
174
+        $ListView->process_for_popups = true;
175
+        $ListView->setXTemplate($form);
176
+        $ListView->multi_select_popup=$multi_select;  //FOR MULTI-SELECT
177
+        if ($multi_select) $ListView->xTemplate->assign("TAG_TYPE","SPAN"); else  $ListView->xTemplate->assign("TAG_TYPE","A");//FOR MULTI-SELECT
178
+        //$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']); //FOR MULTI-SELECT
179
+        //$ListView->setHeaderText($button); //FOR MULTI-SELECT
180
+        $ListView->setQuery($where, '', 'campaign_name1', 'CAMPAIGNLOG');
181
+        $ListView->setModStrings($mod_strings);
182
+
183
+        ob_start();
184
+        $output_html .= get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], $button, false); //FOR MULTI-SELECT
185
+        $ListView->processListView($seed_bean, 'main', 'CAMPAIGNLOG');
186
+        $output_html .= ob_get_contents();
187
+        ob_end_clean();
188
+
189
+        $output_html .= insert_popup_footer();
190
+        return $output_html;
191
+    }
192 192
 } // end of class Popup_Picker
193 193
 ?>
194 194
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
67 67
      */
68
-    function Popup_Picker(){
68
+    function Popup_Picker() {
69 69
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
70
-        if(isset($GLOBALS['log'])) {
70
+        if (isset($GLOBALS['log'])) {
71 71
             $GLOBALS['log']->deprecated($deprecatedMessage);
72 72
         }
73 73
         else {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	function _get_where_clause()
84 84
 	{
85 85
 		$where = '';
86
-		if(isset($_REQUEST['query']))
86
+		if (isset($_REQUEST['query']))
87 87
 		{
88 88
 			$where_clauses = array();
89 89
 			append_where_clause($where_clauses, "target_id", "campaign_log.target_id");
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 
92 92
 			$where = generate_where_statement($where_clauses);
93 93
 			if (!empty($where))
94
-				$where.=" AND ";
95
-			$where .=" activity_type='targeted'";
94
+				$where .= " AND ";
95
+			$where .= " activity_type='targeted'";
96 96
 
97 97
 		}
98 98
 
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 		$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
125 125
 		$hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
126 126
 
127
-		$button  = "<form action='index.php' method='post' name='form' id='form'>\n";
127
+		$button = "<form action='index.php' method='post' name='form' id='form'>\n";
128 128
 		//START:FOR MULTI-SELECT
129
-		$multi_select=false;
129
+		$multi_select = false;
130 130
 		if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
131
-			$multi_select=true;
132
-			$button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('Prospects',document.MassUpdate,'mass[]','" .$app_strings['ERR_NOTHING_SELECTED']."');\" title='"
131
+			$multi_select = true;
132
+			$button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('Prospects',document.MassUpdate,'mass[]','".$app_strings['ERR_NOTHING_SELECTED']."');\" title='"
133 133
 				.$app_strings['LBL_SELECT_BUTTON_TITLE']."' value='  "
134 134
 				.$app_strings['LBL_SELECT_BUTTON_LABEL']."  ' />\n";
135 135
 		}
136 136
 		//END:FOR MULTI-SELECT
137
-		if(!$hide_clear_button)
137
+		if (!$hide_clear_button)
138 138
 		{
139 139
 			$button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
140 140
 				.$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value='  "
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 		$ListView->show_export_button = false;
174 174
 		$ListView->process_for_popups = true;
175 175
 		$ListView->setXTemplate($form);
176
-		$ListView->multi_select_popup=$multi_select;  //FOR MULTI-SELECT
177
-		if ($multi_select) $ListView->xTemplate->assign("TAG_TYPE","SPAN"); else  $ListView->xTemplate->assign("TAG_TYPE","A");//FOR MULTI-SELECT
176
+		$ListView->multi_select_popup = $multi_select; //FOR MULTI-SELECT
177
+		if ($multi_select) $ListView->xTemplate->assign("TAG_TYPE", "SPAN"); else  $ListView->xTemplate->assign("TAG_TYPE", "A"); //FOR MULTI-SELECT
178 178
 		//$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']); //FOR MULTI-SELECT
179 179
 		//$ListView->setHeaderText($button); //FOR MULTI-SELECT
180 180
 		$ListView->setQuery($where, '', 'campaign_name1', 'CAMPAIGNLOG');
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -69,8 +71,7 @@  discard block
 block discarded – undo
69 71
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
70 72
         if(isset($GLOBALS['log'])) {
71 73
             $GLOBALS['log']->deprecated($deprecatedMessage);
72
-        }
73
-        else {
74
+        } else {
74 75
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
75 76
         }
76 77
         self::__construct();
@@ -90,8 +91,9 @@  discard block
 block discarded – undo
90 91
 			//append_where_clause($where_clauses, "last_name", "prospects.last_name");
91 92
 
92 93
 			$where = generate_where_statement($where_clauses);
93
-			if (!empty($where))
94
-				$where.=" AND ";
94
+			if (!empty($where)) {
95
+							$where.=" AND ";
96
+			}
95 97
 			$where .=" activity_type='targeted'";
96 98
 
97 99
 		}
@@ -174,7 +176,12 @@  discard block
 block discarded – undo
174 176
 		$ListView->process_for_popups = true;
175 177
 		$ListView->setXTemplate($form);
176 178
 		$ListView->multi_select_popup=$multi_select;  //FOR MULTI-SELECT
177
-		if ($multi_select) $ListView->xTemplate->assign("TAG_TYPE","SPAN"); else  $ListView->xTemplate->assign("TAG_TYPE","A");//FOR MULTI-SELECT
179
+		if ($multi_select) {
180
+		    $ListView->xTemplate->assign("TAG_TYPE","SPAN");
181
+		} else {
182
+		    $ListView->xTemplate->assign("TAG_TYPE","A");
183
+		}
184
+		//FOR MULTI-SELECT
178 185
 		//$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']); //FOR MULTI-SELECT
179 186
 		//$ListView->setHeaderText($button); //FOR MULTI-SELECT
180 187
 		$ListView->setQuery($where, '', 'campaign_name1', 'CAMPAIGNLOG');
Please login to merge, or discard this patch.