Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
modules/ModuleBuilder/views/view.main.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 class ViewMain extends SugarView
42 42
 {
43
- 	function __construct(){
43
+ 	function __construct() {
44 44
 		$this->options['show_footer'] = true;
45 45
  		parent::__construct();
46 46
  	}
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
     /**
49 49
      * @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
50 50
      */
51
-    function ViewMain(){
51
+    function ViewMain() {
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53
-        if(isset($GLOBALS['log'])) {
53
+        if (isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55 55
         }
56 56
         else {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	    global $mod_strings;
69 69
 
70 70
     	return array(
71
-    	   translate('LBL_MODULE_NAME','Administration'),
71
+    	   translate('LBL_MODULE_NAME', 'Administration'),
72 72
     	   ModuleBuilderController::getModuleTitle(),
73 73
     	   );
74 74
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		global $app_strings, $current_user, $mod_strings, $theme;
79 79
 
80 80
  		$smarty = new Sugar_Smarty();
81
- 		$type = (!empty($_REQUEST['type']))?$_REQUEST['type']:'main';
81
+ 		$type = (!empty($_REQUEST['type'])) ? $_REQUEST['type'] : 'main';
82 82
  		$mbt = false;
83 83
  		$admin = false;
84 84
  		$mb = strtolower($type);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
  		$smarty->assign('app_strings', $app_strings);
87 87
  		$smarty->assign('mod', $mod_strings);
88 88
  		//Replaced by javascript function "setMode"
89
- 		switch($type){
89
+ 		switch ($type) {
90 90
  			case 'studio':
91 91
  				//$smarty->assign('ONLOAD','ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
92 92
  				require_once('modules/ModuleBuilder/Module/StudioTree.php');
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
  		$smarty->assign('TEST_STUDIO', displayStudioForCurrentUser());
111 111
  		$smarty->assign('ADMIN', is_admin($current_user));
112 112
  		$smarty->display('modules/ModuleBuilder/tpls/includes.tpl');
113
-		if($mbt)
113
+		if ($mbt)
114 114
 		{
115
-			$smarty->assign('TREE',$mbt->fetch());
115
+			$smarty->assign('TREE', $mbt->fetch());
116 116
 			$smarty->assign('TREElabel', $mbt->getName());
117 117
 		}
118 118
 		$userPref = $current_user->getPreference('mb_assist', 'Assistant');
119
-		if(!$userPref) $userPref="na";
120
-		$smarty->assign('userPref',$userPref);
119
+		if (!$userPref) $userPref = "na";
120
+		$smarty->assign('userPref', $userPref);
121 121
 
122 122
 		///////////////////////////////////
123 123
 	    require_once('include/SugarTinyMCE.php');
124 124
 	    $tiny = new SugarTinyMCE();
125
-	    $tiny->defaultConfig['width']=300;
126
-	    $tiny->defaultConfig['height']=300;
125
+	    $tiny->defaultConfig['width'] = 300;
126
+	    $tiny->defaultConfig['height'] = 300;
127 127
 	    $tiny->buttonConfig = "code,separator,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,
128 128
 	                         justifyfull,separator,forecolor,backcolor,
129 129
 	                         ";
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53 53
         if(isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55
-        }
56
-        else {
55
+        } else {
57 56
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
58 57
         }
59 58
         self::__construct();
@@ -116,7 +115,9 @@  discard block
 block discarded – undo
116 115
 			$smarty->assign('TREElabel', $mbt->getName());
117 116
 		}
118 117
 		$userPref = $current_user->getPreference('mb_assist', 'Assistant');
119
-		if(!$userPref) $userPref="na";
118
+		if(!$userPref) {
119
+		    $userPref="na";
120
+		}
120 121
 		$smarty->assign('userPref',$userPref);
121 122
 
122 123
 		///////////////////////////////////
Please login to merge, or discard this patch.
modules/ModuleBuilder/views/view.layoutview.php 2 patches
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3
-    die ( 'Not A Valid Entry Point' ) ;
2
+if (!defined('sugarEntry') || !sugarEntry)
3
+    die ('Not A Valid Entry Point');
4 4
 
5 5
 /*********************************************************************************
6 6
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -41,28 +41,28 @@  discard block
 block discarded – undo
41 41
  ********************************************************************************/
42 42
 
43 43
 
44
-require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
45
-require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
46
-require_once 'modules/ModuleBuilder/parsers/constants.php' ;
44
+require_once ('modules/ModuleBuilder/parsers/ParserFactory.php');
45
+require_once ('modules/ModuleBuilder/MB/AjaxCompose.php');
46
+require_once 'modules/ModuleBuilder/parsers/constants.php';
47 47
 
48 48
 class ViewLayoutView extends SugarView
49 49
 {
50 50
     function __construct()
51 51
     {
52
-        $GLOBALS [ 'log' ]->debug ( 'in ViewLayoutView' ) ;
53
-        $this->editModule = $_REQUEST [ 'view_module' ] ;
54
-        $this->editLayout = $_REQUEST [ 'view' ] ;
52
+        $GLOBALS ['log']->debug('in ViewLayoutView');
53
+        $this->editModule = $_REQUEST ['view_module'];
54
+        $this->editLayout = $_REQUEST ['view'];
55 55
         $this->package = null;
56
-        $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || !empty($_REQUEST [ 'view_package' ]);
56
+        $this->fromModuleBuilder = isset ($_REQUEST ['MB']) || !empty($_REQUEST ['view_package']);
57 57
         if ($this->fromModuleBuilder)
58 58
         {
59
-            $this->package = $_REQUEST [ 'view_package' ] ;
59
+            $this->package = $_REQUEST ['view_package'];
60 60
             $this->type = $this->editLayout;
61 61
         } else
62 62
         {
63
-            global $app_list_strings ;
64
-            $moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
65
-            $this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
63
+            global $app_list_strings;
64
+            $moduleNames = array_change_key_case($app_list_strings ['moduleList']);
65
+            $this->translatedEditModule = $moduleNames [strtolower($this->editModule)];
66 66
             $this->sm = StudioModuleFactory::getStudioModule($this->editModule);
67 67
             $this->type = $this->sm->getViewType($this->editLayout);
68 68
         }
@@ -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
-    function ViewLayoutView(){
74
+    function ViewLayoutView() {
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 {
@@ -90,30 +90,30 @@  discard block
 block discarded – undo
90 90
 	    global $mod_strings;
91 91
 
92 92
     	return array(
93
-    	   translate('LBL_MODULE_NAME','Administration'),
93
+    	   translate('LBL_MODULE_NAME', 'Administration'),
94 94
     	   ModuleBuilderController::getModuleTitle(),
95 95
     	   );
96 96
     }
97 97
 
98 98
     // DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
99
-    function preDisplay ()
99
+    function preDisplay()
100 100
     {
101 101
     }
102 102
 
103
-    function display ($preview = false)
103
+    function display($preview = false)
104 104
     {
105 105
 
106
-        global $mod_strings ;
107
-        $parser = ParserFactory::getParser($this->editLayout,$this->editModule,$this->package);
106
+        global $mod_strings;
107
+        $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->package);
108 108
 
109
-        if(isset($this->view_object_map['new_parser'])) {
109
+        if (isset($this->view_object_map['new_parser'])) {
110 110
             $parser = $this->view_object_map['new_parser'];
111 111
         }
112 112
 
113
-        $history = $parser->getHistory () ;
114
-        $smarty = new Sugar_Smarty ( ) ;
113
+        $history = $parser->getHistory();
114
+        $smarty = new Sugar_Smarty( );
115 115
         //Add in the module we are viewing to our current mod strings
116
-		if (! $this->fromModuleBuilder) {
116
+		if (!$this->fromModuleBuilder) {
117 117
 			global $current_language;
118 118
 			$editModStrings = return_module_language($current_language, $this->editModule);
119 119
 			$mod_strings = sugarArrayMerge($editModStrings, $mod_strings);
@@ -121,171 +121,171 @@  discard block
 block discarded – undo
121 121
         $smarty->assign('mod', $mod_strings);
122 122
 		$smarty->assign('MOD', $mod_strings);
123 123
         // assign buttons
124
-        $images = array ( 'icon_save' => 'studio_save' , 'icon_publish' => 'studio_publish' , 'icon_address' => 'icon_Address' , 'icon_emailaddress' => 'icon_EmailAddress' , 'icon_phone' => 'icon_Phone' ) ;
125
-        foreach ( $images as $image => $file )
124
+        $images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone');
125
+        foreach ($images as $image => $file)
126 126
         {
127
-            $smarty->assign ( $image, SugarThemeRegistry::current()->getImage($file,'',null,null,'.gif',$file) ) ;
127
+            $smarty->assign($image, SugarThemeRegistry::current()->getImage($file, '', null, null, '.gif', $file));
128 128
         }
129 129
 
130
-        $requiredFields = implode($parser->getRequiredFields () , ',');
130
+        $requiredFields = implode($parser->getRequiredFields(), ',');
131 131
         $slashedRequiredFields = addslashes($requiredFields);
132
-        $buttons = array ( ) ;
132
+        $buttons = array( );
133 133
         $disableLayout = false;
134 134
 
135 135
         if ($preview)
136 136
         {
137
-            $smarty->assign ( 'layouttitle', translate ( 'LBL_LAYOUT_PREVIEW', 'ModuleBuilder' ) ) ;
137
+            $smarty->assign('layouttitle', translate('LBL_LAYOUT_PREVIEW', 'ModuleBuilder'));
138 138
         } else
139 139
         {
140
-            $smarty->assign ( 'layouttitle', translate ( 'LBL_CURRENT_LAYOUT', 'ModuleBuilder' ) ) ;
140
+            $smarty->assign('layouttitle', translate('LBL_CURRENT_LAYOUT', 'ModuleBuilder'));
141 141
 
142 142
             //Check if we need to synch edit view to other layouts
143
-            if($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE){
144
-		        $parser2 = ParserFactory::getParser(MB_EDITVIEW,$this->editModule,$this->package);
145
-                if($this->editLayout == MB_DETAILVIEW){
143
+            if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) {
144
+		        $parser2 = ParserFactory::getParser(MB_EDITVIEW, $this->editModule, $this->package);
145
+                if ($this->editLayout == MB_DETAILVIEW) {
146 146
 		            $disableLayout = $parser2->getSyncDetailEditViews();
147 147
                 }
148
-                if(!empty($_REQUEST['copyFromEditView'])){
149
-                    $editViewPanels = $parser2->convertFromCanonicalForm ( $parser2->_viewdefs [ 'panels' ] , $parser2->_fielddefs ) ;
150
-                    $parser->_viewdefs [ 'panels' ] = $editViewPanels;
148
+                if (!empty($_REQUEST['copyFromEditView'])) {
149
+                    $editViewPanels = $parser2->convertFromCanonicalForm($parser2->_viewdefs ['panels'], $parser2->_fielddefs);
150
+                    $parser->_viewdefs ['panels'] = $editViewPanels;
151 151
                     $parser->_fielddefs = $parser2->_fielddefs;
152 152
                     $parser->setUseTabs($parser2->getUseTabs());
153 153
                     $parser->setTabDefs($parser2->getTabDefs());
154 154
                 }
155 155
 		    }
156 156
 
157
-            if (! $this->fromModuleBuilder)
157
+            if (!$this->fromModuleBuilder)
158 158
             {
159
-	            $buttons [] = array (
160
-                    'id' => 'saveBtn' ,
161
-                    'text' => translate ( 'LBL_BTN_SAVE' ) ,
159
+	            $buttons [] = array(
160
+                    'id' => 'saveBtn',
161
+                    'text' => translate('LBL_BTN_SAVE'),
162 162
                     'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'",
163 163
                 	'disabled' => $disableLayout,
164
-                ) ;
165
-                $buttons [] = array (
166
-                    'id' => 'publishBtn' ,
167
-                    'text' => translate ( 'LBL_BTN_SAVEPUBLISH' ) ,
164
+                );
165
+                $buttons [] = array(
166
+                    'id' => 'publishBtn',
167
+                    'text' => translate('LBL_BTN_SAVEPUBLISH'),
168 168
                     'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'",
169 169
                 	'disabled' => $disableLayout,
170
-                ) ;
171
-                $buttons [] = array ( 'id' => 'spacer' , 'width' => '33px' ) ;
172
-                $buttons [] = array (
173
-	                'id' => 'historyBtn' ,
174
-	                'text' => translate ( 'LBL_HISTORY' ) ,
170
+                );
171
+                $buttons [] = array('id' => 'spacer', 'width' => '33px');
172
+                $buttons [] = array(
173
+	                'id' => 'historyBtn',
174
+	                'text' => translate('LBL_HISTORY'),
175 175
 	                'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'",
176 176
                     'disabled' => $disableLayout,
177
-                ) ;
178
-                $buttons [] = array (
179
-	                'id' => 'historyDefault' ,
180
-	                'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
177
+                );
178
+                $buttons [] = array(
179
+	                'id' => 'historyDefault',
180
+	                'text' => translate('LBL_RESTORE_DEFAULT'),
181 181
 	                'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'",
182 182
                 	'disabled' => $disableLayout,
183
-                ) ;
183
+                );
184 184
             } else
185 185
             {
186
-                $buttons [] = array (
187
-                    'id' => 'saveBtn' ,
188
-                    'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] ,
186
+                $buttons [] = array(
187
+                    'id' => 'saveBtn',
188
+                    'text' => $GLOBALS ['mod_strings'] ['LBL_BTN_SAVE'],
189 189
                     'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'",
190 190
                     'disabled' => $disableLayout,
191
-                ) ;
192
-                $buttons [] = array ( 'id' => 'spacer' , 'width' => '33px' ) ;
193
-                $buttons [] = array (
194
-                    'id' => 'historyBtn' ,
195
-                    'text' => translate ( 'LBL_HISTORY' ) ,
191
+                );
192
+                $buttons [] = array('id' => 'spacer', 'width' => '33px');
193
+                $buttons [] = array(
194
+                    'id' => 'historyBtn',
195
+                    'text' => translate('LBL_HISTORY'),
196 196
                     'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'",
197 197
                     'disabled' => $disableLayout,
198
-                ) ;
199
-                $buttons [] = array (
200
-                    'id' => 'historyDefault' ,
201
-                    'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
198
+                );
199
+                $buttons [] = array(
200
+                    'id' => 'historyDefault',
201
+                    'text' => translate('LBL_RESTORE_DEFAULT'),
202 202
                     'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'",
203 203
                     'disabled' => $disableLayout,
204
-                ) ;
204
+                );
205 205
             }
206 206
 
207 207
 
208
-            if($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE){
209
-                $buttons [] = array (
210
-                'id' => 'copyFromEditView' ,
211
-                'text' => translate ( 'LBL_COPY_FROM_EDITVIEW' ) ,
208
+            if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) {
209
+                $buttons [] = array(
210
+                'id' => 'copyFromEditView',
211
+                'text' => translate('LBL_COPY_FROM_EDITVIEW'),
212 212
                 'actionScript' => "onclick='ModuleBuilder.copyFromView(\"{$this->editModule}\", \"{$this->editLayout}\")'",
213 213
                 'disabled' => $disableLayout,
214
-                ) ;
214
+                );
215 215
             }
216 216
         }
217 217
 
218
-        $html = "" ;
219
-        foreach ( $buttons as $button )
218
+        $html = "";
219
+        foreach ($buttons as $button)
220 220
         {
221 221
             if ($button['id'] == "spacer") {
222 222
             	$html .= "<td style='width:{$button['width']}'> </td>";
223 223
             } else {
224 224
         	    $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' "
225 225
         	       . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' "
226
-        	       . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}'" ;
227
-        	    if(!empty($button['disabled'])){
226
+        	       . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}'";
227
+        	    if (!empty($button['disabled'])) {
228 228
         	    	 $html .= " disabled";
229 229
         	    }
230 230
         	    $html .= "></td>";
231 231
             }
232 232
         }
233 233
 
234
-        $smarty->assign ( 'buttons', $html ) ;
234
+        $smarty->assign('buttons', $html);
235 235
 
236 236
         // assign fields and layout
237
-        $smarty->assign ( 'available_fields', $parser->getAvailableFields () ) ;
238
-
239
-        $smarty->assign ( 'disable_layout', $disableLayout) ;
240
-        $smarty->assign ( 'required_fields', $requiredFields) ;
241
-        $smarty->assign ( 'layout', $parser->getLayout () ) ;
242
-        $smarty->assign ( 'field_defs', $parser->getFieldDefs () ) ;
243
-        $smarty->assign ( 'view_module', $this->editModule ) ;
244
-        $smarty->assign ( 'view', $this->editLayout ) ;
245
-        $smarty->assign ( 'maxColumns', $parser->getMaxColumns() ) ;
246
-        $smarty->assign ( 'nextPanelId', $parser->getFirstNewPanelId() ) ;
247
-        $smarty->assign ( 'displayAsTabs', $parser->getUseTabs() ) ;
248
-        $smarty->assign ( 'tabDefs', $parser->getTabDefs() ) ;
249
-        $smarty->assign ( 'syncDetailEditViews', $parser->getSyncDetailEditViews() ) ;
250
-        $smarty->assign ( 'fieldwidth', 150 ) ;
251
-        $smarty->assign ( 'translate', $this->fromModuleBuilder ? false : true ) ;
237
+        $smarty->assign('available_fields', $parser->getAvailableFields());
238
+
239
+        $smarty->assign('disable_layout', $disableLayout);
240
+        $smarty->assign('required_fields', $requiredFields);
241
+        $smarty->assign('layout', $parser->getLayout());
242
+        $smarty->assign('field_defs', $parser->getFieldDefs());
243
+        $smarty->assign('view_module', $this->editModule);
244
+        $smarty->assign('view', $this->editLayout);
245
+        $smarty->assign('maxColumns', $parser->getMaxColumns());
246
+        $smarty->assign('nextPanelId', $parser->getFirstNewPanelId());
247
+        $smarty->assign('displayAsTabs', $parser->getUseTabs());
248
+        $smarty->assign('tabDefs', $parser->getTabDefs());
249
+        $smarty->assign('syncDetailEditViews', $parser->getSyncDetailEditViews());
250
+        $smarty->assign('fieldwidth', 150);
251
+        $smarty->assign('translate', $this->fromModuleBuilder ? false : true);
252 252
 
253 253
         if ($this->fromModuleBuilder)
254 254
         {
255
-            $smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ;
256
-            $smarty->assign ( 'view_package', $this->package ) ;
255
+            $smarty->assign('fromModuleBuilder', $this->fromModuleBuilder);
256
+            $smarty->assign('view_package', $this->package);
257 257
         }
258 258
 
259
-        $labels = array (
260
-        			MB_EDITVIEW => 'LBL_EDITVIEW' ,
261
-        			MB_DETAILVIEW => 'LBL_DETAILVIEW' ,
259
+        $labels = array(
260
+        			MB_EDITVIEW => 'LBL_EDITVIEW',
261
+        			MB_DETAILVIEW => 'LBL_DETAILVIEW',
262 262
         			MB_QUICKCREATE => 'LBL_QUICKCREATE',
263
-        			) ;
263
+        			);
264 264
 
265
-        $layoutLabel = 'LBL_LAYOUTS' ;
266
-        $layoutView = 'layouts' ;
265
+        $layoutLabel = 'LBL_LAYOUTS';
266
+        $layoutView = 'layouts';
267 267
 
268 268
 
269
-        $ajax = new AjaxCompose ( ) ;
269
+        $ajax = new AjaxCompose( );
270 270
 
271
-        $translatedViewType = '' ;
272
-		if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
273
-			$translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
271
+        $translatedViewType = '';
272
+		if (isset ($labels [strtolower($this->editLayout)]))
273
+			$translatedViewType = translate($labels [strtolower($this->editLayout)], 'ModuleBuilder');
274 274
         else if (isset($this->sm))
275 275
         {
276
-            foreach($this->sm->sources as $file => $def)
276
+            foreach ($this->sm->sources as $file => $def)
277 277
             {
278 278
                 if (!empty($def['view']) && $def['view'] == $this->editLayout && !empty($def['name']))
279 279
                 {
280 280
                     $translatedViewType = $def['name'];
281 281
                 }
282 282
             }
283
-            if(empty($translatedViewType))
283
+            if (empty($translatedViewType))
284 284
             {
285
-                $label = "LBL_" . strtoupper($this->editLayout);
285
+                $label = "LBL_".strtoupper($this->editLayout);
286 286
                 $translated = translate($label, $this->editModule);
287 287
                 if ($translated != $label)
288
-                    $translatedViewType =  $translated;
288
+                    $translatedViewType = $translated;
289 289
             }
290 290
         }
291 291
 
@@ -294,34 +294,34 @@  discard block
 block discarded – undo
294 294
 
295 295
         if ($this->fromModuleBuilder)
296 296
         {
297
-            $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
298
-            $ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")' ) ;
299
-            $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")' ) ;
300
-            $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
301
-            $ajax->addCrumb ( $translatedViewType, '' ) ;
297
+            $ajax->addCrumb(translate('LBL_MODULEBUILDER', 'ModuleBuilder'), 'ModuleBuilder.main("mb")');
298
+            $ajax->addCrumb($this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package='.$this->package.'")');
299
+            $ajax->addCrumb($this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package='.$this->package.'&view_module='.$this->editModule.'")');
300
+            $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view='.$layoutView.'&view_module='.$this->editModule.'&view_package='.$this->package.'")');
301
+            $ajax->addCrumb($translatedViewType, '');
302 302
         } else
303 303
         {
304
-            $ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.main("studio")' ) ;
305
-            $ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
306
-            $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
307
-            $ajax->addCrumb ( $translatedViewType, '' ) ;
304
+            $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")');
305
+            $ajax->addCrumb($this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module='.$this->editModule.'")');
306
+            $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module='.$this->editModule.'")');
307
+            $ajax->addCrumb($translatedViewType, '');
308 308
         }
309 309
 
310 310
         // set up language files
311
-		$smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template
312
-        $smarty->assign('from_mb',$this->fromModuleBuilder);
311
+		$smarty->assign('language', $parser->getLanguage()); // for sugar_translate in the smarty template
312
+        $smarty->assign('from_mb', $this->fromModuleBuilder);
313 313
         $smarty->assign('calc_field_list', json_encode($parser->getCalculatedFields()));
314 314
 		if ($this->fromModuleBuilder) {
315
-			$mb = new ModuleBuilder ( ) ;
316
-            $module = & $mb->getPackageModule ( $this->package, $this->editModule ) ;
315
+			$mb = new ModuleBuilder( );
316
+            $module = & $mb->getPackageModule($this->package, $this->editModule);
317 317
 		    $smarty->assign('current_mod_strings', $module->getModStrings());
318 318
 		}
319 319
 
320
-        $ajax->addSection ( 'center', $translatedViewType, $smarty->fetch ( 'modules/ModuleBuilder/tpls/layoutView.tpl' ) ) ;
320
+        $ajax->addSection('center', $translatedViewType, $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl'));
321 321
         if ($preview) {
322
-        	echo $smarty->fetch ( 'modules/ModuleBuilder/tpls/Preview/layoutView.tpl' );
322
+        	echo $smarty->fetch('modules/ModuleBuilder/tpls/Preview/layoutView.tpl');
323 323
 		} else {
324
-			echo $ajax->getJavascript () ;
324
+			echo $ajax->getJavascript();
325 325
     	}
326 326
     }
327 327
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
2
+if (! defined ( 'sugarEntry' ) || ! sugarEntry) {
3 3
     die ( 'Not A Valid Entry Point' ) ;
4
+}
4 5
 
5 6
 /*********************************************************************************
6 7
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -75,8 +76,7 @@  discard block
 block discarded – undo
75 76
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
76 77
         if(isset($GLOBALS['log'])) {
77 78
             $GLOBALS['log']->deprecated($deprecatedMessage);
78
-        }
79
-        else {
79
+        } else {
80 80
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
81 81
         }
82 82
         self::__construct();
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
         $ajax = new AjaxCompose ( ) ;
270 270
 
271 271
         $translatedViewType = '' ;
272
-		if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
273
-			$translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
274
-        else if (isset($this->sm))
272
+		if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) ) {
273
+					$translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
274
+		} else if (isset($this->sm))
275 275
         {
276 276
             foreach($this->sm->sources as $file => $def)
277 277
             {
@@ -284,8 +284,9 @@  discard block
 block discarded – undo
284 284
             {
285 285
                 $label = "LBL_" . strtoupper($this->editLayout);
286 286
                 $translated = translate($label, $this->editModule);
287
-                if ($translated != $label)
288
-                    $translatedViewType =  $translated;
287
+                if ($translated != $label) {
288
+                                    $translatedViewType =  $translated;
289
+                }
289 290
             }
290 291
         }
291 292
 
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.searchfields.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3
-    die ( 'Not A Valid Entry Point' ) ;
2
+if (!defined('sugarEntry') || !sugarEntry)
3
+    die ('Not A Valid Entry Point');
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
6 6
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
40 40
  ********************************************************************************/
41 41
 
42
-require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ;
42
+require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php');
43 43
 require_once ('modules/ModuleBuilder/MB/MBPackage.php');
44 44
 
45 45
 class ParserSearchFields extends ModuleBuilderParser
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	var $searchFields;
49 49
 	var $packageKey;
50 50
 
51
-    function __construct ($moduleName, $packageName='')
51
+    function __construct($moduleName, $packageName = '')
52 52
     {
53 53
         $this->moduleName = $moduleName;
54 54
         if (!empty($packageName))
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * @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
66 66
      */
67
-    function ParserSearchFields($moduleName, $packageName=''){
67
+    function ParserSearchFields($moduleName, $packageName = '') {
68 68
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
69
-        if(isset($GLOBALS['log'])) {
69
+        if (isset($GLOBALS['log'])) {
70 70
             $GLOBALS['log']->deprecated($deprecatedMessage);
71 71
         }
72 72
         else {
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 
78 78
     function addSearchField($name, $searchField)
79 79
     {
80
-    	if(empty($name) || empty($searchField) || !is_array($searchField))
80
+    	if (empty($name) || empty($searchField) || !is_array($searchField))
81 81
     	{
82 82
     		return;
83 83
     	}
84 84
 
85
-    	$key = isset($this->packageKey) ? $this->packageKey . '_' . $this->moduleName : $this->moduleName;
85
+    	$key = isset($this->packageKey) ? $this->packageKey.'_'.$this->moduleName : $this->moduleName;
86 86
         $this->searchFields[$key][$name] = $searchField;
87 87
     }
88 88
 
89 89
     function removeSearchField($name)
90 90
     {
91 91
 
92
-    	$key = isset($this->packageKey) ? $this->packageKey . '_' . $this->moduleName : $this->moduleName;
92
+    	$key = isset($this->packageKey) ? $this->packageKey.'_'.$this->moduleName : $this->moduleName;
93 93
 
94
-    	if(isset($this->searchFields[$key][$name]))
94
+    	if (isset($this->searchFields[$key][$name]))
95 95
     	{
96 96
     		unset($this->searchFields[$key][$name]);
97 97
     	}
@@ -103,28 +103,28 @@  discard block
 block discarded – undo
103 103
         if (!empty($this->packageName) && file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php")) //we are in Module builder
104 104
         {
105 105
 			include("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php");
106
-        } else if(file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php")) {
106
+        } else if (file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php")) {
107 107
 			include("custom/modules/{$this->moduleName}/metadata/SearchFields.php");
108
-        } else if(file_exists("modules/{$this->moduleName}/metadata/SearchFields.php")) {
108
+        } else if (file_exists("modules/{$this->moduleName}/metadata/SearchFields.php")) {
109 109
 			include("modules/{$this->moduleName}/metadata/SearchFields.php");
110 110
         }
111 111
 
112 112
         return $searchFields;
113 113
     }
114 114
 
115
-    function saveSearchFields ($searchFields)
115
+    function saveSearchFields($searchFields)
116 116
     {
117 117
         if (!empty($this->packageName)) //we are in Module builder
118 118
         {
119 119
 			$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
120
-            if(!file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php"))
120
+            if (!file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php"))
121 121
             {
122 122
                mkdir_recursive("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata");
123 123
             }
124 124
 			write_array_to_file("searchFields['{$this->packageKey}_{$this->moduleName}']", $searchFields["{$this->packageKey}_{$this->moduleName}"], "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php", 'w', $header);
125 125
         } else {
126 126
 			$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
127
-            if(!file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php"))
127
+            if (!file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php"))
128 128
             {
129 129
                mkdir_recursive("custom/modules/{$this->moduleName}/metadata");
130 130
             }
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
2
+if (! defined ( 'sugarEntry' ) || ! sugarEntry) {
3 3
     die ( 'Not A Valid Entry Point' ) ;
4
+}
4 5
 /*********************************************************************************
5 6
  * SugarCRM Community Edition is a customer relationship management program developed by
6 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -68,8 +69,7 @@  discard block
 block discarded – undo
68 69
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
69 70
         if(isset($GLOBALS['log'])) {
70 71
             $GLOBALS['log']->deprecated($deprecatedMessage);
71
-        }
72
-        else {
72
+        } else {
73 73
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
74 74
         }
75 75
         self::__construct($moduleName, $packageName);
@@ -100,9 +100,11 @@  discard block
 block discarded – undo
100 100
     function getSearchFields()
101 101
     {
102 102
     	$searchFields = array();
103
-        if (!empty($this->packageName) && file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php")) //we are in Module builder
103
+        if (!empty($this->packageName) && file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php")) {
104
+            //we are in Module builder
104 105
         {
105 106
 			include("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php");
107
+        }
106 108
         } else if(file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php")) {
107 109
 			include("custom/modules/{$this->moduleName}/metadata/SearchFields.php");
108 110
         } else if(file_exists("modules/{$this->moduleName}/metadata/SearchFields.php")) {
@@ -114,9 +116,11 @@  discard block
 block discarded – undo
114 116
 
115 117
     function saveSearchFields ($searchFields)
116 118
     {
117
-        if (!empty($this->packageName)) //we are in Module builder
119
+        if (!empty($this->packageName)) {
120
+            //we are in Module builder
118 121
         {
119 122
 			$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
123
+        }
120 124
             if(!file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php"))
121 125
             {
122 126
                mkdir_recursive("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata");
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.label.php 2 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3
-    die ( 'Not A Valid Entry Point' ) ;
2
+if (!defined('sugarEntry') || !sugarEntry)
3
+    die ('Not A Valid Entry Point');
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
6 6
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -40,24 +40,24 @@  discard block
 block discarded – undo
40 40
  ********************************************************************************/
41 41
 
42 42
 
43
-require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ;
43
+require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php');
44 44
 
45 45
 class ParserLabel //extends ModuleBuilderParser
46 46
 {
47 47
 
48
-    public function __construct ($moduleName, $packageName = '' )
48
+    public function __construct($moduleName, $packageName = '')
49 49
     {
50 50
         $this->moduleName = $moduleName;
51 51
         if (!empty($packageName))
52
-            $this->packageName = $packageName ;
52
+            $this->packageName = $packageName;
53 53
     }
54 54
 
55 55
     /**
56 56
      * @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
57 57
      */
58
-    public function ParserLabel($moduleName, $packageName = '' ){
58
+    public function ParserLabel($moduleName, $packageName = '') {
59 59
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
60
-        if(isset($GLOBALS['log'])) {
60
+        if (isset($GLOBALS['log'])) {
61 61
             $GLOBALS['log']->deprecated($deprecatedMessage);
62 62
         }
63 63
         else {
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
72 72
      * @param REQUEST $params       Labels as "label_".System label => Display label pairs
73 73
      * @param string $language      Language key, for example 'en_us'
74 74
      */
75
-    function handleSave ($params , $language)
75
+    function handleSave($params, $language)
76 76
     {
77
-        $labels = array ( ) ;
78
-        foreach ( $params as $key => $value )
77
+        $labels = array( );
78
+        foreach ($params as $key => $value)
79 79
         {
80
-            if (preg_match ( '/^label_/', $key ) && strcmp ( $value, 'no_change' ) != 0)
80
+            if (preg_match('/^label_/', $key) && strcmp($value, 'no_change') != 0)
81 81
             {
82
-                $labels [ strtoupper(substr ( $key, 6 )) ] = SugarCleaner::cleanHtml(from_html($value),false);
82
+                $labels [strtoupper(substr($key, 6))] = SugarCleaner::cleanHtml(from_html($value), false);
83 83
             }
84 84
         }
85 85
         if (!empty($this->packageName)) //we are in Module builder
86 86
         {
87
-            return self::addLabels ( $language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language" ) ;
87
+            return self::addLabels($language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language");
88 88
         } else
89 89
         {
90
-            return self::addLabels ( $language, $labels, $this->moduleName ) ;
90
+            return self::addLabels($language, $labels, $this->moduleName);
91 91
         }
92 92
     }
93 93
 
@@ -101,68 +101,68 @@  discard block
 block discarded – undo
101 101
      * @param string $forRelationshipLabel      whether this is a relationship label
102 102
      */
103 103
     static function removeLabel($language, $label, $labelvalue, $moduleName, $basepath = null, $forRelationshipLabel = false) {
104
-        $GLOBALS [ 'log' ]->debug ( "ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );" ) ;
105
-        if (is_null ( $basepath ))
104
+        $GLOBALS ['log']->debug("ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );");
105
+        if (is_null($basepath))
106 106
         {
107
-            $deployedModule = true ;
108
-            $basepath = "custom/modules/$moduleName/language" ;
109
-            if($forRelationshipLabel){
110
-            	$basepath = "custom/modules/$moduleName/Ext/Language" ;
107
+            $deployedModule = true;
108
+            $basepath = "custom/modules/$moduleName/language";
109
+            if ($forRelationshipLabel) {
110
+            	$basepath = "custom/modules/$moduleName/Ext/Language";
111 111
             }
112
-            if (! is_dir ( $basepath ))
112
+            if (!is_dir($basepath))
113 113
             {
114 114
                 $GLOBALS ['log']->debug("$basepath is not a directory.");
115 115
                 return false;
116 116
             }
117 117
         }
118 118
 
119
-        $filename = "$basepath/$language.lang.php" ;
120
-        if($forRelationshipLabel){
121
-        	$filename = "$basepath/$language.lang.ext.php" ;
119
+        $filename = "$basepath/$language.lang.php";
120
+        if ($forRelationshipLabel) {
121
+        	$filename = "$basepath/$language.lang.ext.php";
122 122
      	}
123 123
 
124
-        $dir_exists = is_dir ( $basepath ) ;
124
+        $dir_exists = is_dir($basepath);
125 125
 
126
-        $mod_strings = array ( ) ;
126
+        $mod_strings = array( );
127 127
 
128 128
         if ($dir_exists)
129 129
         {
130
-            if (file_exists ($filename))
130
+            if (file_exists($filename))
131 131
             {
132 132
                 // obtain $mod_strings
133
-                include ($filename) ;
133
+                include ($filename);
134 134
             } else {
135 135
                 $GLOBALS ['log']->debug("file $filename does not exist.");
136 136
                 return false;
137 137
             }
138 138
         } else {
139 139
             $GLOBALS ['log']->debug("directory $basepath does not exist.");
140
-            return false ;
140
+            return false;
141 141
         }
142 142
 
143
-        $changed = false ;
143
+        $changed = false;
144 144
 
145
-        if (isset($mod_strings[$label]) && $mod_strings[$label]==$labelvalue) {
145
+        if (isset($mod_strings[$label]) && $mod_strings[$label] == $labelvalue) {
146 146
             unset($mod_strings[$label]);
147 147
             $changed = true;
148 148
         }
149 149
 
150 150
         if ($changed)
151 151
         {
152
-            if (! write_array_to_file ( "mod_strings", $mod_strings, $filename )) {
153
-                $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ;
152
+            if (!write_array_to_file("mod_strings", $mod_strings, $filename)) {
153
+                $GLOBALS ['log']->fatal("Could not write $filename");
154 154
             } else {
155 155
                 // if we have a cache to worry about, then clear it now
156 156
                 if ($deployedModule) {
157
-                    $GLOBALS ['log']->debug ( "PaserLabel->addLabels: clearing language cache" ) ;
158
-                    $cache_key = "module_language." . $language . $moduleName ;
159
-                    sugar_cache_clear ( $cache_key ) ;
160
-                    LanguageManager::clearLanguageCache ( $moduleName, $language ) ;
157
+                    $GLOBALS ['log']->debug("PaserLabel->addLabels: clearing language cache");
158
+                    $cache_key = "module_language.".$language.$moduleName;
159
+                    sugar_cache_clear($cache_key);
160
+                    LanguageManager::clearLanguageCache($moduleName, $language);
161 161
                 }
162 162
             }
163 163
         }
164 164
 
165
-        return true ;
165
+        return true;
166 166
     }
167 167
 
168 168
     /*
@@ -172,79 +172,79 @@  discard block
 block discarded – undo
172 172
      * @param string $moduleName    Name of the module to which to add these labels
173 173
      * @param string $packageName   If module is undeployed, name of the package to which it belongs
174 174
      */
175
-    static function addLabels ($language , $labels , $moduleName , $basepath = null, $forRelationshipLabel = false)
175
+    static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false)
176 176
     {
177 177
 
178
-        $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );" ) ;
179
-        $GLOBALS [ 'log' ]->debug ( "\$labels:" . print_r ( $labels, true ) ) ;
178
+        $GLOBALS ['log']->debug("ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );");
179
+        $GLOBALS ['log']->debug("\$labels:".print_r($labels, true));
180 180
 
181
-        $deployedModule = false ;
182
-        if (is_null ( $basepath ))
181
+        $deployedModule = false;
182
+        if (is_null($basepath))
183 183
         {
184
-            $deployedModule = true ;
185
-            $basepath = "custom/modules/$moduleName/language" ;
186
-            if($forRelationshipLabel){
187
-            	$basepath = "custom/modules/$moduleName/Ext/Language" ;
184
+            $deployedModule = true;
185
+            $basepath = "custom/modules/$moduleName/language";
186
+            if ($forRelationshipLabel) {
187
+            	$basepath = "custom/modules/$moduleName/Ext/Language";
188 188
             }
189
-            if (! is_dir ( $basepath ))
189
+            if (!is_dir($basepath))
190 190
             {
191 191
                 mkdir_recursive($basepath);
192 192
             }
193 193
         }
194 194
 
195
-        $filename = "$basepath/$language.lang.php" ;
196
-        if($forRelationshipLabel){
197
-        	$filename = "$basepath/$language.lang.ext.php" ;
195
+        $filename = "$basepath/$language.lang.php";
196
+        if ($forRelationshipLabel) {
197
+        	$filename = "$basepath/$language.lang.ext.php";
198 198
      	}
199
-        $dir_exists = is_dir ( $basepath ) ;
199
+        $dir_exists = is_dir($basepath);
200 200
 
201
-        $mod_strings = array ( ) ;
201
+        $mod_strings = array( );
202 202
 
203 203
         if ($dir_exists)
204 204
         {
205
-            if (file_exists ( $filename ))
205
+            if (file_exists($filename))
206 206
             {
207 207
                 // obtain $mod_strings
208
-                include ($filename) ;
209
-            }else if($forRelationshipLabel){
210
-            	$fh = fopen ($filename, 'a');
208
+                include ($filename);
209
+            } else if ($forRelationshipLabel) {
210
+            	$fh = fopen($filename, 'a');
211 211
             	fclose($fh);
212 212
             }
213 213
         } else
214 214
         {
215
-            return false ;
215
+            return false;
216 216
         }
217 217
 
218
-        	$changed = false ;
218
+        	$changed = false;
219 219
 
220 220
         //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
221 221
 
222
-	        foreach ( $labels as $key => $value )
222
+	        foreach ($labels as $key => $value)
223 223
 	        {
224
-            if (! isset ( $mod_strings [ $key ] ) || strcmp ( $value, $mod_strings [ $key ] ) != 0)
224
+            if (!isset ($mod_strings [$key]) || strcmp($value, $mod_strings [$key]) != 0)
225 225
 	            {
226 226
                     $mod_strings [$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php
227
-	                $changed = true ;
227
+	                $changed = true;
228 228
 	            }
229 229
 	        }
230 230
 
231 231
 	        if ($changed)
232 232
 	        {
233
-            $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: writing new mod_strings to $filename" ) ;
234
-	            $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ;
235
-            if (! write_array_to_file ( "mod_strings", $mod_strings, $filename ))
233
+            $GLOBALS ['log']->debug("ParserLabel->addLabels: writing new mod_strings to $filename");
234
+	            $GLOBALS ['log']->debug("ParserLabel->addLabels: mod_strings=".print_r($mod_strings, true));
235
+            if (!write_array_to_file("mod_strings", $mod_strings, $filename))
236 236
 	            {
237
-                $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ;
237
+                $GLOBALS ['log']->fatal("Could not write $filename");
238 238
 	            } else
239 239
 	            {
240 240
 	                // if we have a cache to worry about, then clear it now
241 241
                 if ($deployedModule)
242 242
 	                {
243 243
                             SugarCache::cleanOpcodes();
244
-	                    $GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ;
245
-	                    $cache_key = "module_language." . $language . $moduleName ;
246
-	                    sugar_cache_clear ( $cache_key ) ;
247
-	                    LanguageManager::clearLanguageCache ( $moduleName, $language ) ;
244
+	                    $GLOBALS ['log']->debug("PaserLabel->addLabels: clearing language cache");
245
+	                    $cache_key = "module_language.".$language.$moduleName;
246
+	                    sugar_cache_clear($cache_key);
247
+	                    LanguageManager::clearLanguageCache($moduleName, $language);
248 248
 	                }
249 249
 	            }
250 250
 	        }
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
         // The changes from custom/Extension/modules/{ModuleName}/Ext/Language
259 259
         // will overwrite stuff in custom/modules/{ModuleName}/Ext/Language/en_us.lang.ext.php after
260 260
         //  Quick Repair and Rebuild is applied.
261
-        if($forRelationshipLabel) {
262
-            if(!empty($_POST[view_module]) && !empty($_POST[relationship_name]) && !empty($_POST[rhs_label]) && !empty($_POST[lhs_module])) {
261
+        if ($forRelationshipLabel) {
262
+            if (!empty($_POST[view_module]) && !empty($_POST[relationship_name]) && !empty($_POST[rhs_label]) && !empty($_POST[lhs_module])) {
263 263
                 // 1. Overwrite custom/Extension/modules/{ModuleName}/Ext/Language
264
-                $extension_basepath = "custom/Extension/modules/" . $_POST[view_module] . "/Ext/Language";
264
+                $extension_basepath = "custom/Extension/modules/".$_POST[view_module]."/Ext/Language";
265 265
                 mkdir_recursive($extension_basepath);
266 266
 
267 267
                 $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
268 268
                 $out = $headerString;
269 269
 
270
-                $extension_filename = "$extension_basepath/$language.custom" . $_POST[relationship_name] . ".php";
270
+                $extension_filename = "$extension_basepath/$language.custom".$_POST[relationship_name].".php";
271 271
 
272 272
                 $mod_strings = array();
273 273
                 if (file_exists($extension_filename)) {
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
                     $file_contents = fopen($extension_filename, 'w');
294 294
                     fputs($file_contents, $out, strlen($out));
295 295
                     fclose($file_contents);
296
-                } catch (Exception $e) {
296
+                }catch (Exception $e) {
297 297
                     $GLOBALS ['log']->fatal("Could not write $filename");
298
-                    $GLOBALS ['log']->fatal("Exception " . $e->getMessage());
298
+                    $GLOBALS ['log']->fatal("Exception ".$e->getMessage());
299 299
                     $failed_to_write = true;
300 300
                 }
301 301
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                 $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
310 310
                 $out = $headerString;
311 311
 
312
-                $relationships_filename = "$relationships_basepath/" . $_POST[lhs_module] . ".php";
312
+                $relationships_filename = "$relationships_basepath/".$_POST[lhs_module].".php";
313 313
 
314 314
 
315 315
                 $mod_strings = array();
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
                     $file_contents = fopen($relationships_filename, 'w');
337 337
                     fputs($file_contents, $out, strlen($out));
338 338
                     fclose($file_contents);
339
-                } catch (Exception $e) {
339
+                }catch (Exception $e) {
340 340
                     $GLOBALS ['log']->fatal("Could not write $filename");
341
-                    $GLOBALS ['log']->fatal("Exception " . $e->getMessage());
341
+                    $GLOBALS ['log']->fatal("Exception ".$e->getMessage());
342 342
                     $failed_to_write = true;
343 343
                 }
344 344
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                         if ($deployedModule) {
349 349
                             SugarCache::cleanOpcodes();
350 350
                             $GLOBALS ['log']->debug("PaserLabel->addLabels: clearing language cache");
351
-                            $cache_key = "module_language." . $language . $moduleName;
351
+                            $cache_key = "module_language.".$language.$moduleName;
352 352
                             sugar_cache_clear($cache_key);
353 353
                             LanguageManager::clearLanguageCache($moduleName, $language);
354 354
                         }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
         }
359 359
 
360
-        return true ;
360
+        return true;
361 361
     }
362 362
 
363 363
     /**
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
      * @param $metadata
367 367
      * @param string $language      Language key, for example 'en_us'
368 368
      */
369
-    function handleSaveRelationshipLabels ($metadata , $language)
369
+    function handleSaveRelationshipLabels($metadata, $language)
370 370
         {
371
-        foreach ( $metadata as $definition )
371
+        foreach ($metadata as $definition)
372 372
             {
373 373
         	$labels = array();
374
-        	$labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
375
-        	self::addLabels ( $language, $labels, $definition [ 'module' ],null,true );
374
+        	$labels[$definition ['system_label']] = $definition ['display_label'];
375
+        	self::addLabels($language, $labels, $definition ['module'], null, true);
376 376
             }
377 377
         }
378 378
 
379 379
     function addLabelsToAllLanguages($labels)
380 380
             {
381 381
     	$langs = get_languages();
382
-    	foreach($langs as $lang_key => $lang_display)
382
+    	foreach ($langs as $lang_key => $lang_display)
383 383
         {
384 384
     		$this->addLabels($lang_key, $labels, $this->moduleName);
385 385
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
2
+if (! defined ( 'sugarEntry' ) || ! sugarEntry) {
3 3
     die ( 'Not A Valid Entry Point' ) ;
4
+}
4 5
 /*********************************************************************************
5 6
  * SugarCRM Community Edition is a customer relationship management program developed by
6 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
     public function __construct ($moduleName, $packageName = '' )
49 50
     {
50 51
         $this->moduleName = $moduleName;
51
-        if (!empty($packageName))
52
-            $this->packageName = $packageName ;
52
+        if (!empty($packageName)) {
53
+                    $this->packageName = $packageName ;
54
+        }
53 55
     }
54 56
 
55 57
     /**
@@ -59,8 +61,7 @@  discard block
 block discarded – undo
59 61
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
60 62
         if(isset($GLOBALS['log'])) {
61 63
             $GLOBALS['log']->deprecated($deprecatedMessage);
62
-        }
63
-        else {
64
+        } else {
64 65
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
65 66
         }
66 67
         self::__construct($moduleName, $packageName);
@@ -82,9 +83,11 @@  discard block
 block discarded – undo
82 83
                 $labels [ strtoupper(substr ( $key, 6 )) ] = SugarCleaner::cleanHtml(from_html($value),false);
83 84
             }
84 85
         }
85
-        if (!empty($this->packageName)) //we are in Module builder
86
+        if (!empty($this->packageName)) {
87
+            //we are in Module builder
86 88
         {
87 89
             return self::addLabels ( $language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language" ) ;
90
+        }
88 91
         } else
89 92
         {
90 93
             return self::addLabels ( $language, $labels, $this->moduleName ) ;
@@ -206,7 +209,7 @@  discard block
 block discarded – undo
206 209
             {
207 210
                 // obtain $mod_strings
208 211
                 include ($filename) ;
209
-            }else if($forRelationshipLabel){
212
+            } else if($forRelationshipLabel){
210 213
             	$fh = fopen ($filename, 'a');
211 214
             	fclose($fh);
212 215
             }
@@ -285,8 +288,9 @@  discard block
 block discarded – undo
285 288
                     }
286 289
                 }
287 290
 
288
-                foreach ($mod_strings as $key => $val)
289
-                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);
291
+                foreach ($mod_strings as $key => $val) {
292
+                                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);
293
+                }
290 294
 
291 295
                 $failed_to_write = false;
292 296
                 try {
@@ -328,8 +332,9 @@  discard block
 block discarded – undo
328 332
                     }
329 333
                 }
330 334
 
331
-                foreach ($mod_strings as $key => $val)
332
-                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);
335
+                foreach ($mod_strings as $key => $val) {
336
+                                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);
337
+                }
333 338
 
334 339
                 $failed_to_write = false;
335 340
                 try {
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/ModuleBuilderParser.php 3 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 class ModuleBuilderParser
44 44
 {
45 45
 
46
-	var $_defMap; // private - mapping from view to variable name inside the viewdef file
47
-	var $_variables = array(); // private - set of additional variables (other than the viewdefs) found in the viewdef file that need to be added to the file again when it is saved - used by ModuleBuilder
46
+    var $_defMap; // private - mapping from view to variable name inside the viewdef file
47
+    var $_variables = array(); // private - set of additional variables (other than the viewdefs) found in the viewdef file that need to be added to the file again when it is saved - used by ModuleBuilder
48 48
 
49
-	function __construct()
50
-	{
51
-		$this->_defMap = array('listview'=>'listViewDefs','searchview'=>'searchdefs','editview'=>'viewdefs','detailview'=>'viewdefs','quickcreate'=>'viewdefs');
52
-	}
49
+    function __construct()
50
+    {
51
+        $this->_defMap = array('listview'=>'listViewDefs','searchview'=>'searchdefs','editview'=>'viewdefs','detailview'=>'viewdefs','quickcreate'=>'viewdefs');
52
+    }
53 53
 
54 54
     /**
55 55
      * @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,25 +65,25 @@  discard block
 block discarded – undo
65 65
         self::__construct();
66 66
     }
67 67
 
68
-	/*
68
+    /*
69 69
 	 * Initialize this parser
70 70
 	 */
71
-	function init ()
72
-	{
73
-	}
71
+    function init ()
72
+    {
73
+    }
74 74
 
75
-	/*
75
+    /*
76 76
 	 * Dummy function used to ease the transition to the new parser structure
77 77
 	 */
78
-	function populateFromPost()
79
-	{
80
-	}
78
+    function populateFromPost()
79
+    {
80
+    }
81 81
 
82
-	function _loadFromFile($view,$file,$moduleName)
83
-	{
82
+    function _loadFromFile($view,$file,$moduleName)
83
+    {
84 84
 
85
-		$variables = array();
86
-	    if (! file_exists($file))
85
+        $variables = array();
86
+        if (! file_exists($file))
87 87
         {
88 88
             $this->_fatalError("ModuleBuilderParser: required viewdef file {$file} does not exist");
89 89
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         foreach ($moduleVariables as $name)
100 100
         {
101 101
             if (isset($$name)) {
102
-            	$variables[$name] = $$name;
102
+                $variables[$name] = $$name;
103 103
             }
104 104
         }
105 105
         $viewVariable = $this->_defMap[strtolower($view)];
@@ -109,33 +109,33 @@  discard block
 block discarded – undo
109 109
 
110 110
         if (isset($variables['module_name']))
111 111
         {
112
-        	$mbName = $variables['module_name'];
113
-        	if ($mbName != $moduleName)
114
-        	{
115
-	        	$GLOBALS['log']->debug('ModuleBuilderParser->_loadFromFile(): tidying module names from '.$mbName.' to '.$moduleName);
116
-	        	$defs[$moduleName] = $defs[$mbName];
117
-	        	unset($defs[$mbName]);
118
-        	}
112
+            $mbName = $variables['module_name'];
113
+            if ($mbName != $moduleName)
114
+            {
115
+                $GLOBALS['log']->debug('ModuleBuilderParser->_loadFromFile(): tidying module names from '.$mbName.' to '.$moduleName);
116
+                $defs[$moduleName] = $defs[$mbName];
117
+                unset($defs[$mbName]);
118
+            }
119 119
         }
120 120
 //	    $GLOBALS['log']->debug('ModuleBuilderParser->_loadFromFile(): '.print_r($defs,true));
121 121
         return (array('viewdefs' => $defs, 'variables' => $variables));
122
-	}
122
+    }
123 123
 
124
-	function handleSave ($file,$view,$moduleName,$defs)
125
-	{
126
-	}
124
+    function handleSave ($file,$view,$moduleName,$defs)
125
+    {
126
+    }
127 127
 
128 128
 
129
-	/*
129
+    /*
130 130
 	 * Save the new layout
131 131
 	 */
132
-	function _writeToFile ($file,$view,$moduleName,$defs,$variables)
133
-	{
134
-	        if(file_exists($file))
135
-	            unlink($file);
132
+    function _writeToFile ($file,$view,$moduleName,$defs,$variables)
133
+    {
134
+            if(file_exists($file))
135
+                unlink($file);
136 136
 
137
-	        mkdir_recursive ( dirname ( $file ) ) ;
138
-	        $GLOBALS['log']->debug("ModuleBuilderParser->_writeFile(): file=".$file);
137
+            mkdir_recursive ( dirname ( $file ) ) ;
138
+            $GLOBALS['log']->debug("ModuleBuilderParser->_writeFile(): file=".$file);
139 139
             $useVariables = (count($variables)>0);
140 140
             if( $fh = @sugar_fopen( $file, 'w' ) )
141 141
             {
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
                     // write out the $<variable>=<modulename> lines
146 146
                     foreach($variables as $key=>$value)
147 147
                     {
148
-                    	$out .= "\$$key = '".$value."';\n";
148
+                        $out .= "\$$key = '".$value."';\n";
149 149
                     }
150 150
                 }
151 151
 
152 152
                 // write out the defs array itself
153 153
                 switch (strtolower($view))
154 154
                 {
155
-                	case 'editview':
156
-                	case 'detailview':
157
-                	case 'quickcreate':
158
-                		$defs = array($view => $defs);
159
-                		break;
160
-                	default:
161
-                		break;
155
+                    case 'editview':
156
+                    case 'detailview':
157
+                    case 'quickcreate':
158
+                        $defs = array($view => $defs);
159
+                        break;
160
+                    default:
161
+                        break;
162 162
                 }
163 163
                 $viewVariable = $this->_defMap[strtolower($view)];
164 164
                 $out .= "\$$viewVariable = ";
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                 // tidy up the parenthesis
168 168
                 if ($useVariables)
169 169
                 {
170
-                	$out .= "\n)";
170
+                    $out .= "\n)";
171 171
                 }
172 172
                 $out .= ";\n?>\n";
173 173
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             {
180 180
                 $GLOBALS['log']->fatal("ModuleBuilderParser->_writeFile() Could not write new viewdef file ".$file);
181 181
             }
182
-	}
182
+    }
183 183
 
184 184
 
185 185
     function _fatalError ($msg)
Please login to merge, or discard this patch.
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
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 
49 49
 	function __construct()
50 50
 	{
51
-		$this->_defMap = array('listview'=>'listViewDefs','searchview'=>'searchdefs','editview'=>'viewdefs','detailview'=>'viewdefs','quickcreate'=>'viewdefs');
51
+		$this->_defMap = array('listview'=>'listViewDefs', 'searchview'=>'searchdefs', 'editview'=>'viewdefs', 'detailview'=>'viewdefs', 'quickcreate'=>'viewdefs');
52 52
 	}
53 53
 
54 54
     /**
55 55
      * @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
56 56
      */
57
-    function ModuleBuilderParser(){
57
+    function ModuleBuilderParser() {
58 58
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
59
-        if(isset($GLOBALS['log'])) {
59
+        if (isset($GLOBALS['log'])) {
60 60
             $GLOBALS['log']->deprecated($deprecatedMessage);
61 61
         }
62 62
         else {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	/*
69 69
 	 * Initialize this parser
70 70
 	 */
71
-	function init ()
71
+	function init()
72 72
 	{
73 73
 	}
74 74
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 	}
81 81
 
82
-	function _loadFromFile($view,$file,$moduleName)
82
+	function _loadFromFile($view, $file, $moduleName)
83 83
 	{
84 84
 
85 85
 		$variables = array();
86
-	    if (! file_exists($file))
86
+	    if (!file_exists($file))
87 87
         {
88 88
             $this->_fatalError("ModuleBuilderParser: required viewdef file {$file} does not exist");
89 89
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         // This is a format used by ModuleBuilder templated modules to speed the renaming of modules
96 96
         // Traditional Sugar modules don't use this format
97 97
         // We must do this in ParserModifyLayout (rather than just in ParserBuildLayout) because we might be editing the layout of a MB created module in Studio after it has been deployed
98
-        $moduleVariables = array('module_name','_module_name', 'OBJECT_NAME', '_object_name');
98
+        $moduleVariables = array('module_name', '_module_name', 'OBJECT_NAME', '_object_name');
99 99
         foreach ($moduleVariables as $name)
100 100
         {
101 101
             if (isset($$name)) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         return (array('viewdefs' => $defs, 'variables' => $variables));
122 122
 	}
123 123
 
124
-	function handleSave ($file,$view,$moduleName,$defs)
124
+	function handleSave($file, $view, $moduleName, $defs)
125 125
 	{
126 126
 	}
127 127
 
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
 	/*
130 130
 	 * Save the new layout
131 131
 	 */
132
-	function _writeToFile ($file,$view,$moduleName,$defs,$variables)
132
+	function _writeToFile($file, $view, $moduleName, $defs, $variables)
133 133
 	{
134
-	        if(file_exists($file))
134
+	        if (file_exists($file))
135 135
 	            unlink($file);
136 136
 
137
-	        mkdir_recursive ( dirname ( $file ) ) ;
137
+	        mkdir_recursive(dirname($file));
138 138
 	        $GLOBALS['log']->debug("ModuleBuilderParser->_writeFile(): file=".$file);
139
-            $useVariables = (count($variables)>0);
140
-            if( $fh = @sugar_fopen( $file, 'w' ) )
139
+            $useVariables = (count($variables) > 0);
140
+            if ($fh = @sugar_fopen($file, 'w'))
141 141
             {
142 142
                 $out = "<?php\n";
143 143
                 if ($useVariables)
144 144
                 {
145 145
                     // write out the $<variable>=<modulename> lines
146
-                    foreach($variables as $key=>$value)
146
+                    foreach ($variables as $key=>$value)
147 147
                     {
148 148
                     	$out .= "\$$key = '".$value."';\n";
149 149
                     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                 }
163 163
                 $viewVariable = $this->_defMap[strtolower($view)];
164 164
                 $out .= "\$$viewVariable = ";
165
-                $out .= ($useVariables) ? "array (\n\$module_name =>\n".var_export_helper($defs) : var_export_helper( array($moduleName => $defs) );
165
+                $out .= ($useVariables) ? "array (\n\$module_name =>\n".var_export_helper($defs) : var_export_helper(array($moduleName => $defs));
166 166
 
167 167
                 // tidy up the parenthesis
168 168
                 if ($useVariables)
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
                 $out .= ";\n?>\n";
173 173
 
174 174
 //           $GLOBALS['log']->debug("parser.modifylayout.php->_writeFile(): out=".print_r($out,true));
175
-            fputs( $fh, $out);
176
-            fclose( $fh );
175
+            fputs($fh, $out);
176
+            fclose($fh);
177 177
             }
178 178
             else
179 179
             {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 
185
-    function _fatalError ($msg)
185
+    function _fatalError($msg)
186 186
     {
187 187
         $GLOBALS ['log']->fatal($msg);
188 188
         echo $msg;
Please login to merge, or discard this patch.
Braces   +8 added lines, -7 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.
@@ -58,8 +60,7 @@  discard block
 block discarded – undo
58 60
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
59 61
         if(isset($GLOBALS['log'])) {
60 62
             $GLOBALS['log']->deprecated($deprecatedMessage);
61
-        }
62
-        else {
63
+        } else {
63 64
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
64 65
         }
65 66
         self::__construct();
@@ -131,8 +132,9 @@  discard block
 block discarded – undo
131 132
 	 */
132 133
 	function _writeToFile ($file,$view,$moduleName,$defs,$variables)
133 134
 	{
134
-	        if(file_exists($file))
135
-	            unlink($file);
135
+	        if(file_exists($file)) {
136
+	        	            unlink($file);
137
+	        }
136 138
 
137 139
 	        mkdir_recursive ( dirname ( $file ) ) ;
138 140
 	        $GLOBALS['log']->debug("ModuleBuilderParser->_writeFile(): file=".$file);
@@ -174,8 +176,7 @@  discard block
 block discarded – undo
174 176
 //           $GLOBALS['log']->debug("parser.modifylayout.php->_writeFile(): out=".print_r($out,true));
175 177
             fputs( $fh, $out);
176 178
             fclose( $fh );
177
-            }
178
-            else
179
+            } else
179 180
             {
180 181
                 $GLOBALS['log']->fatal("ModuleBuilderParser->_writeFile() Could not write new viewdef file ".$file);
181 182
             }
Please login to merge, or discard this patch.
modules/Relationships/RelationshipHandler.php 3 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -48,30 +48,30 @@  discard block
 block discarded – undo
48 48
 
49 49
 class RelationshipHandler extends Relationship {
50 50
 
51
-	var $db;							//Database link by reference
51
+    var $db;							//Database link by reference
52 52
 
53
-	var $base_module;					//name of module
54
-	var $base_bean;						//actual object
55
-	var $base_vardef_field;				//base's vardef field name of relationship with rel1
53
+    var $base_module;					//name of module
54
+    var $base_bean;						//actual object
55
+    var $base_vardef_field;				//base's vardef field name of relationship with rel1
56 56
 
57
-	var $rel1_module;					//name of related module
58
-	var $rel1_bean;						//actual related object
59
-	var $rel1_relationship_name;		//Relationship name between base and rel1
60
-	var $rel1_vardef_field;				//rel1's vardef field name of relationship with rel2
61
-	var $rel1_vardef_field_base;		//rel1's vardef field name of relationship with base
57
+    var $rel1_module;					//name of related module
58
+    var $rel1_bean;						//actual related object
59
+    var $rel1_relationship_name;		//Relationship name between base and rel1
60
+    var $rel1_vardef_field;				//rel1's vardef field name of relationship with rel2
61
+    var $rel1_vardef_field_base;		//rel1's vardef field name of relationship with base
62 62
 
63
-	var $rel2_module;					//name of related related module
64
-	var $rel2_bean;						//actual related related object
65
-	var $rel2_relationship_name;		//Relationship name between rel1 and rel2
66
-	var $rel2_vardef_field;				//rel2's vardef field name of relationship with rel1
63
+    var $rel2_module;					//name of related related module
64
+    var $rel2_bean;						//actual related related object
65
+    var $rel2_relationship_name;		//Relationship name between rel1 and rel2
66
+    var $rel2_vardef_field;				//rel2's vardef field name of relationship with rel1
67 67
 
68 68
 
69
-	var $base_array;					//Info array
70
-	var $rel1_array;					//Info array
71
-	var $rel2_array;					//Info array
69
+    var $base_array;					//Info array
70
+    var $rel1_array;					//Info array
71
+    var $rel2_array;					//Info array
72 72
 
73 73
 
74
-	/*
74
+    /*
75 75
 
76 76
 	info arrays contain:
77 77
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
 ///////////////////////////Setup and populate functions//////////////////////////////
87 87
 
88
-	function __construct(& $db, $base_module=""){
88
+    function __construct(& $db, $base_module=""){
89 89
 
90
-		$this->db = $db;
91
-		$this->base_module = $base_module;
90
+        $this->db = $db;
91
+        $this->base_module = $base_module;
92 92
 
93
-	//end function RelationshipHandler
94
-	}
93
+    //end function RelationshipHandler
94
+    }
95 95
 
96 96
     /**
97 97
      * @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
@@ -108,25 +108,25 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
 
111
-	function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){
111
+    function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){
112 112
 
113
-		$this->base_vardef_field = $base_vardef_field;
114
-		$this->rel1_vardef_field = $rel1_vardef_field;
113
+        $this->base_vardef_field = $base_vardef_field;
114
+        $this->rel1_vardef_field = $rel1_vardef_field;
115 115
 
116
-	//end function set_rel_vardef_fields
117
-	}
116
+    //end function set_rel_vardef_fields
117
+    }
118 118
 
119 119
 
120
-	function set_rel_relationship_names($build_rel2=false){
120
+    function set_rel_relationship_names($build_rel2=false){
121 121
 
122
-		$this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship'];
122
+        $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship'];
123 123
 
124
-	if($build_rel2==true){
125
-		$this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship'];
126
-	}
124
+    if($build_rel2==true){
125
+        $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship'];
126
+    }
127 127
 
128
-	//end function set_rel_relationship_names
129
-	}
128
+    //end function set_rel_relationship_names
129
+    }
130 130
 
131 131
 
132 132
 
@@ -134,131 +134,131 @@  discard block
 block discarded – undo
134 134
 ///////////////////////////////END Setup and populate functions/////////////////////
135 135
 
136 136
 
137
-	/*
137
+    /*
138 138
 	set the build_rel2 to true if you want the rel2 info array as well
139 139
 	This function will build all the relationship info it can based on values set in the setup functions
140 140
 	When you use the info arrays (rel1_array) or (rel2_array), make sure you always check for empty values
141 141
 	*/
142
-	function build_info($build_rel2=false){
143
-		if($this->base_bean == null){
144
-			$this->base_bean = get_module_info($this->base_module);
145
-		}
142
+    function build_info($build_rel2=false){
143
+        if($this->base_bean == null){
144
+            $this->base_bean = get_module_info($this->base_module);
145
+        }
146 146
 
147
-		if(empty($this->rel1_bean)){
148
-			$this->build_rel1_info();
149
-			$this->rel1_module = $this->rel1_bean->module_dir;
150
-		}
147
+        if(empty($this->rel1_bean)){
148
+            $this->build_rel1_info();
149
+            $this->rel1_module = $this->rel1_bean->module_dir;
150
+        }
151 151
 
152
-		if($build_rel2==true && $this->rel2_bean==""){
153
-			$this->build_rel2_info();
154
-			$this->rel2_module = $this->rel2_bean->module_dir;
155
-		}
152
+        if($build_rel2==true && $this->rel2_bean==""){
153
+            $this->build_rel2_info();
154
+            $this->rel2_module = $this->rel2_bean->module_dir;
155
+        }
156 156
 
157
-		//translate the module titles to the proper language
158
-		$this->build_module_labels($build_rel2);
157
+        //translate the module titles to the proper language
158
+        $this->build_module_labels($build_rel2);
159 159
 
160
-	//end function build_info
161
-	}
160
+    //end function build_info
161
+    }
162 162
 
163
-	function build_rel1_info(){
163
+    function build_rel1_info(){
164 164
 
165
-			$this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field);
165
+            $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field);
166 166
 
167
-	//end function build_rel1_info
168
-	}
167
+    //end function build_rel1_info
168
+    }
169 169
 
170
-	function build_rel2_info(){
170
+    function build_rel2_info(){
171 171
 
172
-			$this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field);
172
+            $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field);
173 173
 
174
-	//end function build_rel1_info
175
-	}
174
+    //end function build_rel1_info
175
+    }
176 176
 
177
-	/*
177
+    /*
178 178
 	Translates the module names to their singular and plural label and puts them in
179 179
 	the info arrays.  Does it for base, rel1, and rel2 if specified
180 180
 	*/
181 181
 
182
-	function build_module_labels($build_rel2=false){
183
-		global $app_list_strings;
182
+    function build_module_labels($build_rel2=false){
183
+        global $app_list_strings;
184 184
 
185
-		///Base Module Labels
186
-		if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){
187
-			$this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir];
188
-		} else {
189
-			$this->base_array['plabel'] = $this->base_bean->module_dir;
190
-		}
191
-		if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){
192
-			$this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir];
193
-		} else {
194
-			$this->base_array['slabel'] = $this->base_bean->object_name;
195
-		}
185
+        ///Base Module Labels
186
+        if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){
187
+            $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir];
188
+        } else {
189
+            $this->base_array['plabel'] = $this->base_bean->module_dir;
190
+        }
191
+        if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){
192
+            $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir];
193
+        } else {
194
+            $this->base_array['slabel'] = $this->base_bean->object_name;
195
+        }
196 196
 
197
-		///Rel1 Module Labels
198
-		if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){
199
-			$this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir];
200
-		} else {
201
-			$this->rel1_array['plabel'] = $this->rel1_bean->module_dir;
202
-		}
197
+        ///Rel1 Module Labels
198
+        if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){
199
+            $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir];
200
+        } else {
201
+            $this->rel1_array['plabel'] = $this->rel1_bean->module_dir;
202
+        }
203 203
 
204
-		if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){
205
-			$this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir];
206
-		} else {
207
-			$this->rel1_array['slabel'] = $this->rel1_bean->object_name;
208
-		}
204
+        if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){
205
+            $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir];
206
+        } else {
207
+            $this->rel1_array['slabel'] = $this->rel1_bean->object_name;
208
+        }
209 209
 
210 210
 
211
-		//Rel2 Module Labels
212
-		if($build_rel2==true){
211
+        //Rel2 Module Labels
212
+        if($build_rel2==true){
213 213
 
214
-			if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){
215
-				$this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir];
216
-			} else {
217
-				$this->rel2_array['plabel'] = $this->rel2_bean->module_dir;
218
-			}
219
-			if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){
220
-				$this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir];
221
-			} else {
222
-				$this->rel2_array['slabel'] = $this->rel2_bean->module_dir;
223
-			}
224
-		//end if build_rel2 is true
225
-		}
214
+            if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){
215
+                $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir];
216
+            } else {
217
+                $this->rel2_array['plabel'] = $this->rel2_bean->module_dir;
218
+            }
219
+            if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){
220
+                $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir];
221
+            } else {
222
+                $this->rel2_array['slabel'] = $this->rel2_bean->module_dir;
223
+            }
224
+        //end if build_rel2 is true
225
+        }
226 226
 
227
-	//end function buld_module_lables
228
-	}
227
+    //end function buld_module_lables
228
+    }
229 229
 
230 230
 
231 231
 
232 232
 
233 233
 
234
-	function build_related_list($type="base"){
235
-		//type can be base, rel1
234
+    function build_related_list($type="base"){
235
+        //type can be base, rel1
236 236
 
237
-		$target_list = "";
237
+        $target_list = "";
238 238
 
239
-		if($type=="base"){
240
-			$target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name);
241
-		//Possibility exists that this is a new relationship, so capture via relationship fields
242
-			if(empty($target_list)){
243
-				$target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field);
244
-			//end if the target list is empty
245
-			}
246
-		}
239
+        if($type=="base"){
240
+            $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name);
241
+        //Possibility exists that this is a new relationship, so capture via relationship fields
242
+            if(empty($target_list)){
243
+                $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field);
244
+            //end if the target list is empty
245
+            }
246
+        }
247 247
 
248
-		if($type=="rel1"){
249
-			$target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name);
248
+        if($type=="rel1"){
249
+            $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name);
250 250
 
251
-			//Possibility exists that this is a new relationship, so capture via relationship fields
252
-			if(empty($target_list)){
253
-				$target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field);
254
-			//end if the target list is empty
255
-			}
256
-		}
251
+            //Possibility exists that this is a new relationship, so capture via relationship fields
252
+            if(empty($target_list)){
253
+                $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field);
254
+            //end if the target list is empty
255
+            }
256
+        }
257 257
 
258
-		return $target_list;
258
+        return $target_list;
259 259
 
260
-	//end function build_related_list
261
-	}
260
+    //end function build_related_list
261
+    }
262 262
 
263 263
 
264 264
 
@@ -267,100 +267,100 @@  discard block
 block discarded – undo
267 267
 
268 268
 function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false){
269 269
 
270
-	$target_module_name = $target_bean->module_dir;
271
-	$current_module_name = $this->base_module;
270
+    $target_module_name = $target_bean->module_dir;
271
+    $current_module_name = $this->base_module;
272 272
 
273
-	//Look for downstream connection
274
-	$rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db);
273
+    //Look for downstream connection
274
+    $rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db);
275 275
 
276 276
 
277
-	//Does a downstream relationship exist
278
-	if($rel_array!=null){
279
-		if($rel_array['relationship_type']=="many-to-many"){
280
-			$joinKeyLHS = $rel_array['join_key_lhs'];
281
-			$target_bean->$joinKeyLHS = $this->base_bean->id;
282
-			if($rel_array['relationship_role_column']!=""){
283
-				$relRole = $rel_array['relationship_role_column'];
284
-				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
285
-			}				
286
-		//end if many-to-many	
287
-		}	
277
+    //Does a downstream relationship exist
278
+    if($rel_array!=null){
279
+        if($rel_array['relationship_type']=="many-to-many"){
280
+            $joinKeyLHS = $rel_array['join_key_lhs'];
281
+            $target_bean->$joinKeyLHS = $this->base_bean->id;
282
+            if($rel_array['relationship_role_column']!=""){
283
+                $relRole = $rel_array['relationship_role_column'];
284
+                $target_bean->$relRole = $rel_array['relationship_role_column_value'];
285
+            }				
286
+        //end if many-to-many	
287
+        }	
288 288
 		
289
-		if($rel_array['relationship_type']=="one-to-many"){
290
-			$RHSKey = $rel_array['rhs_key'];
291
-			$target_bean->$RHSKey = $this->base_bean->id;
292
-			if($rel_array['relationship_role_column']!=""){
293
-				$relRole = $rel_array['relationship_role_column'];
294
-				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
295
-			}
296
-		//end if one-to-many
297
-		}
298
-
299
-		return;
300
-	//end if downstream relationship exists
301
-	}
302
-
303
-
304
-
305
-	//Look for upstream connection
306
-	$rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db);
307
-
308
-	//Does an upstream relationship exist
309
-	if($rel_array!=null){
310
-		if($rel_array['relationship_type']=="many-to-many"){
311
-			$joinKeyRHS = $rel_array['join_key_rhs'];
312
-			$target_bean->$joinKeyRHS = $this->base_bean->id;
313
-			if($rel_array['relationship_role_column']!=""){
314
-				$relRole = $rel_array['relationship_role_column'];
315
-				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
316
-			}				
317
-		//end if many-to-many	
318
-		}	
289
+        if($rel_array['relationship_type']=="one-to-many"){
290
+            $RHSKey = $rel_array['rhs_key'];
291
+            $target_bean->$RHSKey = $this->base_bean->id;
292
+            if($rel_array['relationship_role_column']!=""){
293
+                $relRole = $rel_array['relationship_role_column'];
294
+                $target_bean->$relRole = $rel_array['relationship_role_column_value'];
295
+            }
296
+        //end if one-to-many
297
+        }
298
+
299
+        return;
300
+    //end if downstream relationship exists
301
+    }
302
+
303
+
304
+
305
+    //Look for upstream connection
306
+    $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db);
307
+
308
+    //Does an upstream relationship exist
309
+    if($rel_array!=null){
310
+        if($rel_array['relationship_type']=="many-to-many"){
311
+            $joinKeyRHS = $rel_array['join_key_rhs'];
312
+            $target_bean->$joinKeyRHS = $this->base_bean->id;
313
+            if($rel_array['relationship_role_column']!=""){
314
+                $relRole = $rel_array['relationship_role_column'];
315
+                $target_bean->$relRole = $rel_array['relationship_role_column_value'];
316
+            }				
317
+        //end if many-to-many	
318
+        }	
319 319
 		
320
-		if($rel_array['relationship_type']=="one-to-many"){
321
-			$RHSKey = $rel_array['rhs_key'];
322
-			$target_bean->$RHSKey = $this->base_bean->id;
323
-			if($rel_array['relationship_role_column']!=""){
324
-				$relRole = $rel_array['relationship_role_column'];
325
-				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
326
-			}
327
-		//end if one-to-many
328
-		}
329
-
330
-
331
-		///Fill additional id field if necessary
332
-		if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){
333
-			$target_bean->$id_name = $this->base_bean->id;
320
+        if($rel_array['relationship_type']=="one-to-many"){
321
+            $RHSKey = $rel_array['rhs_key'];
322
+            $target_bean->$RHSKey = $this->base_bean->id;
323
+            if($rel_array['relationship_role_column']!=""){
324
+                $relRole = $rel_array['relationship_role_column'];
325
+                $target_bean->$relRole = $rel_array['relationship_role_column_value'];
326
+            }
327
+        //end if one-to-many
328
+        }
329
+
330
+
331
+        ///Fill additional id field if necessary
332
+        if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){
333
+            $target_bean->$id_name = $this->base_bean->id;
334 334
             if($get_upstream_rel_field_name) {
335 335
                 $target_bean->new_rel_relname = $id_name;
336 336
                 $target_bean->new_rel_id = $this->base_bean->id;
337 337
             }
338
-		}
338
+        }
339 339
 
340
-	//end if an upstream relationship exists
341
-	}
340
+    //end if an upstream relationship exists
341
+    }
342 342
 
343 343
 //end function get_relationship_information
344 344
 }
345 345
 
346 346
 function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){
347
-	$id_name = null;
347
+    $id_name = null;
348 348
 
349
-	//returns name of variable to store id in
350
-	//if none exists, then returns null
351
-	foreach($target_bean->field_defs as $field_array){
349
+    //returns name of variable to store id in
350
+    //if none exists, then returns null
351
+    foreach($target_bean->field_defs as $field_array){
352 352
 
353
-		if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){
353
+        if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){
354 354
 
355
-			$id_name = $this->get_id_name($target_bean, $field_array['name']);
356
-			return $id_name;
357
-		//end if rel name match
358
-		}
355
+            $id_name = $this->get_id_name($target_bean, $field_array['name']);
356
+            return $id_name;
357
+        //end if rel name match
358
+        }
359 359
 
360
-	//end foreach field def
361
-	}
360
+    //end foreach field def
361
+    }
362 362
 
363
-	return null;
363
+    return null;
364 364
 
365 365
 //end function traverse_rel_meta
366 366
 }
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
 
369 369
 function get_id_name(& $target_bean, $field_name){
370 370
 
371
-	foreach($target_bean->relationship_fields as $target_id => $rel_name){
371
+    foreach($target_bean->relationship_fields as $target_id => $rel_name){
372 372
 
373
-		if($rel_name == $field_name){
374
-			//relationship id found
375
-			return $target_id;
376
-		//end if match
377
-		}
378
-	//end foreach
379
-	}
373
+        if($rel_name == $field_name){
374
+            //relationship id found
375
+            return $target_id;
376
+        //end if match
377
+        }
378
+    //end foreach
379
+    }
380 380
 
381
-	return null;
381
+    return null;
382 382
 //end function get_id_name
383 383
 }
384 384
 
@@ -387,27 +387,27 @@  discard block
 block discarded – undo
387 387
 
388 388
 function process_by_rel_bean($rel1_module){
389 389
 
390
-	$this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db);
391
-	$this->rel1_module = $rel1_module;
392
-	$this->rel1_bean = get_module_info($this->rel1_module);
390
+    $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db);
391
+    $this->rel1_module = $rel1_module;
392
+    $this->rel1_bean = get_module_info($this->rel1_module);
393 393
 
394 394
 //end function process_by_rel_bean
395 395
 }
396 396
 
397 397
 
398 398
 function get_rel1_vardef_field_base($field_defs){
399
-	foreach($field_defs as $field_array){
399
+    foreach($field_defs as $field_array){
400 400
 
401
-		if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){
401
+        if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){
402 402
 
403
-			$this->rel1_vardef_field_base = $field_array['name'];
404
-		//end if rel name match
405
-		}
403
+            $this->rel1_vardef_field_base = $field_array['name'];
404
+        //end if rel name match
405
+        }
406 406
 
407
-	//end foreach field def
408
-	}
407
+    //end foreach field def
408
+    }
409 409
 
410
-	return null;
410
+    return null;
411 411
 
412 412
 
413 413
 //end get_rel1_vardef_field_base
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 
417 417
 function get_farthest_reach(){
418 418
 
419
-	if($this->rel1_vardef_field!=""){
420
-		//the farthest reach is rel2
421
-		$this->build_info(true);
422
-		return $this->rel2_bean;
423
-	}
419
+    if($this->rel1_vardef_field!=""){
420
+        //the farthest reach is rel2
421
+        $this->build_info(true);
422
+        return $this->rel2_bean;
423
+    }
424 424
 
425
-	//the farthest reach is rel1
426
-	$this->build_info(false);
427
-	return $this->rel1_bean;
425
+    //the farthest reach is rel1
426
+    $this->build_info(false);
427
+    return $this->rel1_bean;
428 428
 
429 429
 //end function get_farthest_reach
430 430
 }
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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.
@@ -48,27 +48,27 @@  discard block
 block discarded – undo
48 48
 
49 49
 class RelationshipHandler extends Relationship {
50 50
 
51
-	var $db;							//Database link by reference
51
+	var $db; //Database link by reference
52 52
 
53
-	var $base_module;					//name of module
54
-	var $base_bean;						//actual object
55
-	var $base_vardef_field;				//base's vardef field name of relationship with rel1
53
+	var $base_module; //name of module
54
+	var $base_bean; //actual object
55
+	var $base_vardef_field; //base's vardef field name of relationship with rel1
56 56
 
57
-	var $rel1_module;					//name of related module
58
-	var $rel1_bean;						//actual related object
59
-	var $rel1_relationship_name;		//Relationship name between base and rel1
60
-	var $rel1_vardef_field;				//rel1's vardef field name of relationship with rel2
61
-	var $rel1_vardef_field_base;		//rel1's vardef field name of relationship with base
57
+	var $rel1_module; //name of related module
58
+	var $rel1_bean; //actual related object
59
+	var $rel1_relationship_name; //Relationship name between base and rel1
60
+	var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2
61
+	var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base
62 62
 
63
-	var $rel2_module;					//name of related related module
64
-	var $rel2_bean;						//actual related related object
65
-	var $rel2_relationship_name;		//Relationship name between rel1 and rel2
66
-	var $rel2_vardef_field;				//rel2's vardef field name of relationship with rel1
63
+	var $rel2_module; //name of related related module
64
+	var $rel2_bean; //actual related related object
65
+	var $rel2_relationship_name; //Relationship name between rel1 and rel2
66
+	var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1
67 67
 
68 68
 
69
-	var $base_array;					//Info array
70
-	var $rel1_array;					//Info array
71
-	var $rel2_array;					//Info array
69
+	var $base_array; //Info array
70
+	var $rel1_array; //Info array
71
+	var $rel2_array; //Info array
72 72
 
73 73
 
74 74
 	/*
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 ///////////////////////////Setup and populate functions//////////////////////////////
87 87
 
88
-	function __construct(& $db, $base_module=""){
88
+	function __construct(& $db, $base_module = "") {
89 89
 
90 90
 		$this->db = $db;
91 91
 		$this->base_module = $base_module;
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * @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
98 98
      */
99
-    function RelationshipHandler(& $db, $base_module=""){
99
+    function RelationshipHandler(& $db, $base_module = "") {
100 100
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
101
-        if(isset($GLOBALS['log'])) {
101
+        if (isset($GLOBALS['log'])) {
102 102
             $GLOBALS['log']->deprecated($deprecatedMessage);
103 103
         }
104 104
         else {
105 105
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
106 106
         }
107
-        self::__construct( $db, $base_module);
107
+        self::__construct($db, $base_module);
108 108
     }
109 109
 
110 110
 
111
-	function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){
111
+	function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field = "") {
112 112
 
113 113
 		$this->base_vardef_field = $base_vardef_field;
114 114
 		$this->rel1_vardef_field = $rel1_vardef_field;
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	}
118 118
 
119 119
 
120
-	function set_rel_relationship_names($build_rel2=false){
120
+	function set_rel_relationship_names($build_rel2 = false) {
121 121
 
122 122
 		$this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship'];
123 123
 
124
-	if($build_rel2==true){
124
+	if ($build_rel2 == true) {
125 125
 		$this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship'];
126 126
 	}
127 127
 
@@ -139,17 +139,17 @@  discard block
 block discarded – undo
139 139
 	This function will build all the relationship info it can based on values set in the setup functions
140 140
 	When you use the info arrays (rel1_array) or (rel2_array), make sure you always check for empty values
141 141
 	*/
142
-	function build_info($build_rel2=false){
143
-		if($this->base_bean == null){
142
+	function build_info($build_rel2 = false) {
143
+		if ($this->base_bean == null) {
144 144
 			$this->base_bean = get_module_info($this->base_module);
145 145
 		}
146 146
 
147
-		if(empty($this->rel1_bean)){
147
+		if (empty($this->rel1_bean)) {
148 148
 			$this->build_rel1_info();
149 149
 			$this->rel1_module = $this->rel1_bean->module_dir;
150 150
 		}
151 151
 
152
-		if($build_rel2==true && $this->rel2_bean==""){
152
+		if ($build_rel2 == true && $this->rel2_bean == "") {
153 153
 			$this->build_rel2_info();
154 154
 			$this->rel2_module = $this->rel2_bean->module_dir;
155 155
 		}
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	//end function build_info
161 161
 	}
162 162
 
163
-	function build_rel1_info(){
163
+	function build_rel1_info() {
164 164
 
165 165
 			$this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field);
166 166
 
167 167
 	//end function build_rel1_info
168 168
 	}
169 169
 
170
-	function build_rel2_info(){
170
+	function build_rel2_info() {
171 171
 
172 172
 			$this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field);
173 173
 
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
 	the info arrays.  Does it for base, rel1, and rel2 if specified
180 180
 	*/
181 181
 
182
-	function build_module_labels($build_rel2=false){
182
+	function build_module_labels($build_rel2 = false) {
183 183
 		global $app_list_strings;
184 184
 
185 185
 		///Base Module Labels
186
-		if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){
186
+		if (!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])) {
187 187
 			$this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir];
188 188
 		} else {
189 189
 			$this->base_array['plabel'] = $this->base_bean->module_dir;
190 190
 		}
191
-		if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){
191
+		if (!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])) {
192 192
 			$this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir];
193 193
 		} else {
194 194
 			$this->base_array['slabel'] = $this->base_bean->object_name;
195 195
 		}
196 196
 
197 197
 		///Rel1 Module Labels
198
-		if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){
198
+		if (!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])) {
199 199
 			$this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir];
200 200
 		} else {
201 201
 			$this->rel1_array['plabel'] = $this->rel1_bean->module_dir;
202 202
 		}
203 203
 
204
-		if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){
204
+		if (!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])) {
205 205
 			$this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir];
206 206
 		} else {
207 207
 			$this->rel1_array['slabel'] = $this->rel1_bean->object_name;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 		//Rel2 Module Labels
212
-		if($build_rel2==true){
212
+		if ($build_rel2 == true) {
213 213
 
214
-			if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){
214
+			if (!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])) {
215 215
 				$this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir];
216 216
 			} else {
217 217
 				$this->rel2_array['plabel'] = $this->rel2_bean->module_dir;
218 218
 			}
219
-			if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){
219
+			if (!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])) {
220 220
 				$this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir];
221 221
 			} else {
222 222
 				$this->rel2_array['slabel'] = $this->rel2_bean->module_dir;
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
 
232 232
 
233 233
 
234
-	function build_related_list($type="base"){
234
+	function build_related_list($type = "base") {
235 235
 		//type can be base, rel1
236 236
 
237 237
 		$target_list = "";
238 238
 
239
-		if($type=="base"){
239
+		if ($type == "base") {
240 240
 			$target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name);
241 241
 		//Possibility exists that this is a new relationship, so capture via relationship fields
242
-			if(empty($target_list)){
242
+			if (empty($target_list)) {
243 243
 				$target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field);
244 244
 			//end if the target list is empty
245 245
 			}
246 246
 		}
247 247
 
248
-		if($type=="rel1"){
248
+		if ($type == "rel1") {
249 249
 			$target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name);
250 250
 
251 251
 			//Possibility exists that this is a new relationship, so capture via relationship fields
252
-			if(empty($target_list)){
252
+			if (empty($target_list)) {
253 253
 				$target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field);
254 254
 			//end if the target list is empty
255 255
 			}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
 ///////BEGIN Functions to find relationships/////////////////////////////////
267 267
 
268
-function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false){
268
+function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false) {
269 269
 
270 270
 	$target_module_name = $target_bean->module_dir;
271 271
 	$current_module_name = $this->base_module;
@@ -275,21 +275,21 @@  discard block
 block discarded – undo
275 275
 
276 276
 
277 277
 	//Does a downstream relationship exist
278
-	if($rel_array!=null){
279
-		if($rel_array['relationship_type']=="many-to-many"){
278
+	if ($rel_array != null) {
279
+		if ($rel_array['relationship_type'] == "many-to-many") {
280 280
 			$joinKeyLHS = $rel_array['join_key_lhs'];
281 281
 			$target_bean->$joinKeyLHS = $this->base_bean->id;
282
-			if($rel_array['relationship_role_column']!=""){
282
+			if ($rel_array['relationship_role_column'] != "") {
283 283
 				$relRole = $rel_array['relationship_role_column'];
284 284
 				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
285 285
 			}				
286 286
 		//end if many-to-many	
287 287
 		}	
288 288
 		
289
-		if($rel_array['relationship_type']=="one-to-many"){
289
+		if ($rel_array['relationship_type'] == "one-to-many") {
290 290
 			$RHSKey = $rel_array['rhs_key'];
291 291
 			$target_bean->$RHSKey = $this->base_bean->id;
292
-			if($rel_array['relationship_role_column']!=""){
292
+			if ($rel_array['relationship_role_column'] != "") {
293 293
 				$relRole = $rel_array['relationship_role_column'];
294 294
 				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
295 295
 			}
@@ -306,21 +306,21 @@  discard block
 block discarded – undo
306 306
 	$rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db);
307 307
 
308 308
 	//Does an upstream relationship exist
309
-	if($rel_array!=null){
310
-		if($rel_array['relationship_type']=="many-to-many"){
309
+	if ($rel_array != null) {
310
+		if ($rel_array['relationship_type'] == "many-to-many") {
311 311
 			$joinKeyRHS = $rel_array['join_key_rhs'];
312 312
 			$target_bean->$joinKeyRHS = $this->base_bean->id;
313
-			if($rel_array['relationship_role_column']!=""){
313
+			if ($rel_array['relationship_role_column'] != "") {
314 314
 				$relRole = $rel_array['relationship_role_column'];
315 315
 				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
316 316
 			}				
317 317
 		//end if many-to-many	
318 318
 		}	
319 319
 		
320
-		if($rel_array['relationship_type']=="one-to-many"){
320
+		if ($rel_array['relationship_type'] == "one-to-many") {
321 321
 			$RHSKey = $rel_array['rhs_key'];
322 322
 			$target_bean->$RHSKey = $this->base_bean->id;
323
-			if($rel_array['relationship_role_column']!=""){
323
+			if ($rel_array['relationship_role_column'] != "") {
324 324
 				$relRole = $rel_array['relationship_role_column'];
325 325
 				$target_bean->$relRole = $rel_array['relationship_role_column_value'];
326 326
 			}
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 
330 330
 
331 331
 		///Fill additional id field if necessary
332
-		if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){
332
+		if (($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null) {
333 333
 			$target_bean->$id_name = $this->base_bean->id;
334
-            if($get_upstream_rel_field_name) {
334
+            if ($get_upstream_rel_field_name) {
335 335
                 $target_bean->new_rel_relname = $id_name;
336 336
                 $target_bean->new_rel_id = $this->base_bean->id;
337 337
             }
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 //end function get_relationship_information
344 344
 }
345 345
 
346
-function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){
346
+function traverse_rel_meta($base_module, & $target_bean, $target_rel_name) {
347 347
 	$id_name = null;
348 348
 
349 349
 	//returns name of variable to store id in
350 350
 	//if none exists, then returns null
351
-	foreach($target_bean->field_defs as $field_array){
351
+	foreach ($target_bean->field_defs as $field_array) {
352 352
 
353
-		if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){
353
+		if (!empty($field_array['relationship']) && $field_array['relationship'] == $target_rel_name) {
354 354
 
355 355
 			$id_name = $this->get_id_name($target_bean, $field_array['name']);
356 356
 			return $id_name;
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 
369
-function get_id_name(& $target_bean, $field_name){
369
+function get_id_name(& $target_bean, $field_name) {
370 370
 
371
-	foreach($target_bean->relationship_fields as $target_id => $rel_name){
371
+	foreach ($target_bean->relationship_fields as $target_id => $rel_name) {
372 372
 
373
-		if($rel_name == $field_name){
373
+		if ($rel_name == $field_name) {
374 374
 			//relationship id found
375 375
 			return $target_id;
376 376
 		//end if match
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 ///////////////////////////END functions to find relationships //////////////////////
386 386
 
387 387
 
388
-function process_by_rel_bean($rel1_module){
388
+function process_by_rel_bean($rel1_module) {
389 389
 
390 390
 	$this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db);
391 391
 	$this->rel1_module = $rel1_module;
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 }
396 396
 
397 397
 
398
-function get_rel1_vardef_field_base($field_defs){
399
-	foreach($field_defs as $field_array){
398
+function get_rel1_vardef_field_base($field_defs) {
399
+	foreach ($field_defs as $field_array) {
400 400
 
401
-		if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){
401
+		if (!empty($field_array['relationship']) && $field_array['relationship'] == $this->rel1_relationship_name) {
402 402
 
403 403
 			$this->rel1_vardef_field_base = $field_array['name'];
404 404
 		//end if rel name match
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 }
415 415
 
416 416
 
417
-function get_farthest_reach(){
417
+function get_farthest_reach() {
418 418
 
419
-	if($this->rel1_vardef_field!=""){
419
+	if ($this->rel1_vardef_field != "") {
420 420
 		//the farthest reach is rel2
421 421
 		$this->build_info(true);
422 422
 		return $this->rel2_bean;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
modules/Relationships/Relationship.php 3 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -49,32 +49,32 @@  discard block
 block discarded – undo
49 49
 
50 50
 class Relationship extends SugarBean {
51 51
 
52
-	var $object_name='Relationship';
53
-	var $module_dir = 'Relationships';
54
-	var $new_schema = true;
55
-	var $table_name = 'relationships';
56
-
57
-	var $id;
58
-	var $relationship_name;
59
-	var $lhs_module;
60
-	var $lhs_table;
61
-	var $lhs_key;
62
-	var $rhs_module;
63
-	var $rhs_table;
64
-	var $rhs_key;
65
-	var $join_table;
66
-	var $join_key_lhs;
67
-	var $join_key_rhs;
68
-	var $relationship_type;
69
-	var $relationship_role_column;
70
-	var $relationship_role_column_value;
71
-	var $reverse;
72
-
73
-	var $_self_referencing;
52
+    var $object_name='Relationship';
53
+    var $module_dir = 'Relationships';
54
+    var $new_schema = true;
55
+    var $table_name = 'relationships';
56
+
57
+    var $id;
58
+    var $relationship_name;
59
+    var $lhs_module;
60
+    var $lhs_table;
61
+    var $lhs_key;
62
+    var $rhs_module;
63
+    var $rhs_table;
64
+    var $rhs_key;
65
+    var $join_table;
66
+    var $join_key_lhs;
67
+    var $join_key_rhs;
68
+    var $relationship_type;
69
+    var $relationship_role_column;
70
+    var $relationship_role_column_value;
71
+    var $reverse;
72
+
73
+    var $_self_referencing;
74 74
 
75 75
     public function __construct() {
76
-		parent::__construct();
77
-	}
76
+        parent::__construct();
77
+    }
78 78
 
79 79
     /**
80 80
      * @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
@@ -91,88 +91,88 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
 
94
-	/*returns true if the relationship is self referencing. equality check is performed for both table and
94
+    /*returns true if the relationship is self referencing. equality check is performed for both table and
95 95
 	 * key names.
96 96
 	 */
97
-	function is_self_referencing() {
98
-		if (empty($this->_self_referencing)) {
99
-			$this->_self_referencing=false;
100
-
101
-			//is it self referencing, both table and key name from lhs and rhs should  be equal.
102
-			if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) {
103
-				$this->_self_referencing=true;
104
-			}
105
-		}
106
-		return $this->_self_referencing;
107
-	}
97
+    function is_self_referencing() {
98
+        if (empty($this->_self_referencing)) {
99
+            $this->_self_referencing=false;
100
+
101
+            //is it self referencing, both table and key name from lhs and rhs should  be equal.
102
+            if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) {
103
+                $this->_self_referencing=true;
104
+            }
105
+        }
106
+        return $this->_self_referencing;
107
+    }
108 108
 
109
-	/*returns true if a relationship with provided name exists*/
110
-	static function exists($relationship_name,&$db) {
111
-		$query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
112
-		$result = $db->query($query,true," Error searching relationships table..");
113
-		$row  =  $db->fetchByAssoc($result);
114
-		if ($row != null) {
115
-			return true;
116
-		}
109
+    /*returns true if a relationship with provided name exists*/
110
+    static function exists($relationship_name,&$db) {
111
+        $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
112
+        $result = $db->query($query,true," Error searching relationships table..");
113
+        $row  =  $db->fetchByAssoc($result);
114
+        if ($row != null) {
115
+            return true;
116
+        }
117 117
 
118
-		return false;
119
-	}
118
+        return false;
119
+    }
120 120
 
121
-	static function delete($relationship_name,&$db) {
121
+    static function delete($relationship_name,&$db) {
122 122
 
123
-		$query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
124
-		$result = $db->query($query,true," Error updating relationships table for ".$relationship_name);
123
+        $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
124
+        $result = $db->query($query,true," Error updating relationships table for ".$relationship_name);
125 125
 
126
-	}
126
+    }
127 127
 
128 128
 
129
-	function get_other_module($relationship_name, $base_module, &$db){
130
-	//give it the relationship_name and base module
131
-	//it will return the module name on the other side of the relationship
129
+    function get_other_module($relationship_name, $base_module, &$db){
130
+    //give it the relationship_name and base module
131
+    //it will return the module name on the other side of the relationship
132 132
 
133
-		$query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
134
-		$result = $db->query($query,true," Error searching relationships table..");
135
-		$row  =  $db->fetchByAssoc($result);
136
-		if ($row != null) {
133
+        $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
134
+        $result = $db->query($query,true," Error searching relationships table..");
135
+        $row  =  $db->fetchByAssoc($result);
136
+        if ($row != null) {
137 137
 
138
-			if($row['rhs_module']==$base_module){
139
-				return $row['lhs_module'];
140
-			}
141
-			if($row['lhs_module']==$base_module){
142
-				return $row['rhs_module'];
143
-			}
144
-		}
138
+            if($row['rhs_module']==$base_module){
139
+                return $row['lhs_module'];
140
+            }
141
+            if($row['lhs_module']==$base_module){
142
+                return $row['rhs_module'];
143
+            }
144
+        }
145 145
 
146
-		return false;
146
+        return false;
147 147
 
148 148
 
149
-	//end function get_other_module
150
-	}
149
+    //end function get_other_module
150
+    }
151 151
 
152
-	function retrieve_by_sides($lhs_module, $rhs_module, &$db){
153
-	//give it the relationship_name and base module
154
-	//it will return the module name on the other side of the relationship
152
+    function retrieve_by_sides($lhs_module, $rhs_module, &$db){
153
+    //give it the relationship_name and base module
154
+    //it will return the module name on the other side of the relationship
155 155
 
156
-		$query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'";
157
-		$result = $db->query($query,true," Error searching relationships table..");
158
-		$row  =  $db->fetchByAssoc($result);
159
-		if ($row != null) {
156
+        $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'";
157
+        $result = $db->query($query,true," Error searching relationships table..");
158
+        $row  =  $db->fetchByAssoc($result);
159
+        if ($row != null) {
160 160
 
161
-			return $row;
161
+            return $row;
162 162
 
163
-		}
163
+        }
164 164
 
165
-		return null;
165
+        return null;
166 166
 
167 167
 
168
-	//end function retrieve_by_sides
169
-	}
168
+    //end function retrieve_by_sides
169
+    }
170 170
 
171
-	static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){
172
-	//give it the relationship_name and base module
173
-	//it will return the module name on the other side of the relationship
171
+    static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){
172
+    //give it the relationship_name and base module
173
+    //it will return the module name on the other side of the relationship
174 174
 
175
-		$query = "	SELECT * FROM relationships
175
+        $query = "	SELECT * FROM relationships
176 176
 					WHERE deleted=0
177 177
 					AND (
178 178
 					(lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."')
@@ -180,113 +180,113 @@  discard block
 block discarded – undo
180 180
 					(lhs_module = '".$rhs_module."' AND rhs_module = '".$lhs_module."')
181 181
 					)
182 182
 					";
183
-		if(!empty($type)){
184
-			$query .= " AND relationship_type='$type'";
185
-		}
186
-		$result = $db->query($query,true," Error searching relationships table..");
187
-		$row  =  $db->fetchByAssoc($result);
188
-		if ($row != null) {
183
+        if(!empty($type)){
184
+            $query .= " AND relationship_type='$type'";
185
+        }
186
+        $result = $db->query($query,true," Error searching relationships table..");
187
+        $row  =  $db->fetchByAssoc($result);
188
+        if ($row != null) {
189 189
 
190
-			return $row['relationship_name'];
190
+            return $row['relationship_name'];
191 191
 
192
-		}
192
+        }
193 193
 
194
-		return null;
194
+        return null;
195 195
 
196 196
 
197
-	//end function retrieve_by_sides
198
-	}
197
+    //end function retrieve_by_sides
198
+    }
199 199
 
200 200
 
201
-	function retrieve_by_name($relationship_name) {
201
+    function retrieve_by_name($relationship_name) {
202 202
 
203
-		if (empty($GLOBALS['relationships'])) {
204
-			$this->load_relationship_meta();
205
-		}
203
+        if (empty($GLOBALS['relationships'])) {
204
+            $this->load_relationship_meta();
205
+        }
206 206
 
207 207
 //		_ppd($GLOBALS['relationships']);
208 208
 
209
-		if (array_key_exists($relationship_name, $GLOBALS['relationships'])) {
210
-
211
-			foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value)
212
-			{
213
-					$this->$field = $value;
214
-			}
215
-		}
216
-		else {
217
-			$GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name);
218
-			return false;
219
-		}
220
-	}
221
-
222
-	function load_relationship_meta() {
223
-		if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) {
224
-			$this->build_relationship_cache();
225
-		}
226
-		include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only());
227
-		$GLOBALS['relationships']=$relationships;
228
-	}
229
-
230
-	function build_relationship_cache() {
231
-		$query="SELECT * from relationships where deleted=0";
232
-		$result=$this->db->query($query);
233
-
234
-		while (($row=$this->db->fetchByAssoc($result))!=null) {
235
-			$relationships[$row['relationship_name']] = $row;
236
-		}
237
-
238
-		sugar_mkdir($this->cache_file_dir(), null, true);
209
+        if (array_key_exists($relationship_name, $GLOBALS['relationships'])) {
210
+
211
+            foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value)
212
+            {
213
+                    $this->$field = $value;
214
+            }
215
+        }
216
+        else {
217
+            $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name);
218
+            return false;
219
+        }
220
+    }
221
+
222
+    function load_relationship_meta() {
223
+        if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) {
224
+            $this->build_relationship_cache();
225
+        }
226
+        include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only());
227
+        $GLOBALS['relationships']=$relationships;
228
+    }
229
+
230
+    function build_relationship_cache() {
231
+        $query="SELECT * from relationships where deleted=0";
232
+        $result=$this->db->query($query);
233
+
234
+        while (($row=$this->db->fetchByAssoc($result))!=null) {
235
+            $relationships[$row['relationship_name']] = $row;
236
+        }
237
+
238
+        sugar_mkdir($this->cache_file_dir(), null, true);
239 239
         $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";";
240 240
         sugar_file_put_contents_atomic(Relationship::cache_file_dir() . '/' . Relationship::cache_file_name_only(), $out);
241 241
 
242 242
         require_once("data/Relationships/RelationshipFactory.php");
243 243
         SugarRelationshipFactory::deleteCache();
244
-	}
244
+    }
245 245
 
246 246
 
247
-	public static function cache_file_dir() {
248
-		return sugar_cached("modules/Relationships");
249
-	}
250
-	public static function cache_file_name_only() {
251
-		return 'relationships.cache.php';
252
-	}
247
+    public static function cache_file_dir() {
248
+        return sugar_cached("modules/Relationships");
249
+    }
250
+    public static function cache_file_name_only() {
251
+        return 'relationships.cache.php';
252
+    }
253 253
 
254
-	public static function delete_cache() {
255
-		$filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only();
256
-		if (file_exists($filename)) {
257
-			unlink($filename);
258
-		}
254
+    public static function delete_cache() {
255
+        $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only();
256
+        if (file_exists($filename)) {
257
+            unlink($filename);
258
+        }
259 259
         require_once("data/Relationships/RelationshipFactory.php");
260 260
         SugarRelationshipFactory::deleteCache();
261
-	}
261
+    }
262 262
 
263 263
 
264
-	function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){
265
-		global $beanList;
266
-		global $dictionary;
264
+    function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){
265
+        global $beanList;
266
+        global $dictionary;
267 267
 
268
-		$temp_module = get_module_info($base_module);
268
+        $temp_module = get_module_info($base_module);
269 269
 
270
-		$rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship'];
271
-		$rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db);
272
-		$rel_module1_bean = get_module_info($rel_module1);
270
+        $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship'];
271
+        $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db);
272
+        $rel_module1_bean = get_module_info($rel_module1);
273 273
 
274
-		if($rel_module2_name!=""){
275
-			if($rel_module2_name == 'ProjectTask'){
276
-				$rel_module2_name = strtolower($rel_module2_name);
277
-			}
278
-			$rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship'];
279
-			$rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db);
280
-			$rel_module2_bean = get_module_info($rel_module2);
281
-			return $rel_module2_bean;
274
+        if($rel_module2_name!=""){
275
+            if($rel_module2_name == 'ProjectTask'){
276
+                $rel_module2_name = strtolower($rel_module2_name);
277
+            }
278
+            $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship'];
279
+            $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db);
280
+            $rel_module2_bean = get_module_info($rel_module2);
281
+            return $rel_module2_bean;
282 282
 
283
-		} else {
284
-			//no rel_module2, so return rel_module2 bean
285
-			return $rel_module1_bean;
286
-		}
283
+        } else {
284
+            //no rel_module2, so return rel_module2 bean
285
+            return $rel_module1_bean;
286
+        }
287 287
 
288
-	//end function trace_relationship_module
289
-	}
288
+    //end function trace_relationship_module
289
+    }
290 290
 
291 291
 
292 292
 
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 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.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 class Relationship extends SugarBean {
51 51
 
52
-	var $object_name='Relationship';
52
+	var $object_name = 'Relationship';
53 53
 	var $module_dir = 'Relationships';
54 54
 	var $new_schema = true;
55 55
 	var $table_name = 'relationships';
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
     /**
80 80
      * @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
81 81
      */
82
-    public function Relationship(){
82
+    public function Relationship() {
83 83
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
84
-        if(isset($GLOBALS['log'])) {
84
+        if (isset($GLOBALS['log'])) {
85 85
             $GLOBALS['log']->deprecated($deprecatedMessage);
86 86
         }
87 87
         else {
@@ -96,21 +96,21 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	function is_self_referencing() {
98 98
 		if (empty($this->_self_referencing)) {
99
-			$this->_self_referencing=false;
99
+			$this->_self_referencing = false;
100 100
 
101 101
 			//is it self referencing, both table and key name from lhs and rhs should  be equal.
102 102
 			if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) {
103
-				$this->_self_referencing=true;
103
+				$this->_self_referencing = true;
104 104
 			}
105 105
 		}
106 106
 		return $this->_self_referencing;
107 107
 	}
108 108
 
109 109
 	/*returns true if a relationship with provided name exists*/
110
-	static function exists($relationship_name,&$db) {
110
+	static function exists($relationship_name, &$db) {
111 111
 		$query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
112
-		$result = $db->query($query,true," Error searching relationships table..");
113
-		$row  =  $db->fetchByAssoc($result);
112
+		$result = $db->query($query, true, " Error searching relationships table..");
113
+		$row = $db->fetchByAssoc($result);
114 114
 		if ($row != null) {
115 115
 			return true;
116 116
 		}
@@ -118,27 +118,27 @@  discard block
 block discarded – undo
118 118
 		return false;
119 119
 	}
120 120
 
121
-	static function delete($relationship_name,&$db) {
121
+	static function delete($relationship_name, &$db) {
122 122
 
123 123
 		$query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
124
-		$result = $db->query($query,true," Error updating relationships table for ".$relationship_name);
124
+		$result = $db->query($query, true, " Error updating relationships table for ".$relationship_name);
125 125
 
126 126
 	}
127 127
 
128 128
 
129
-	function get_other_module($relationship_name, $base_module, &$db){
129
+	function get_other_module($relationship_name, $base_module, &$db) {
130 130
 	//give it the relationship_name and base module
131 131
 	//it will return the module name on the other side of the relationship
132 132
 
133 133
 		$query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'";
134
-		$result = $db->query($query,true," Error searching relationships table..");
135
-		$row  =  $db->fetchByAssoc($result);
134
+		$result = $db->query($query, true, " Error searching relationships table..");
135
+		$row = $db->fetchByAssoc($result);
136 136
 		if ($row != null) {
137 137
 
138
-			if($row['rhs_module']==$base_module){
138
+			if ($row['rhs_module'] == $base_module) {
139 139
 				return $row['lhs_module'];
140 140
 			}
141
-			if($row['lhs_module']==$base_module){
141
+			if ($row['lhs_module'] == $base_module) {
142 142
 				return $row['rhs_module'];
143 143
 			}
144 144
 		}
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	//end function get_other_module
150 150
 	}
151 151
 
152
-	function retrieve_by_sides($lhs_module, $rhs_module, &$db){
152
+	function retrieve_by_sides($lhs_module, $rhs_module, &$db) {
153 153
 	//give it the relationship_name and base module
154 154
 	//it will return the module name on the other side of the relationship
155 155
 
156 156
 		$query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'";
157
-		$result = $db->query($query,true," Error searching relationships table..");
158
-		$row  =  $db->fetchByAssoc($result);
157
+		$result = $db->query($query, true, " Error searching relationships table..");
158
+		$row = $db->fetchByAssoc($result);
159 159
 		if ($row != null) {
160 160
 
161 161
 			return $row;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	//end function retrieve_by_sides
169 169
 	}
170 170
 
171
-	static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){
171
+	static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type = '') {
172 172
 	//give it the relationship_name and base module
173 173
 	//it will return the module name on the other side of the relationship
174 174
 
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 					(lhs_module = '".$rhs_module."' AND rhs_module = '".$lhs_module."')
181 181
 					)
182 182
 					";
183
-		if(!empty($type)){
183
+		if (!empty($type)) {
184 184
 			$query .= " AND relationship_type='$type'";
185 185
 		}
186
-		$result = $db->query($query,true," Error searching relationships table..");
187
-		$row  =  $db->fetchByAssoc($result);
186
+		$result = $db->query($query, true, " Error searching relationships table..");
187
+		$row = $db->fetchByAssoc($result);
188 188
 		if ($row != null) {
189 189
 
190 190
 			return $row['relationship_name'];
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
 		if (array_key_exists($relationship_name, $GLOBALS['relationships'])) {
210 210
 
211
-			foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value)
211
+			foreach ($GLOBALS['relationships'][$relationship_name] as $field=>$value)
212 212
 			{
213 213
 					$this->$field = $value;
214 214
 			}
@@ -224,20 +224,20 @@  discard block
 block discarded – undo
224 224
 			$this->build_relationship_cache();
225 225
 		}
226 226
 		include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only());
227
-		$GLOBALS['relationships']=$relationships;
227
+		$GLOBALS['relationships'] = $relationships;
228 228
 	}
229 229
 
230 230
 	function build_relationship_cache() {
231
-		$query="SELECT * from relationships where deleted=0";
232
-		$result=$this->db->query($query);
231
+		$query = "SELECT * from relationships where deleted=0";
232
+		$result = $this->db->query($query);
233 233
 
234
-		while (($row=$this->db->fetchByAssoc($result))!=null) {
234
+		while (($row = $this->db->fetchByAssoc($result)) != null) {
235 235
 			$relationships[$row['relationship_name']] = $row;
236 236
 		}
237 237
 
238 238
 		sugar_mkdir($this->cache_file_dir(), null, true);
239
-        $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";";
240
-        sugar_file_put_contents_atomic(Relationship::cache_file_dir() . '/' . Relationship::cache_file_name_only(), $out);
239
+        $out = "<?php \n \$relationships = ".var_export($relationships, true).";";
240
+        sugar_file_put_contents_atomic(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(), $out);
241 241
 
242 242
         require_once("data/Relationships/RelationshipFactory.php");
243 243
         SugarRelationshipFactory::deleteCache();
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	public static function delete_cache() {
255
-		$filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only();
255
+		$filename = Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only();
256 256
 		if (file_exists($filename)) {
257 257
 			unlink($filename);
258 258
 		}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 
264
-	function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){
264
+	function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name = "") {
265 265
 		global $beanList;
266 266
 		global $dictionary;
267 267
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 		$rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db);
272 272
 		$rel_module1_bean = get_module_info($rel_module1);
273 273
 
274
-		if($rel_module2_name!=""){
275
-			if($rel_module2_name == 'ProjectTask'){
274
+		if ($rel_module2_name != "") {
275
+			if ($rel_module2_name == 'ProjectTask') {
276 276
 				$rel_module2_name = strtolower($rel_module2_name);
277 277
 			}
278 278
 			$rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship'];
Please login to merge, or discard this patch.
Braces   +5 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.
@@ -57,8 +59,7 @@  discard block
 block discarded – undo
57 59
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
58 60
         if(isset($GLOBALS['log'])) {
59 61
             $GLOBALS['log']->deprecated($deprecatedMessage);
60
-        }
61
-        else {
62
+        } else {
62 63
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
63 64
         }
64 65
         self::__construct($layout_manager);
@@ -71,8 +72,7 @@  discard block
 block discarded – undo
71 72
 		if($this->getAssignedUser()) {
72 73
 			$begin = $timedate->handle_offset($layout_def['input_name0'], $timedate->get_db_date_time_format(), false, $this->assigned_user);
73 74
 			$end = $timedate->handle_offset($layout_def['input_name2'], $timedate->get_db_date_time_format(), false, $this->assigned_user);
74
-		}
75
-		else {
75
+		} else {
76 76
 			$begin = $layout_def['input_name0'];
77 77
 			$end = $layout_def['input_name1'];
78 78
 		}
Please login to merge, or discard this patch.
modules/ProspectLists/ProspectList.php 3 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -50,51 +50,51 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
 class ProspectList extends SugarBean {
53
-	var $field_name_map;
54
-
55
-	// Stored fields
56
-	var $id;
57
-	var $date_entered;
58
-	var $date_modified;
59
-	var $modified_user_id;
60
-	var $assigned_user_id;
61
-	var $created_by;
62
-	var $created_by_name;
63
-	var $modified_by_name;
64
-	var $list_type;
65
-	var $domain_name;
66
-
67
-	var $name;
68
-	var $description;
69
-
70
-	// These are related
71
-	var $assigned_user_name;
72
-	var $prospect_id;
73
-	var $contact_id;
74
-	var $lead_id;
75
-
76
-	// module name definitions and table relations
77
-	var $table_name = "prospect_lists";
78
-	var $module_dir = 'ProspectLists';
79
-	var $rel_prospects_table = "prospect_lists_prospects";
80
-	var $object_name = "ProspectList";
81
-
82
-	// This is used to retrieve related fields from form posts.
83
-	var $additional_column_fields = array(
84
-		'assigned_user_name', 'assigned_user_id', 'campaign_id',
85
-	);
86
-	var $relationship_fields = array(
87
-		'campaign_id'=>'campaigns',
88
-		'prospect_list_prospects' => 'prospects',
89
-	);
53
+    var $field_name_map;
54
+
55
+    // Stored fields
56
+    var $id;
57
+    var $date_entered;
58
+    var $date_modified;
59
+    var $modified_user_id;
60
+    var $assigned_user_id;
61
+    var $created_by;
62
+    var $created_by_name;
63
+    var $modified_by_name;
64
+    var $list_type;
65
+    var $domain_name;
66
+
67
+    var $name;
68
+    var $description;
69
+
70
+    // These are related
71
+    var $assigned_user_name;
72
+    var $prospect_id;
73
+    var $contact_id;
74
+    var $lead_id;
75
+
76
+    // module name definitions and table relations
77
+    var $table_name = "prospect_lists";
78
+    var $module_dir = 'ProspectLists';
79
+    var $rel_prospects_table = "prospect_lists_prospects";
80
+    var $object_name = "ProspectList";
81
+
82
+    // This is used to retrieve related fields from form posts.
83
+    var $additional_column_fields = array(
84
+        'assigned_user_name', 'assigned_user_id', 'campaign_id',
85
+    );
86
+    var $relationship_fields = array(
87
+        'campaign_id'=>'campaigns',
88
+        'prospect_list_prospects' => 'prospects',
89
+    );
90 90
 
91 91
     var $entry_count;
92 92
 
93 93
     public function __construct() {
94
-		global $sugar_config;
95
-		parent::__construct();
94
+        global $sugar_config;
95
+        parent::__construct();
96 96
 
97
-	}
97
+    }
98 98
 
99 99
     /**
100 100
      * @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
@@ -111,61 +111,61 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
 
114
-	var $new_schema = true;
114
+    var $new_schema = true;
115 115
 
116
-	function get_summary_text()
117
-	{
118
-		return "$this->name";
119
-	}
116
+    function get_summary_text()
117
+    {
118
+        return "$this->name";
119
+    }
120 120
 
121
-	function create_list_query($order_by, $where, $show_deleted = 0)
122
-	{
121
+    function create_list_query($order_by, $where, $show_deleted = 0)
122
+    {
123 123
         $custom_join = $this->getCustomJoin();
124 124
 
125
-		$query = "SELECT ";
126
-		$query .= "users.user_name as assigned_user_name, ";
127
-		$query .= "prospect_lists.*";
125
+        $query = "SELECT ";
126
+        $query .= "users.user_name as assigned_user_name, ";
127
+        $query .= "prospect_lists.*";
128 128
 
129 129
         $query .= $custom_join['select'];
130
-		$query .= " FROM prospect_lists ";
130
+        $query .= " FROM prospect_lists ";
131 131
 
132
-		$query .= "LEFT JOIN users
132
+        $query .= "LEFT JOIN users
133 133
 					ON prospect_lists.assigned_user_id=users.id ";
134 134
 
135 135
         $query .= $custom_join['join'];
136 136
 
137
-			$where_auto = '1=1';
138
-				if($show_deleted == 0){
139
-                	$where_auto = "$this->table_name.deleted=0";
140
-				}else if($show_deleted == 1){
141
-                	$where_auto = "$this->table_name.deleted=1";
142
-				}
137
+            $where_auto = '1=1';
138
+                if($show_deleted == 0){
139
+                    $where_auto = "$this->table_name.deleted=0";
140
+                }else if($show_deleted == 1){
141
+                    $where_auto = "$this->table_name.deleted=1";
142
+                }
143 143
 
144
-		if($where != "")
145
-			$query .= "where $where AND ".$where_auto;
146
-		else
147
-			$query .= "where ".$where_auto;
144
+        if($where != "")
145
+            $query .= "where $where AND ".$where_auto;
146
+        else
147
+            $query .= "where ".$where_auto;
148 148
 
149
-		if($order_by != "")
150
-			$query .= " ORDER BY $order_by";
151
-		else
152
-			$query .= " ORDER BY prospect_lists.name";
149
+        if($order_by != "")
150
+            $query .= " ORDER BY $order_by";
151
+        else
152
+            $query .= " ORDER BY prospect_lists.name";
153 153
 
154
-		return $query;
155
-	}
154
+        return $query;
155
+    }
156 156
 
157 157
 
158
-	function create_export_query($order_by, $where)
159
-	{
158
+    function create_export_query($order_by, $where)
159
+    {
160 160
 
161 161
                                 $query = "SELECT
162 162
                                 prospect_lists.*,
163 163
                                 users.user_name as assigned_user_name ";
164
-	                            $query .= "FROM prospect_lists ";
165
-		$query .= 				"LEFT JOIN users
164
+                                $query .= "FROM prospect_lists ";
165
+        $query .= 				"LEFT JOIN users
166 166
                                 ON prospect_lists.assigned_user_id=users.id ";
167 167
 
168
-		$where_auto = " prospect_lists.deleted=0";
168
+        $where_auto = " prospect_lists.deleted=0";
169 169
 
170 170
         if($where != "")
171 171
                 $query .= " WHERE $where AND ".$where_auto;
@@ -179,47 +179,47 @@  discard block
 block discarded – undo
179 179
         return $query;
180 180
     }
181 181
 
182
-	function create_export_members_query($record_id)
183
-	{
184
-		$members = array(	'Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
185
-					'Contacts' 	=> array('has_custom_fields' => false, 'fields' => array()),
186
-					'Users' 	=> array('has_custom_fields' => false, 'fields' => array()),
187
-					'Prospects' 	=> array('has_custom_fields' => false, 'fields' => array()),
188
-					'Leads' 	=> array('has_custom_fields' => false, 'fields' => array())
189
-				);
190
-
191
-		// query all custom fields in the fields_meta_data table for the modules which are being exported
192
-		$db = DBManagerFactory::getInstance();
193
-		$result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" .
194
-					implode("', '", array_keys($members)) . "')",
195
-					true,
196
-					"ProspectList::create_export_members_query() : error querying custom fields");
197
-
198
-		// cycle through the custom fields and put them in the members array according to
199
-		// what module the field belongs
200
-		// take into account that the same custom field may exist in more modules
201
-		while($val = $db->fetchByAssoc($result, false))
202
-		{
203
-			$fieldname = $val['name'];
204
-
205
-			foreach($members as $membername => &$memberarr)
206
-			{
207
-				// if the field belongs to this module, then query it in the cstm table
208
-				if ($membername == $val['custom_module'])
209
-				{
210
-					$memberarr['has_custom_fields'] = true;
211
-					$memberarr['fields'][$fieldname] =
212
-						strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname;
213
-				}
214
-				// else, only if for this module no entry exists for this field, query an empty string
215
-				else if (!isset($memberarr['fields'][$val['name']]))
216
-				{
217
-					$memberarr['fields'][$fieldname] = "'' AS " . $fieldname;
218
-				}
219
-			}
220
-		}
221
-
222
-		$leads_query = "SELECT l.id AS id, 'Leads' AS related_type, '' AS \"name\", l.first_name AS first_name, l.last_name AS last_name, l.title AS title, l.salutation AS salutation,
182
+    function create_export_members_query($record_id)
183
+    {
184
+        $members = array(	'Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
185
+                    'Contacts' 	=> array('has_custom_fields' => false, 'fields' => array()),
186
+                    'Users' 	=> array('has_custom_fields' => false, 'fields' => array()),
187
+                    'Prospects' 	=> array('has_custom_fields' => false, 'fields' => array()),
188
+                    'Leads' 	=> array('has_custom_fields' => false, 'fields' => array())
189
+                );
190
+
191
+        // query all custom fields in the fields_meta_data table for the modules which are being exported
192
+        $db = DBManagerFactory::getInstance();
193
+        $result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" .
194
+                    implode("', '", array_keys($members)) . "')",
195
+                    true,
196
+                    "ProspectList::create_export_members_query() : error querying custom fields");
197
+
198
+        // cycle through the custom fields and put them in the members array according to
199
+        // what module the field belongs
200
+        // take into account that the same custom field may exist in more modules
201
+        while($val = $db->fetchByAssoc($result, false))
202
+        {
203
+            $fieldname = $val['name'];
204
+
205
+            foreach($members as $membername => &$memberarr)
206
+            {
207
+                // if the field belongs to this module, then query it in the cstm table
208
+                if ($membername == $val['custom_module'])
209
+                {
210
+                    $memberarr['has_custom_fields'] = true;
211
+                    $memberarr['fields'][$fieldname] =
212
+                        strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname;
213
+                }
214
+                // else, only if for this module no entry exists for this field, query an empty string
215
+                else if (!isset($memberarr['fields'][$val['name']]))
216
+                {
217
+                    $memberarr['fields'][$fieldname] = "'' AS " . $fieldname;
218
+                }
219
+            }
220
+        }
221
+
222
+        $leads_query = "SELECT l.id AS id, 'Leads' AS related_type, '' AS \"name\", l.first_name AS first_name, l.last_name AS last_name, l.title AS title, l.salutation AS salutation,
223 223
 				l.primary_address_street AS primary_address_street,l.primary_address_city AS primary_address_city, l.primary_address_state AS primary_address_state, l.primary_address_postalcode AS primary_address_postalcode, l.primary_address_country AS primary_address_country,
224 224
 				l.account_name AS account_name,
225 225
 				ea.email_address AS primary_email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				AND l.deleted=0
235 235
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
236 236
 
237
-		$users_query = "SELECT u.id AS id, 'Users' AS related_type, '' AS \"name\", u.first_name AS first_name, u.last_name AS last_name,u.title AS title, '' AS salutation,
237
+        $users_query = "SELECT u.id AS id, 'Users' AS related_type, '' AS \"name\", u.first_name AS first_name, u.last_name AS last_name,u.title AS title, '' AS salutation,
238 238
 				u.address_street AS primary_address_street,u.address_city AS primary_address_city, u.address_state AS primary_address_state,  u.address_postalcode AS primary_address_postalcode, u.address_country AS primary_address_country,
239 239
 				'' AS account_name,
240 240
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 				AND u.deleted=0
250 250
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
251 251
 
252
-		$contacts_query = "SELECT c.id AS id, 'Contacts' AS related_type, '' AS \"name\", c.first_name AS first_name, c.last_name AS last_name,c.title AS title, c.salutation AS salutation,
252
+        $contacts_query = "SELECT c.id AS id, 'Contacts' AS related_type, '' AS \"name\", c.first_name AS first_name, c.last_name AS last_name,c.title AS title, c.salutation AS salutation,
253 253
 				c.primary_address_street AS primary_address_street,c.primary_address_city AS primary_address_city, c.primary_address_state AS primary_address_state,  c.primary_address_postalcode AS primary_address_postalcode, c.primary_address_country AS primary_address_country,
254 254
 				a.name AS account_name,
255 255
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				AND c.deleted=0
266 266
                 AND (ear.deleted=0 OR ear.deleted IS NULL)";
267 267
 
268
-		$prospects_query = "SELECT p.id AS id, 'Prospects' AS related_type, '' AS \"name\", p.first_name AS first_name, p.last_name AS last_name,p.title AS title, p.salutation AS salutation,
268
+        $prospects_query = "SELECT p.id AS id, 'Prospects' AS related_type, '' AS \"name\", p.first_name AS first_name, p.last_name AS last_name,p.title AS title, p.salutation AS salutation,
269 269
 				p.primary_address_street AS primary_address_street,p.primary_address_city AS primary_address_city, p.primary_address_state AS primary_address_state,  p.primary_address_postalcode AS primary_address_postalcode, p.primary_address_country AS primary_address_country,
270 270
 				p.account_name AS account_name,
271 271
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				AND p.deleted=0
281 281
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
282 282
 
283
-		$accounts_query = "SELECT a.id AS id, 'Accounts' AS related_type, a.name AS \"name\", '' AS first_name, '' AS last_name,'' AS title, '' AS salutation,
283
+        $accounts_query = "SELECT a.id AS id, 'Accounts' AS related_type, a.name AS \"name\", '' AS first_name, '' AS last_name,'' AS title, '' AS salutation,
284 284
 				a.billing_address_street AS primary_address_street,a.billing_address_city AS primary_address_city, a.billing_address_state AS primary_address_state, a.billing_address_postalcode AS primary_address_postalcode, a.billing_address_country AS primary_address_country,
285 285
 				'' AS account_name,
286 286
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -294,115 +294,115 @@  discard block
 block discarded – undo
294 294
 				WHERE plp.prospect_list_id = $record_id  AND plp.deleted=0
295 295
 				AND a.deleted=0
296 296
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
297
-		$order_by = "ORDER BY related_type, id, primary_address DESC";
298
-		$query = "$leads_query UNION ALL $users_query UNION ALL $contacts_query UNION ALL $prospects_query UNION ALL $accounts_query $order_by";
299
-		return $query;
300
-	}
297
+        $order_by = "ORDER BY related_type, id, primary_address DESC";
298
+        $query = "$leads_query UNION ALL $users_query UNION ALL $contacts_query UNION ALL $prospects_query UNION ALL $accounts_query $order_by";
299
+        return $query;
300
+    }
301 301
 
302
-	function save_relationship_changes($is_update, $exclude = array())
302
+    function save_relationship_changes($is_update, $exclude = array())
303 303
     {
304
-    	parent::save_relationship_changes($is_update, $exclude);
305
-		if($this->lead_id != "")
306
-	   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
-    	if($this->contact_id != "")
308
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
-    	if($this->prospect_id != "")
310
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
304
+        parent::save_relationship_changes($is_update, $exclude);
305
+        if($this->lead_id != "")
306
+                $this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
+        if($this->contact_id != "")
308
+            $this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
+        if($this->prospect_id != "")
310
+            $this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
311 311
     }
312 312
 
313
-	function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
314
-	{
315
-		$link_field = sprintf("%s_id", $link_name);
313
+    function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
314
+    {
315
+        $link_field = sprintf("%s_id", $link_name);
316 316
 
317
-		foreach($link_ids as $link_id)
318
-		{
319
-			$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
320
-		}
321
-	}
317
+        foreach($link_ids as $link_id)
318
+        {
319
+            $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
320
+        }
321
+    }
322 322
 
323
-	function set_prospect_relationship_single($prospect_list_id, $link_id, $link_name)
324
-	{
325
-		$link_field = sprintf("%s_id", $link_name);
323
+    function set_prospect_relationship_single($prospect_list_id, $link_id, $link_name)
324
+    {
325
+        $link_field = sprintf("%s_id", $link_name);
326 326
 
327
-		$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
328
-	}
327
+        $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
328
+    }
329 329
 
330 330
 
331
-	function clear_prospect_relationship($prospect_list_id, $link_id, $link_name)
332
-	{
333
-		$link_field = sprintf("%s_id", $link_name);
334
-		$where_clause = " AND $link_field = '$link_id' ";
331
+    function clear_prospect_relationship($prospect_list_id, $link_id, $link_name)
332
+    {
333
+        $link_field = sprintf("%s_id", $link_name);
334
+        $where_clause = " AND $link_field = '$link_id' ";
335 335
 
336
-		$query = sprintf("DELETE FROM prospect_lists_prospects WHERE prospect_list_id='%s' AND deleted = '0' %s", $prospect_list_id, $where_clause);
336
+        $query = sprintf("DELETE FROM prospect_lists_prospects WHERE prospect_list_id='%s' AND deleted = '0' %s", $prospect_list_id, $where_clause);
337 337
 
338
-		$this->db->query($query, true, "Error clearing prospect/prospect_list relationship: ");
339
-	}
338
+        $this->db->query($query, true, "Error clearing prospect/prospect_list relationship: ");
339
+    }
340 340
 
341 341
 
342
-	function mark_relationships_deleted($id)
343
-	{
344
-	}
342
+    function mark_relationships_deleted($id)
343
+    {
344
+    }
345 345
 
346
-	function fill_in_additional_list_fields()
347
-	{
348
-	}
346
+    function fill_in_additional_list_fields()
347
+    {
348
+    }
349 349
 
350
-	function fill_in_additional_detail_fields()
351
-	{
352
-		parent::fill_in_additional_detail_fields();
350
+    function fill_in_additional_detail_fields()
351
+    {
352
+        parent::fill_in_additional_detail_fields();
353 353
         $this->entry_count = $this->get_entry_count();
354
-	}
354
+    }
355 355
 
356 356
 
357
-	function update_currency_id($fromid, $toid){
358
-	}
357
+    function update_currency_id($fromid, $toid){
358
+    }
359 359
 
360 360
 
361
-	function get_entry_count()
362
-	{
363
-		$query = "SELECT count(*) AS num FROM prospect_lists_prospects WHERE prospect_list_id='$this->id' AND deleted = '0'";
364
-		$result = $this->db->query($query, true, "Grabbing prospect_list entry count");
361
+    function get_entry_count()
362
+    {
363
+        $query = "SELECT count(*) AS num FROM prospect_lists_prospects WHERE prospect_list_id='$this->id' AND deleted = '0'";
364
+        $result = $this->db->query($query, true, "Grabbing prospect_list entry count");
365 365
 
366
-		$row = $this->db->fetchByAssoc($result);
366
+        $row = $this->db->fetchByAssoc($result);
367 367
 
368
-		if($row)
369
-			return $row['num'];
370
-		else
371
-			return 0;
372
-	}
368
+        if($row)
369
+            return $row['num'];
370
+        else
371
+            return 0;
372
+    }
373 373
 
374 374
 
375
-	function get_list_view_data(){
376
-		$temp_array = $this->get_list_view_array();
377
-		$temp_array["ENTRY_COUNT"] = $this->get_entry_count();
378
-		return $temp_array;
379
-	}
380
-	/**
375
+    function get_list_view_data(){
376
+        $temp_array = $this->get_list_view_array();
377
+        $temp_array["ENTRY_COUNT"] = $this->get_entry_count();
378
+        return $temp_array;
379
+    }
380
+    /**
381 381
 		builds a generic search based on the query string using or
382 382
 		do not include any $this-> because this is called on without having the class instantiated
383
-	*/
384
-	function build_generic_where_clause ($the_query_string)
385
-	{
386
-		$where_clauses = Array();
387
-		$the_query_string = $GLOBALS['db']->quote($the_query_string);
388
-		array_push($where_clauses, "prospect_lists.name like '$the_query_string%'");
389
-
390
-		$the_where = "";
391
-		foreach($where_clauses as $clause)
392
-		{
393
-			if($the_where != "") $the_where .= " or ";
394
-			$the_where .= $clause;
395
-		}
383
+     */
384
+    function build_generic_where_clause ($the_query_string)
385
+    {
386
+        $where_clauses = Array();
387
+        $the_query_string = $GLOBALS['db']->quote($the_query_string);
388
+        array_push($where_clauses, "prospect_lists.name like '$the_query_string%'");
389
+
390
+        $the_where = "";
391
+        foreach($where_clauses as $clause)
392
+        {
393
+            if($the_where != "") $the_where .= " or ";
394
+            $the_where .= $clause;
395
+        }
396 396
 
397 397
 
398
-		return $the_where;
399
-	}
398
+        return $the_where;
399
+    }
400 400
 
401
-	function save($check_notify = FALSE) {
401
+    function save($check_notify = FALSE) {
402 402
 
403
-		return parent::save($check_notify);
403
+        return parent::save($check_notify);
404 404
 
405
-	}
405
+    }
406 406
 
407 407
     function mark_deleted($id){
408 408
         $query = "UPDATE prospect_lists_prospects SET deleted = 1 WHERE prospect_list_id = '{$id}' ";
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
         return parent::mark_deleted($id);
411 411
     }
412 412
 
413
-	 function bean_implements($interface){
414
-		switch($interface){
415
-			case 'ACL':return true;
416
-		}
417
-		return false;
418
-	}
413
+        function bean_implements($interface){
414
+        switch($interface){
415
+            case 'ACL':return true;
416
+        }
417
+        return false;
418
+    }
419 419
 
420 420
 }
421 421
 
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 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,9 +99,9 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * @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
101 101
      */
102
-    public function ProspectList(){
102
+    public function ProspectList() {
103 103
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
104
-        if(isset($GLOBALS['log'])) {
104
+        if (isset($GLOBALS['log'])) {
105 105
             $GLOBALS['log']->deprecated($deprecatedMessage);
106 106
         }
107 107
         else {
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
         $query .= $custom_join['join'];
136 136
 
137 137
 			$where_auto = '1=1';
138
-				if($show_deleted == 0){
138
+				if ($show_deleted == 0) {
139 139
                 	$where_auto = "$this->table_name.deleted=0";
140
-				}else if($show_deleted == 1){
140
+				} else if ($show_deleted == 1) {
141 141
                 	$where_auto = "$this->table_name.deleted=1";
142 142
 				}
143 143
 
144
-		if($where != "")
144
+		if ($where != "")
145 145
 			$query .= "where $where AND ".$where_auto;
146 146
 		else
147 147
 			$query .= "where ".$where_auto;
148 148
 
149
-		if($order_by != "")
149
+		if ($order_by != "")
150 150
 			$query .= " ORDER BY $order_by";
151 151
 		else
152 152
 			$query .= " ORDER BY prospect_lists.name";
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
                                 prospect_lists.*,
163 163
                                 users.user_name as assigned_user_name ";
164 164
 	                            $query .= "FROM prospect_lists ";
165
-		$query .= 				"LEFT JOIN users
165
+		$query .= "LEFT JOIN users
166 166
                                 ON prospect_lists.assigned_user_id=users.id ";
167 167
 
168 168
 		$where_auto = " prospect_lists.deleted=0";
169 169
 
170
-        if($where != "")
170
+        if ($where != "")
171 171
                 $query .= " WHERE $where AND ".$where_auto;
172 172
         else
173 173
                 $query .= " WHERE ".$where_auto;
174 174
 
175
-        if($order_by != "")
175
+        if ($order_by != "")
176 176
                 $query .= " ORDER BY $order_by";
177 177
         else
178 178
                 $query .= " ORDER BY prospect_lists.name";
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 	function create_export_members_query($record_id)
183 183
 	{
184
-		$members = array(	'Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
184
+		$members = array('Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
185 185
 					'Contacts' 	=> array('has_custom_fields' => false, 'fields' => array()),
186 186
 					'Users' 	=> array('has_custom_fields' => false, 'fields' => array()),
187 187
 					'Prospects' 	=> array('has_custom_fields' => false, 'fields' => array()),
@@ -190,31 +190,31 @@  discard block
 block discarded – undo
190 190
 
191 191
 		// query all custom fields in the fields_meta_data table for the modules which are being exported
192 192
 		$db = DBManagerFactory::getInstance();
193
-		$result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" .
194
-					implode("', '", array_keys($members)) . "')",
193
+		$result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('".
194
+					implode("', '", array_keys($members))."')",
195 195
 					true,
196 196
 					"ProspectList::create_export_members_query() : error querying custom fields");
197 197
 
198 198
 		// cycle through the custom fields and put them in the members array according to
199 199
 		// what module the field belongs
200 200
 		// take into account that the same custom field may exist in more modules
201
-		while($val = $db->fetchByAssoc($result, false))
201
+		while ($val = $db->fetchByAssoc($result, false))
202 202
 		{
203 203
 			$fieldname = $val['name'];
204 204
 
205
-			foreach($members as $membername => &$memberarr)
205
+			foreach ($members as $membername => &$memberarr)
206 206
 			{
207 207
 				// if the field belongs to this module, then query it in the cstm table
208 208
 				if ($membername == $val['custom_module'])
209 209
 				{
210 210
 					$memberarr['has_custom_fields'] = true;
211 211
 					$memberarr['fields'][$fieldname] =
212
-						strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname;
212
+						strtolower($membername).'_cstm.'.$fieldname.' AS '.$fieldname;
213 213
 				}
214 214
 				// else, only if for this module no entry exists for this field, query an empty string
215 215
 				else if (!isset($memberarr['fields'][$val['name']]))
216 216
 				{
217
-					$memberarr['fields'][$fieldname] = "'' AS " . $fieldname;
217
+					$memberarr['fields'][$fieldname] = "'' AS ".$fieldname;
218 218
 				}
219 219
 			}
220 220
 		}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				l.account_name AS account_name,
225 225
 				ea.email_address AS primary_email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
226 226
 				l.do_not_call AS do_not_call, l.phone_fax AS phone_fax, l.phone_other AS phone_other, l.phone_home AS phone_home, l.phone_mobile AS phone_mobile, l.phone_work AS phone_work
227
-				".(count($members['Leads']['fields']) ? ', ' : '') . implode(', ', $members['Leads']['fields'])."
227
+				".(count($members['Leads']['fields']) ? ', ' : '').implode(', ', $members['Leads']['fields'])."
228 228
 				FROM prospect_lists_prospects plp
229 229
 				INNER JOIN leads l ON plp.related_id=l.id
230 230
 				".($members['Leads']['has_custom_fields'] ? 'LEFT join leads_cstm ON l.id = leads_cstm.id_c' : '')."
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 				'' AS account_name,
240 240
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
241 241
 				0 AS do_not_call, u.phone_fax AS phone_fax, u.phone_other AS phone_other, u.phone_home AS phone_home, u.phone_mobile AS phone_mobile, u.phone_work AS phone_work
242
-				".(count($members['Users']['fields']) ? ', ' : '') . implode(', ', $members['Users']['fields'])."
242
+				".(count($members['Users']['fields']) ? ', ' : '').implode(', ', $members['Users']['fields'])."
243 243
 				FROM prospect_lists_prospects plp
244 244
 				INNER JOIN users u ON plp.related_id=u.id
245 245
 				".($members['Users']['has_custom_fields'] ? 'LEFT join users_cstm ON u.id = users_cstm.id_c' : '')."
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 				a.name AS account_name,
255 255
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
256 256
 				c.do_not_call AS do_not_call, c.phone_fax AS phone_fax, c.phone_other AS phone_other, c.phone_home AS phone_home, c.phone_mobile AS phone_mobile, c.phone_work AS phone_work
257
-				".(count($members['Contacts']['fields']) ? ', ' : '') . implode(', ', $members['Contacts']['fields'])."
257
+				".(count($members['Contacts']['fields']) ? ', ' : '').implode(', ', $members['Contacts']['fields'])."
258 258
 FROM prospect_lists_prospects plp
259 259
 				INNER JOIN contacts c ON plp.related_id=c.id LEFT JOIN accounts_contacts ac ON ac.contact_id=c.id
260 260
 				LEFT JOIN accounts a ON ac.account_id=a.id AND ac.deleted=0
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 				p.account_name AS account_name,
271 271
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
272 272
 				p.do_not_call AS do_not_call, p.phone_fax AS phone_fax, p.phone_other AS phone_other, p.phone_home AS phone_home, p.phone_mobile AS phone_mobile, p.phone_work AS phone_work
273
-				".(count($members['Prospects']['fields']) ? ', ' : '') . implode(', ', $members['Prospects']['fields'])."
273
+				".(count($members['Prospects']['fields']) ? ', ' : '').implode(', ', $members['Prospects']['fields'])."
274 274
 				FROM prospect_lists_prospects plp
275 275
 				INNER JOIN prospects p ON plp.related_id=p.id
276 276
 				".($members['Prospects']['has_custom_fields'] ? 'LEFT join prospects_cstm ON p.id = prospects_cstm.id_c' : '')."
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				'' AS account_name,
286 286
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
287 287
 				0 AS do_not_call, a.phone_fax as phone_fax, a.phone_alternate AS phone_other, '' AS phone_home, '' AS phone_mobile, a.phone_office AS phone_office
288
-				".(count($members['Accounts']['fields']) ? ', ' : '') . implode(', ', $members['Accounts']['fields'])."
288
+				".(count($members['Accounts']['fields']) ? ', ' : '').implode(', ', $members['Accounts']['fields'])."
289 289
 				FROM prospect_lists_prospects plp
290 290
 				INNER JOIN accounts a ON plp.related_id=a.id
291 291
 				".($members['Accounts']['has_custom_fields'] ? 'LEFT join accounts_cstm ON a.id = accounts_cstm.id_c' : '')."
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 	function save_relationship_changes($is_update, $exclude = array())
303 303
     {
304 304
     	parent::save_relationship_changes($is_update, $exclude);
305
-		if($this->lead_id != "")
305
+		if ($this->lead_id != "")
306 306
 	   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
-    	if($this->contact_id != "")
307
+    	if ($this->contact_id != "")
308 308
     		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
-    	if($this->prospect_id != "")
309
+    	if ($this->prospect_id != "")
310 310
     		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
311 311
     }
312 312
 
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	{
315 315
 		$link_field = sprintf("%s_id", $link_name);
316 316
 
317
-		foreach($link_ids as $link_id)
317
+		foreach ($link_ids as $link_id)
318 318
 		{
319
-			$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
319
+			$this->set_relationship('prospect_lists_prospects', array($link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id));
320 320
 		}
321 321
 	}
322 322
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	{
325 325
 		$link_field = sprintf("%s_id", $link_name);
326 326
 
327
-		$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
327
+		$this->set_relationship('prospect_lists_prospects', array($link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id));
328 328
 	}
329 329
 
330 330
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	}
355 355
 
356 356
 
357
-	function update_currency_id($fromid, $toid){
357
+	function update_currency_id($fromid, $toid) {
358 358
 	}
359 359
 
360 360
 
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
 
366 366
 		$row = $this->db->fetchByAssoc($result);
367 367
 
368
-		if($row)
368
+		if ($row)
369 369
 			return $row['num'];
370 370
 		else
371 371
 			return 0;
372 372
 	}
373 373
 
374 374
 
375
-	function get_list_view_data(){
375
+	function get_list_view_data() {
376 376
 		$temp_array = $this->get_list_view_array();
377 377
 		$temp_array["ENTRY_COUNT"] = $this->get_entry_count();
378 378
 		return $temp_array;
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
 		builds a generic search based on the query string using or
382 382
 		do not include any $this-> because this is called on without having the class instantiated
383 383
 	*/
384
-	function build_generic_where_clause ($the_query_string)
384
+	function build_generic_where_clause($the_query_string)
385 385
 	{
386 386
 		$where_clauses = Array();
387 387
 		$the_query_string = $GLOBALS['db']->quote($the_query_string);
388 388
 		array_push($where_clauses, "prospect_lists.name like '$the_query_string%'");
389 389
 
390 390
 		$the_where = "";
391
-		foreach($where_clauses as $clause)
391
+		foreach ($where_clauses as $clause)
392 392
 		{
393
-			if($the_where != "") $the_where .= " or ";
393
+			if ($the_where != "") $the_where .= " or ";
394 394
 			$the_where .= $clause;
395 395
 		}
396 396
 
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
 
405 405
 	}
406 406
 
407
-    function mark_deleted($id){
407
+    function mark_deleted($id) {
408 408
         $query = "UPDATE prospect_lists_prospects SET deleted = 1 WHERE prospect_list_id = '{$id}' ";
409 409
         $this->db->query($query);
410 410
         return parent::mark_deleted($id);
411 411
     }
412 412
 
413
-	 function bean_implements($interface){
414
-		switch($interface){
413
+	 function bean_implements($interface) {
414
+		switch ($interface) {
415 415
 			case 'ACL':return true;
416 416
 		}
417 417
 		return false;
Please login to merge, or discard this patch.
Braces   +42 added lines, -31 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.
@@ -103,8 +105,7 @@  discard block
 block discarded – undo
103 105
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
104 106
         if(isset($GLOBALS['log'])) {
105 107
             $GLOBALS['log']->deprecated($deprecatedMessage);
106
-        }
107
-        else {
108
+        } else {
108 109
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
109 110
         }
110 111
         self::__construct();
@@ -137,19 +138,21 @@  discard block
 block discarded – undo
137 138
 			$where_auto = '1=1';
138 139
 				if($show_deleted == 0){
139 140
                 	$where_auto = "$this->table_name.deleted=0";
140
-				}else if($show_deleted == 1){
141
+				} else if($show_deleted == 1){
141 142
                 	$where_auto = "$this->table_name.deleted=1";
142 143
 				}
143 144
 
144
-		if($where != "")
145
-			$query .= "where $where AND ".$where_auto;
146
-		else
147
-			$query .= "where ".$where_auto;
145
+		if($where != "") {
146
+					$query .= "where $where AND ".$where_auto;
147
+		} else {
148
+					$query .= "where ".$where_auto;
149
+		}
148 150
 
149
-		if($order_by != "")
150
-			$query .= " ORDER BY $order_by";
151
-		else
152
-			$query .= " ORDER BY prospect_lists.name";
151
+		if($order_by != "") {
152
+					$query .= " ORDER BY $order_by";
153
+		} else {
154
+					$query .= " ORDER BY prospect_lists.name";
155
+		}
153 156
 
154 157
 		return $query;
155 158
 	}
@@ -167,15 +170,17 @@  discard block
 block discarded – undo
167 170
 
168 171
 		$where_auto = " prospect_lists.deleted=0";
169 172
 
170
-        if($where != "")
171
-                $query .= " WHERE $where AND ".$where_auto;
172
-        else
173
-                $query .= " WHERE ".$where_auto;
173
+        if($where != "") {
174
+                        $query .= " WHERE $where AND ".$where_auto;
175
+        } else {
176
+                        $query .= " WHERE ".$where_auto;
177
+        }
174 178
 
175
-        if($order_by != "")
176
-                $query .= " ORDER BY $order_by";
177
-        else
178
-                $query .= " ORDER BY prospect_lists.name";
179
+        if($order_by != "") {
180
+                        $query .= " ORDER BY $order_by";
181
+        } else {
182
+                        $query .= " ORDER BY prospect_lists.name";
183
+        }
179 184
         return $query;
180 185
     }
181 186
 
@@ -302,12 +307,15 @@  discard block
 block discarded – undo
302 307
 	function save_relationship_changes($is_update, $exclude = array())
303 308
     {
304 309
     	parent::save_relationship_changes($is_update, $exclude);
305
-		if($this->lead_id != "")
306
-	   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
-    	if($this->contact_id != "")
308
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
-    	if($this->prospect_id != "")
310
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
310
+		if($this->lead_id != "") {
311
+			   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
312
+		}
313
+    	if($this->contact_id != "") {
314
+    	    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
315
+    	}
316
+    	if($this->prospect_id != "") {
317
+    	    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
318
+    	}
311 319
     }
312 320
 
313 321
 	function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
@@ -365,10 +373,11 @@  discard block
 block discarded – undo
365 373
 
366 374
 		$row = $this->db->fetchByAssoc($result);
367 375
 
368
-		if($row)
369
-			return $row['num'];
370
-		else
371
-			return 0;
376
+		if($row) {
377
+					return $row['num'];
378
+		} else {
379
+					return 0;
380
+		}
372 381
 	}
373 382
 
374 383
 
@@ -390,7 +399,9 @@  discard block
 block discarded – undo
390 399
 		$the_where = "";
391 400
 		foreach($where_clauses as $clause)
392 401
 		{
393
-			if($the_where != "") $the_where .= " or ";
402
+			if($the_where != "") {
403
+			    $the_where .= " or ";
404
+			}
394 405
 			$the_where .= $clause;
395 406
 		}
396 407
 
Please login to merge, or discard this patch.
modules/Leads/LeadsJjwg_MapsLogicHook.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
     /**
14 14
      * @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
15 15
      */
16
-    function LeadsJjwg_MapsLogicHook(){
16
+    function LeadsJjwg_MapsLogicHook() {
17 17
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
18
-        if(isset($GLOBALS['log'])) {
18
+        if (isset($GLOBALS['log'])) {
19 19
             $GLOBALS['log']->deprecated($deprecatedMessage);
20 20
         }
21 21
         else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('sugarEntry') || !sugarEntry)
3
+if (!defined('sugarEntry') || !sugarEntry) {
4 4
     die('Not A Valid Entry Point');
5
+}
5 6
 
6 7
 class OpportunitiesJjwg_MapsLogicHook {
7 8
 
@@ -17,8 +18,7 @@  discard block
 block discarded – undo
17 18
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
18 19
         if(isset($GLOBALS['log'])) {
19 20
             $GLOBALS['log']->deprecated($deprecatedMessage);
20
-        }
21
-        else {
21
+        } else {
22 22
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
23 23
         }
24 24
         self::__construct();
Please login to merge, or discard this patch.