Completed
Push — console-installer ( 3d54e5...e2b50d )
by Adam
69:10 queued 48:24
created
modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php 2 patches
Spacing   +18 added lines, -18 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.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
42
+require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php';
43 43
 
44 44
 /*
45 45
  * Class to manage the metadata for a Many-To-Many Relationship
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
      * Constructor
58 58
      * @param array $definition Parameters passed in as array with keys defined in parent::keys
59 59
      */
60
-    function __construct ($definition)
60
+    function __construct($definition)
61 61
     {
62
-        parent::__construct ( $definition ) ;
62
+        parent::__construct($definition);
63 63
     }
64 64
   
65 65
     /*
@@ -71,37 +71,37 @@  discard block
 block discarded – undo
71 71
      * The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
72 72
      * @return array    An array of subpanel definitions, keyed by module
73 73
      */
74
-    function buildSubpanelDefinitions ()
74
+    function buildSubpanelDefinitions()
75 75
     {        
76
-        $subpanelDefinitions = array ( ) ;
76
+        $subpanelDefinitions = array( );
77 77
         if (!$this->relationship_only)
78 78
         {
79
-            $subpanelDefinitions [ $this->rhs_module ] = $this->getSubpanelDefinition ( $this->relationship_name, $this->lhs_module, $this->lhs_subpanel, $this->getLeftModuleSystemLabel() ) ;
80
-            $subpanelDefinitions [ $this->lhs_module ] = $this->getSubpanelDefinition ( $this->relationship_name, $this->rhs_module, $this->rhs_subpanel, $this->getRightModuleSystemLabel() ) ;
79
+            $subpanelDefinitions [$this->rhs_module] = $this->getSubpanelDefinition($this->relationship_name, $this->lhs_module, $this->lhs_subpanel, $this->getLeftModuleSystemLabel());
80
+            $subpanelDefinitions [$this->lhs_module] = $this->getSubpanelDefinition($this->relationship_name, $this->rhs_module, $this->rhs_subpanel, $this->getRightModuleSystemLabel());
81 81
         }
82
-        return $subpanelDefinitions ;
82
+        return $subpanelDefinitions;
83 83
     }
84 84
 
85 85
 
86 86
     /*
87 87
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
88 88
      */
89
-    function buildVardefs ( )
89
+    function buildVardefs( )
90 90
     {
91
-        $vardefs = array ( ) ;
92
-        $vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name, false, 
93
-            'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ) ;
94
-        $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, false, 
95
-            'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()  ) . '_TITLE' ) ;
96
-        return $vardefs ;
91
+        $vardefs = array( );
92
+        $vardefs [$this->rhs_module] [] = $this->getLinkFieldDefinition($this->lhs_module, $this->relationship_name, false, 
93
+            'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE');
94
+        $vardefs [$this->lhs_module] [] = $this->getLinkFieldDefinition($this->rhs_module, $this->relationship_name, false, 
95
+            'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE');
96
+        return $vardefs;
97 97
     }
98 98
     
99 99
     /*
100 100
      * @return array    An array of relationship metadata definitions
101 101
      */
102
-    function buildRelationshipMetaData ()
102
+    function buildRelationshipMetaData()
103 103
     {
104
-        return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_MANYTOMANY ) ) ;
104
+        return array($this->lhs_module => $this->getRelationshipMetaData(MB_MANYTOMANY));
105 105
     }
106 106
     
107 107
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 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.
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
     // have different actual relationship names other than <relationshipName>
67 67
     // e.g $dictionary[ 'quotes_accounts' ] has two relationships: quotes_billto_accounts, quotes_shipto_accounts
68 68
     protected $specialCaseBaseNames = array( 'quotes_accounts',
69
-                                             'quotes_contacts',
70
-                                             'emails_beans',
71
-                                             'linked_documents',
72
-                                             'project_relation',
73
-                                             'prospect_lists_prospects',
74
-                                             'queues_beans',
75
-                                             'queues_queue',
76
-                                             'tracker_sessions'
77
-                                          );
69
+                                                'quotes_contacts',
70
+                                                'emails_beans',
71
+                                                'linked_documents',
72
+                                                'project_relation',
73
+                                                'prospect_lists_prospects',
74
+                                                'queues_beans',
75
+                                                'queues_queue',
76
+                                                'tracker_sessions'
77
+                                            );
78 78
     /*
79 79
      * Find all deployed modules that can participate in a relationship
80 80
      * Return a list of modules with associated subpanels
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     protected function build ($basepath , $installDefPrefix , $relationships )
334 334
     {
335 335
         global $sugar_config;
336
-    	// keep the relationships data separate from any other build data by ading /relationships to the basepath
336
+        // keep the relationships data separate from any other build data by ading /relationships to the basepath
337 337
         $basepath .= '/relationships' ;
338 338
 
339 339
         $installDefs = array ( ) ;
@@ -393,34 +393,34 @@  discard block
 block discarded – undo
393 393
     {
394 394
         global $sugar_config;
395 395
         
396
-       	mkdir_recursive ( "$basepath/language" ) ;
396
+            mkdir_recursive ( "$basepath/language" ) ;
397 397
     	
398
-       	$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ;
398
+            $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ;
399 399
         $installDefs = array ( ) ;
400 400
         foreach ( $labelDefinitions as $definition )
401 401
         {
402
-        	$mod_strings = array();
403
-        	$app_list_strings = array();
402
+            $mod_strings = array();
403
+            $app_list_strings = array();
404 404
         	
405
-        	$out = $headerString;
405
+            $out = $headerString;
406 406
         	
407
-        	$filename = "{$basepath}/language/{$definition['module']}.php" ;
407
+            $filename = "{$basepath}/language/{$definition['module']}.php" ;
408 408
     	
409
-	    	if (file_exists ( $filename ))
410
-	    		include ($filename);
409
+            if (file_exists ( $filename ))
410
+                include ($filename);
411 411
 	    		
412 412
             
413 413
             //Check for app strings
414 414
             $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveLabels(): saving the following to {$filename}" 
415
-                                      . print_r ( $definition, true ) ) ;
415
+                                        . print_r ( $definition, true ) ) ;
416 416
             if ($definition['module'] == 'application') {
417
-            	$app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
418
-            	foreach ($app_list_strings as $key => $val)
419
-            		$out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
417
+                $app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
418
+                foreach ($app_list_strings as $key => $val)
419
+                    $out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
420 420
             } else {
421
-            	$mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ];
422
-            	foreach ($mod_strings as $key => $val)
423
-            		$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
421
+                $mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ];
422
+                foreach ($mod_strings as $key => $val)
423
+                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);
424 424
             }
425 425
             
426 426
             $fh = fopen ( $filename, 'w' ) ;
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
         	
431 431
             foreach($sugar_config['languages'] as $lk => $lv)
432 432
             {
433
-            	$installDefs [ $definition [ 'module' ] . "_$lk" ] = array ( 
434
-            		'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" , 
435
-            		'to_module' => $definition [ 'module' ] , 
436
-            		'language' => $lk 
437
-            	) ;                                 		
433
+                $installDefs [ $definition [ 'module' ] . "_$lk" ] = array ( 
434
+                    'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" , 
435
+                    'to_module' => $definition [ 'module' ] , 
436
+                    'language' => $lk 
437
+                ) ;                                 		
438 438
             }
439 439
             
440 440
             /* do not use the following write_array_to_file method to write the label file - 
441 441
              * module installer appends each of the label files together (as it does for all files) 
442 442
 			 * into a combined label file and so the last $mod_strings is the only one received by the application */
443
-        	// write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ;
443
+            // write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ;
444 444
         }
445 445
         
446 446
         return $installDefs ;
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
             $relName = $moduleName;
535 535
             foreach ( $definitions as $definition )
536 536
             {
537
-            	if (!empty($definition['relationship']))
538
-            	{
539
-            		$relName = $definition['relationship'];
540
-            		break;
541
-            	}
537
+                if (!empty($definition['relationship']))
538
+                {
539
+                    $relName = $definition['relationship'];
540
+                    break;
541
+                }
542 542
             }
543 543
             
544 544
             $filename = "$basepath/vardefs/{$relName}_{$moduleName}.php" ;
@@ -547,14 +547,14 @@  discard block
 block discarded – undo
547 547
             foreach ( $definitions as $definition )
548 548
             {
549 549
                 $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
550
-               	$out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = '
551
-               		  . var_export_helper($definition) . ";\n";
550
+                    $out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = '
551
+                            . var_export_helper($definition) . ";\n";
552 552
             }
553 553
             file_put_contents($filename, $out);
554 554
             
555 555
             $installDefs [ $moduleName ] = array ( 
556
-            	'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" , 
557
-            	'to_module' => $moduleName 
556
+                'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" , 
557
+                'to_module' => $moduleName 
558 558
             ) ;
559 559
         }
560 560
         
Please login to merge, or discard this patch.
Spacing   +199 added lines, -199 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
@@ -50,22 +50,22 @@  discard block
 block discarded – undo
50 50
 class AbstractRelationships
51 51
 {
52 52
     
53
-    static $methods = array (
54
-        'Labels' => 'language' ,
55
-        'RelationshipMetaData' => 'relationships' ,
56
-        'SubpanelDefinitions' => 'layoutdefs' ,
57
-        'Vardefs' => 'vardefs' ,
53
+    static $methods = array(
54
+        'Labels' => 'language',
55
+        'RelationshipMetaData' => 'relationships',
56
+        'SubpanelDefinitions' => 'layoutdefs',
57
+        'Vardefs' => 'vardefs',
58 58
         'FieldsToLayouts' => 'layoutfields',
59
-    ) ;
60
-    static $activities = array ( 'calls' => 'Calls' , 'meetings' => 'Meetings' , 'notes' => 'Notes' , 'tasks' => 'Tasks' , 'emails' => 'Emails' ) ;
59
+    );
60
+    static $activities = array('calls' => 'Calls', 'meetings' => 'Meetings', 'notes' => 'Notes', 'tasks' => 'Tasks', 'emails' => 'Emails');
61 61
     
62
-    protected $relationships = array ( ) ; // array containing all the AbstractRelationship objects that are in this set of relationships
63
-    protected $moduleName ;
62
+    protected $relationships = array( ); // array containing all the AbstractRelationship objects that are in this set of relationships
63
+    protected $moduleName;
64 64
 
65 65
     // bug33522 - the following relationship names that you would find in $dictionary[ <relationshipName> ]
66 66
     // have different actual relationship names other than <relationshipName>
67 67
     // e.g $dictionary[ 'quotes_accounts' ] has two relationships: quotes_billto_accounts, quotes_shipto_accounts
68
-    protected $specialCaseBaseNames = array( 'quotes_accounts',
68
+    protected $specialCaseBaseNames = array('quotes_accounts',
69 69
                                              'quotes_contacts',
70 70
                                              'emails_beans',
71 71
                                              'linked_documents',
@@ -81,56 +81,56 @@  discard block
 block discarded – undo
81 81
      * @param boolean $includeActivitiesSubmodules True if the list should include Calls, Meetings etc; false if they should be replaced by the parent, Activities
82 82
      * @return array    Array of [$module][$subpanel]
83 83
      */
84
-    static function findRelatableModules ($includeActivitiesSubmodules = true)
84
+    static function findRelatableModules($includeActivitiesSubmodules = true)
85 85
     {
86
-        $relatableModules = array ( ) ;
86
+        $relatableModules = array( );
87 87
         
88 88
         // add in activities automatically if required
89
-        $relatableModules [ 'Activities' ] [ 'default' ] = translate( 'LBL_DEFAULT' ) ;
89
+        $relatableModules ['Activities'] ['default'] = translate('LBL_DEFAULT');
90 90
             
91 91
         // find all deployed modules
92
-        require_once 'modules/ModuleBuilder/Module/StudioBrowser.php' ;
93
-        $browser = new StudioBrowser() ;
92
+        require_once 'modules/ModuleBuilder/Module/StudioBrowser.php';
93
+        $browser = new StudioBrowser();
94 94
         $browser->loadRelatableModules();
95
-        reset($browser->modules) ;
95
+        reset($browser->modules);
96 96
 
97
-        while ( list( $moduleName , $module ) = each($browser->modules) )
97
+        while (list($moduleName, $module) = each($browser->modules))
98 98
         {
99 99
             // do not include the submodules of Activities as already have the parent...
100
-            if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities ))
101
-                continue ;
100
+            if (!$includeActivitiesSubmodules && in_array($module->module, self::$activities))
101
+                continue;
102 102
             $providedSubpanels = $module->getProvidedSubpanels();
103
-            if ( $providedSubpanels !== false ) {
104
-                $relatableModules [ $module->module ] = $providedSubpanels;
103
+            if ($providedSubpanels !== false) {
104
+                $relatableModules [$module->module] = $providedSubpanels;
105 105
             }
106 106
         }
107 107
         
108
-        return $relatableModules ;
108
+        return $relatableModules;
109 109
     
110 110
     }
111 111
 
112
-    static function validSubpanel ($filename)
112
+    static function validSubpanel($filename)
113 113
     {
114
-        if (! file_exists ( $filename ))
115
-            return false ;
114
+        if (!file_exists($filename))
115
+            return false;
116 116
         
117
-        include $filename ;
118
-        return (isset ( $subpanel_layout ) && (isset ( $subpanel_layout [ 'top_buttons' ] ) && isset ( $subpanel_layout [ 'list_fields' ] ))) ;
117
+        include $filename;
118
+        return (isset ($subpanel_layout) && (isset ($subpanel_layout ['top_buttons']) && isset ($subpanel_layout ['list_fields'])));
119 119
     }
120 120
 
121 121
     /*
122 122
      * Get a list of all relationships (which have not been deleted)
123 123
      * @return array    Array of relationship names, ready for use in get()
124 124
      */
125
-    function getRelationshipList ()
125
+    function getRelationshipList()
126 126
     {
127
-        $list = array ( ) ;
128
-        foreach ( $this->relationships as $name => $relationship )
127
+        $list = array( );
128
+        foreach ($this->relationships as $name => $relationship)
129 129
         {
130
-            if (! $relationship->deleted ())
131
-                $list [ $name ] = $name ;
130
+            if (!$relationship->deleted())
131
+                $list [$name] = $name;
132 132
         }
133
-        return $list ;
133
+        return $list;
134 134
     }
135 135
 
136 136
     /*
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
      * @param string $relationshipName  The unique name for this relationship, as returned by $relationship->getName()
139 139
      * @return AbstractRelationship or false if $relationshipName is not in this set of relationships
140 140
      */
141
-    function get ($relationshipName)
141
+    function get($relationshipName)
142 142
     {
143
-        if (isset ( $this->relationships [ $relationshipName ] ))
143
+        if (isset ($this->relationships [$relationshipName]))
144 144
         {
145
-            return $this->relationships [ $relationshipName ] ;
145
+            return $this->relationships [$relationshipName];
146 146
         }
147
-        return false ;
147
+        return false;
148 148
     }
149 149
 
150 150
     /*
@@ -153,45 +153,45 @@  discard block
 block discarded – undo
153 153
      * Otherwise, create and add a new relationship with the information in the $_REQUEST
154 154
      * @return AbstractRelationship
155 155
      */
156
-    function addFromPost ()
156
+    function addFromPost()
157 157
     {
158
-        $definition = array ( ) ;
158
+        $definition = array( );
159 159
         
160
-        require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
161
-        foreach ( AbstractRelationship::$definitionKeys as $key )
160
+        require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php';
161
+        foreach (AbstractRelationship::$definitionKeys as $key)
162 162
         {
163
-            if (! empty ( $_REQUEST [ $key ] ))
163
+            if (!empty ($_REQUEST [$key]))
164 164
             {
165
-                $definition [ $key ] = ($key == 'relationship_type') ? AbstractRelationship::parseRelationshipType ( $_REQUEST [ $key ] ) : $_REQUEST [ $key ] ;
165
+                $definition [$key] = ($key == 'relationship_type') ? AbstractRelationship::parseRelationshipType($_REQUEST [$key]) : $_REQUEST [$key];
166 166
             }
167 167
         }
168 168
         
169 169
         // if this is a change to an existing relationship, and it is not readonly, then delete the old one
170
-        if (! empty ( $_REQUEST [ 'relationship_name' ] ))
170
+        if (!empty ($_REQUEST ['relationship_name']))
171 171
         {
172
-            if ($relationship = $this->get ( $_REQUEST [ 'relationship_name' ] ))
172
+            if ($relationship = $this->get($_REQUEST ['relationship_name']))
173 173
             {
174
-                unset( $definition[ 'relationship_name' ] ) ; // in case the related modules have changed; this name is probably no longer appropriate
175
-                if (! $relationship->readonly ())
176
-                    $this->delete ( $_REQUEST [ 'relationship_name' ] ) ;
174
+                unset($definition['relationship_name']); // in case the related modules have changed; this name is probably no longer appropriate
175
+                if (!$relationship->readonly())
176
+                    $this->delete($_REQUEST ['relationship_name']);
177 177
         }
178 178
         }
179 179
         
180
-        $newRelationship = RelationshipFactory::newRelationship ( $definition ) ;
180
+        $newRelationship = RelationshipFactory::newRelationship($definition);
181 181
         // TODO: error handling in case we get a badly formed definition and hence relationship
182
-        $this->add ( $newRelationship ) ;
183
-        return $newRelationship ;
182
+        $this->add($newRelationship);
183
+        return $newRelationship;
184 184
     }
185 185
 
186 186
     /*
187 187
      * Add a relationship to the set
188 188
      * @param AbstractRelationship $relationship    The relationship to add
189 189
      */
190
-    function add ($relationship)
190
+    function add($relationship)
191 191
     {
192
-        $name = $this->getUniqueName ( $relationship ) ;
193
-        $relationship->setName ( $name ) ;
194
-        $this->relationships [ $name ] = $relationship ;
192
+        $name = $this->getUniqueName($relationship);
193
+        $relationship->setName($name);
194
+        $this->relationships [$name] = $relationship;
195 195
     }
196 196
 
197 197
     /*
@@ -200,52 +200,52 @@  discard block
 block discarded – undo
200 200
      * @param string $basepath  Base directory in which to store the relationships information
201 201
      * @return Array of AbstractRelationship objects
202 202
      */
203
-    protected function _load ($basepath)
203
+    protected function _load($basepath)
204 204
     {
205
-        $GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": loading relationships from " . $basepath . '/relationships.php' ) ;
206
-        $objects = array ( ) ;
207
-        if (file_exists ( $basepath . '/relationships.php' ))
205
+        $GLOBALS ['log']->info(get_class($this).": loading relationships from ".$basepath.'/relationships.php');
206
+        $objects = array( );
207
+        if (file_exists($basepath.'/relationships.php'))
208 208
         {
209
-            include ($basepath . '/relationships.php') ;
210
-            foreach ( $relationships as $name => $definition )
209
+            include ($basepath.'/relationships.php');
210
+            foreach ($relationships as $name => $definition)
211 211
             {
212 212
                 // update any pre-5.1 relationships to the new definitions
213 213
                 // we do this here, rather than when upgrading from 5.0 to 5.1, as modules exported from MB in 5.0 may be loaded into 5.1 at any time
214 214
                 // note also that since these definitions are only found in the relationships.php working file they only occur for deployed or exported modules, not published then loaded modules
215
-                $definition = $this->_updateRelationshipDefinition( $definition ) ;
216
-                $relationship = RelationshipFactory::newRelationship ( $definition ) ;
215
+                $definition = $this->_updateRelationshipDefinition($definition);
216
+                $relationship = RelationshipFactory::newRelationship($definition);
217 217
                 // make sure it has a unique name
218
-                if (! isset( $definition [ 'relationship_name' ] ) )
218
+                if (!isset($definition ['relationship_name']))
219 219
                 {
220
-                    $name = $this->getUniqueName ( $relationship ) ;
221
-                    $relationship->setName ( $name ) ;
220
+                    $name = $this->getUniqueName($relationship);
221
+                    $relationship->setName($name);
222 222
                 }
223
-                $objects [ $name ] = $relationship ;
223
+                $objects [$name] = $relationship;
224 224
             }
225 225
         }
226
-        return $objects ;
226
+        return $objects;
227 227
     }
228 228
 
229 229
     /*
230 230
      * Save the set of relationships to a file
231 231
      * @param string $basepath  Base directory in which to store the relationships information
232 232
      */
233
-    protected function _save ($relationships , $basepath)
233
+    protected function _save($relationships, $basepath)
234 234
     {
235
-        $GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": saving relationships to " . $basepath . '/relationships.php' ) ;
236
-        $header = file_get_contents ( 'modules/ModuleBuilder/MB/header.php' ) ;
235
+        $GLOBALS ['log']->info(get_class($this).": saving relationships to ".$basepath.'/relationships.php');
236
+        $header = file_get_contents('modules/ModuleBuilder/MB/header.php');
237 237
         
238
-        $definitions = array ( ) ;
238
+        $definitions = array( );
239 239
         
240
-        foreach ( $relationships as $relationship )
240
+        foreach ($relationships as $relationship)
241 241
         {
242 242
             // if (! $relationship->readonly ())
243
-            $definitions [ $relationship->getName () ] = $relationship->getDefinition () ;
243
+            $definitions [$relationship->getName()] = $relationship->getDefinition();
244 244
         }
245 245
         
246
-        mkdir_recursive ( $basepath ) ;
246
+        mkdir_recursive($basepath);
247 247
         // replace any existing relationships.php
248
-        write_array_to_file ( 'relationships', $definitions, $basepath . '/relationships.php', 'w', $header ) ;
248
+        write_array_to_file('relationships', $definitions, $basepath.'/relationships.php', 'w', $header);
249 249
     }
250 250
 
251 251
     /*
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
      * relationship (products-products) uses it (and there it makes no difference from our POV) and we don't use it when creating new ones
259 259
      * @return array Array of $relationshipName => $relationshipDefinition as an array
260 260
      */
261
-    protected function getDeployedRelationships ()
261
+    protected function getDeployedRelationships()
262 262
     {
263 263
         
264
-        $db = DBManagerFactory::getInstance () ;
265
-        $query = "SELECT * FROM relationships WHERE deleted = 0" ;
266
-        $result = $db->query ( $query ) ;
267
-        while ( $row = $db->fetchByAssoc ( $result ) )
264
+        $db = DBManagerFactory::getInstance();
265
+        $query = "SELECT * FROM relationships WHERE deleted = 0";
266
+        $result = $db->query($query);
267
+        while ($row = $db->fetchByAssoc($result))
268 268
         {
269 269
             // set this relationship to readonly
270
-            $row [ 'readonly' ] = true ;
271
-            $relationships [ $row [ 'relationship_name' ] ] = $row ;
270
+            $row ['readonly'] = true;
271
+            $relationships [$row ['relationship_name']] = $row;
272 272
         }
273 273
         
274
-        return $relationships ;
274
+        return $relationships;
275 275
     }
276 276
 
277 277
     /*
@@ -280,48 +280,48 @@  discard block
 block discarded – undo
280 280
      * @param AbstractRelationship The relationship object
281 281
      * @return string A globally unique relationship name
282 282
      */
283
-    protected function getUniqueName ($relationship)
283
+    protected function getUniqueName($relationship)
284 284
     {
285
-        $allRelationships = $this->getRelationshipList () ;
286
-        $basename = $relationship->getName () ;
285
+        $allRelationships = $this->getRelationshipList();
286
+        $basename = $relationship->getName();
287 287
         
288
-        if (empty ( $basename ))
288
+        if (empty ($basename))
289 289
         {
290 290
             // start off with the proposed name being simply lhs_module_rhs_module
291
-            $definition = $relationship->getDefinition () ;
292
-            $basename = strtolower ( $definition [ 'lhs_module' ] . '_' . $definition [ 'rhs_module' ] ) ;
291
+            $definition = $relationship->getDefinition();
292
+            $basename = strtolower($definition ['lhs_module'].'_'.$definition ['rhs_module']);
293 293
         }
294 294
         
295 295
         // Bug #49024 : Relationships Created in Earlier Versions Cause Conflicts and AJAX Errors After Upgrade
296 296
         // ...all custom relationships created via Studio should always have a numeric identifier attached.
297
-        if ( $this instanceof DeployedRelationships )
297
+        if ($this instanceof DeployedRelationships)
298 298
         {
299
-            $name = $basename . '_1' ;
300
-            $suffix = 2 ;
299
+            $name = $basename.'_1';
300
+            $suffix = 2;
301 301
         }
302 302
         else
303 303
         {
304
-            $name = $basename ;
305
-            $suffix = 1 ;
304
+            $name = $basename;
305
+            $suffix = 1;
306 306
         }
307 307
         
308
-        while ( isset ( $allRelationships [ $name ] ) )
308
+        while (isset ($allRelationships [$name]))
309 309
         {
310
-            $name = $basename . "_" . ( string ) ($suffix ++) ;
310
+            $name = $basename."_".(string)($suffix++);
311 311
         }
312 312
 
313 313
         // bug33522 - if our relationship basename is in the special cases
314
-        if( in_array( $name , $this->specialCaseBaseNames ) )  {
314
+        if (in_array($name, $this->specialCaseBaseNames)) {
315 315
             //add a _1 (or _suffix#) and check to see if it already exists
316
-            $name = $name . "_" . ( string ) ($suffix ++);
317
-            while ( isset ( $allRelationships [ $name ] ) )
316
+            $name = $name."_".(string)($suffix++);
317
+            while (isset ($allRelationships [$name]))
318 318
             {
319 319
                 // if it does exist, strip off the _1 previously added and try again
320
-                $name = substr( $name , 0 , -2 ) . "_" . ( string ) ($suffix ++);
320
+                $name = substr($name, 0, -2)."_".(string)($suffix++);
321 321
             }
322 322
         }
323 323
 
324
-        return $name ;
324
+        return $name;
325 325
     }
326 326
     
327 327
     /*
@@ -330,40 +330,40 @@  discard block
 block discarded – undo
330 330
      * @param string $installDefPrefix  Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
331 331
      * @param array $relationships      Relationships to implement
332 332
      */
333
-    protected function build ($basepath , $installDefPrefix , $relationships )
333
+    protected function build($basepath, $installDefPrefix, $relationships)
334 334
     {
335 335
         global $sugar_config;
336 336
     	// keep the relationships data separate from any other build data by ading /relationships to the basepath
337
-        $basepath .= '/relationships' ;
337
+        $basepath .= '/relationships';
338 338
 
339
-        $installDefs = array ( ) ;
340
-        $compositeAdded = false ;
341
-        foreach ( self::$methods as $method => $key )
339
+        $installDefs = array( );
340
+        $compositeAdded = false;
341
+        foreach (self::$methods as $method => $key)
342 342
         {
343
-            $buildMethod = 'build' . $method ;
344
-            $saveMethod = 'save' . $method ;
343
+            $buildMethod = 'build'.$method;
344
+            $saveMethod = 'save'.$method;
345 345
             
346
-            foreach ( $relationships as $name => $relationship )
346
+            foreach ($relationships as $name => $relationship)
347 347
             {
348
-                if (! ($relationship->readonly () || $relationship->deleted ()))
348
+                if (!($relationship->readonly() || $relationship->deleted()))
349 349
                 {
350
-                    if (method_exists ( $relationship, $buildMethod ) && method_exists ( $this, $saveMethod ))
350
+                    if (method_exists($relationship, $buildMethod) && method_exists($this, $saveMethod))
351 351
                     {
352
-                        $metadata = $relationship->$buildMethod () ;
352
+                        $metadata = $relationship->$buildMethod();
353 353
                         
354
-                        if (count ( $metadata ) > 0) // don't clutter up the filesystem with empty files...
354
+                        if (count($metadata) > 0) // don't clutter up the filesystem with empty files...
355 355
                         {
356
-                            $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": BUILD is running METHOD $saveMethod" ) ;
357
-                            $installDef = $this->$saveMethod ( $basepath, $installDefPrefix, $name, $metadata ) ;
356
+                            $GLOBALS ['log']->debug(get_class($this).": BUILD is running METHOD $saveMethod");
357
+                            $installDef = $this->$saveMethod($basepath, $installDefPrefix, $name, $metadata);
358 358
                             
359 359
                             // some save methods (e.g., saveRelateFieldDefinition) handle the installDefs internally and so return null
360 360
 
361 361
                         
362
-                            if (! is_null ( $installDef ))
362
+                            if (!is_null($installDef))
363 363
                             {
364
-                                foreach ( $installDef as $moduleName => $def )
364
+                                foreach ($installDef as $moduleName => $def)
365 365
                                 {
366
-                                    $installDefs [ $key ] [ ] = $def ;                                    	                                   
366
+                                    $installDefs [$key] [] = $def;                                    	                                   
367 367
                                 }
368 368
                             }
369 369
                         }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             }
374 374
         }
375 375
         
376
-        return $installDefs ;
376
+        return $installDefs;
377 377
     }
378 378
 
379 379
     /*
@@ -389,52 +389,52 @@  discard block
 block discarded – undo
389 389
      * @param array $labelDefinitions       Array of System label => Display label pairs
390 390
      * @return null Nothing to be added to the installdefs for an undeployed module
391 391
      */
392
-    protected function saveLabels ($basepath , $installDefPrefix , $relationshipName , $labelDefinitions)
392
+    protected function saveLabels($basepath, $installDefPrefix, $relationshipName, $labelDefinitions)
393 393
     {
394 394
         global $sugar_config;
395 395
         
396
-       	mkdir_recursive ( "$basepath/language" ) ;
396
+       	mkdir_recursive("$basepath/language");
397 397
     	
398
-       	$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ;
399
-        $installDefs = array ( ) ;
400
-        foreach ( $labelDefinitions as $definition )
398
+       	$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
399
+        $installDefs = array( );
400
+        foreach ($labelDefinitions as $definition)
401 401
         {
402 402
         	$mod_strings = array();
403 403
         	$app_list_strings = array();
404 404
         	
405 405
         	$out = $headerString;
406 406
         	
407
-        	$filename = "{$basepath}/language/{$definition['module']}.php" ;
407
+        	$filename = "{$basepath}/language/{$definition['module']}.php";
408 408
     	
409
-	    	if (file_exists ( $filename ))
409
+	    	if (file_exists($filename))
410 410
 	    		include ($filename);
411 411
 	    		
412 412
             
413 413
             //Check for app strings
414
-            $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveLabels(): saving the following to {$filename}" 
415
-                                      . print_r ( $definition, true ) ) ;
414
+            $GLOBALS ['log']->debug(get_class($this)."->saveLabels(): saving the following to {$filename}" 
415
+                                      . print_r($definition, true));
416 416
             if ($definition['module'] == 'application') {
417
-            	$app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
417
+            	$app_list_strings[$definition ['system_label']] = $definition ['display_label'];
418 418
             	foreach ($app_list_strings as $key => $val)
419 419
             		$out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
420 420
             } else {
421
-            	$mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ];
421
+            	$mod_strings[$definition ['system_label']] = $definition ['display_label'];
422 422
             	foreach ($mod_strings as $key => $val)
423 423
             		$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
424 424
             }
425 425
             
426
-            $fh = fopen ( $filename, 'w' ) ;
427
-            fputs ( $fh, $out, strlen ( $out ) ) ;
428
-            fclose ( $fh ) ;
426
+            $fh = fopen($filename, 'w');
427
+            fputs($fh, $out, strlen($out));
428
+            fclose($fh);
429 429
             
430 430
         	
431
-            foreach($sugar_config['languages'] as $lk => $lv)
431
+            foreach ($sugar_config['languages'] as $lk => $lv)
432 432
             {
433
-            	$installDefs [ $definition [ 'module' ] . "_$lk" ] = array ( 
434
-            		'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" , 
435
-            		'to_module' => $definition [ 'module' ] , 
433
+            	$installDefs [$definition ['module']."_$lk"] = array( 
434
+            		'from' => "{$installDefPrefix}/relationships/language/{$definition ['module']}.php", 
435
+            		'to_module' => $definition ['module'], 
436 436
             		'language' => $lk 
437
-            	) ;                                 		
437
+            	);                                 		
438 438
             }
439 439
             
440 440
             /* do not use the following write_array_to_file method to write the label file - 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         	// write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ;
444 444
         }
445 445
         
446
-        return $installDefs ;
446
+        return $installDefs;
447 447
     }
448 448
 
449 449
     /*
@@ -454,18 +454,18 @@  discard block
 block discarded – undo
454 454
      * @param array $relationshipMetaData   Set of metadata definitions in the form $relationshipMetaData[$relationshipName]
455 455
      * @return array $installDefs           Set of new installDefs
456 456
      */
457
-    protected function saveRelationshipMetaData ($basepath , $installDefPrefix , $relationshipName , $relationshipMetaData)
457
+    protected function saveRelationshipMetaData($basepath, $installDefPrefix, $relationshipName, $relationshipMetaData)
458 458
     {
459
-        mkdir_recursive ( "$basepath/relationships" ) ;
459
+        mkdir_recursive("$basepath/relationships");
460 460
         
461
-        $installDefs = array ( ) ;
462
-        list ( $rhs_module, $properties ) = each ( $relationshipMetaData ) ;
463
-        $filename = "$basepath/relationships/{$relationshipName}MetaData.php" ;
464
-        $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveRelationshipMetaData(): saving the following to {$filename}" . print_r ( $properties, true ) ) ;
465
-        write_array_to_file ( 'dictionary["' . $relationshipName . '"]', $properties, "{$filename}", 'w' ) ;
466
-        $installDefs [ $relationshipName ] = array ( /*'module' => $rhs_module , 'module_vardefs' => "<basepath>/Vardefs/{$relationshipName}.php" ,*/ 'meta_data' => "{$installDefPrefix}/relationships/relationships/{$relationshipName}MetaData.php" ) ;
461
+        $installDefs = array( );
462
+        list ($rhs_module, $properties) = each($relationshipMetaData);
463
+        $filename = "$basepath/relationships/{$relationshipName}MetaData.php";
464
+        $GLOBALS ['log']->debug(get_class($this)."->saveRelationshipMetaData(): saving the following to {$filename}".print_r($properties, true));
465
+        write_array_to_file('dictionary["'.$relationshipName.'"]', $properties, "{$filename}", 'w');
466
+        $installDefs [$relationshipName] = array( /*'module' => $rhs_module , 'module_vardefs' => "<basepath>/Vardefs/{$relationshipName}.php" ,*/ 'meta_data' => "{$installDefPrefix}/relationships/relationships/{$relationshipName}MetaData.php" );
467 467
         
468
-        return $installDefs ;
468
+        return $installDefs;
469 469
     }
470 470
 
471 471
     /*
@@ -475,31 +475,31 @@  discard block
 block discarded – undo
475 475
      * @param array $subpanelDefinitions    Set of subpanel definitions in the form $subpanelDefinitions[$for_module][]
476 476
      * @return array $installDefs           Set of new installDefs
477 477
      */
478
-    protected function saveSubpanelDefinitions ($basepath , $installDefPrefix , $relationshipName , $subpanelDefinitions)
478
+    protected function saveSubpanelDefinitions($basepath, $installDefPrefix, $relationshipName, $subpanelDefinitions)
479 479
     {
480
-        mkdir_recursive ( "$basepath/layoutdefs/" ) ;
480
+        mkdir_recursive("$basepath/layoutdefs/");
481 481
         
482
-        foreach ( $subpanelDefinitions as $moduleName => $definitions )
482
+        foreach ($subpanelDefinitions as $moduleName => $definitions)
483 483
         {
484
-            $filename = "$basepath/layoutdefs/{$relationshipName}_{$moduleName}.php" ;
485
-            $subpanelVarname = 'layout_defs["' . $moduleName . '"]["subpanel_setup"]';
484
+            $filename = "$basepath/layoutdefs/{$relationshipName}_{$moduleName}.php";
485
+            $subpanelVarname = 'layout_defs["'.$moduleName.'"]["subpanel_setup"]';
486 486
             $out = "";
487
-            foreach ( $definitions as $definition )
487
+            foreach ($definitions as $definition)
488 488
             {
489
-                $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveSubpanelDefinitions(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
489
+                $GLOBALS ['log']->debug(get_class($this)."->saveSubpanelDefinitions(): saving the following to {$filename}".print_r($definition, true));
490 490
                 if (empty($definition ['get_subpanel_data']) || $definition ['subpanel_name'] == 'history' || $definition ['subpanel_name'] == 'activities') {
491 491
                     $definition ['get_subpanel_data'] = $definition ['subpanel_name'];
492 492
                 }
493
-                $out .= override_value_to_string($subpanelVarname, strtolower ( $definition [ 'get_subpanel_data' ] ), $definition) . "\n";
493
+                $out .= override_value_to_string($subpanelVarname, strtolower($definition ['get_subpanel_data']), $definition)."\n";
494 494
             }
495 495
             if (!empty($out)) {
496
-                $out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n" . $out;
496
+                $out = "<?php\n // created: ".date('Y-m-d H:i:s')."\n".$out;
497 497
                 sugar_file_put_contents($filename, $out);
498 498
             }
499 499
 
500
-            $installDefs [ $moduleName ] = array ( 'from' => "{$installDefPrefix}/relationships/layoutdefs/{$relationshipName}_{$moduleName}.php" , 'to_module' => $moduleName ) ;
500
+            $installDefs [$moduleName] = array('from' => "{$installDefPrefix}/relationships/layoutdefs/{$relationshipName}_{$moduleName}.php", 'to_module' => $moduleName);
501 501
         }
502
-        return $installDefs ;
502
+        return $installDefs;
503 503
     }
504 504
 
505 505
 
@@ -514,25 +514,25 @@  discard block
 block discarded – undo
514 514
      * @param array $linkFieldDefinitions   Set of link field definitions in the form $linkFieldDefinitions[$for_module]
515 515
      * @return array $installDefs           Set of new installDefs
516 516
      */
517
-    protected function saveVardefs ($basepath , $installDefPrefix , $relationshipName , $vardefs)
517
+    protected function saveVardefs($basepath, $installDefPrefix, $relationshipName, $vardefs)
518 518
     {
519
-        mkdir_recursive ( "$basepath/vardefs/" ) ;
520
-        $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): vardefs =" . print_r ( $vardefs, true ) ) ;
519
+        mkdir_recursive("$basepath/vardefs/");
520
+        $GLOBALS ['log']->debug(get_class($this)."->saveVardefs(): vardefs =".print_r($vardefs, true));
521 521
         
522
-        foreach ( $vardefs as $moduleName => $definitions )
522
+        foreach ($vardefs as $moduleName => $definitions)
523 523
         {
524 524
             // find this module's Object name - the object name, not the module name, is used as the key in the vardefs...
525
-            if (isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] ))
525
+            if (isset ($GLOBALS ['beanList'] [$moduleName]))
526 526
             {
527
-                $module = get_module_info ( $moduleName ) ;
528
-                $object = $module->object_name ;
527
+                $module = get_module_info($moduleName);
528
+                $object = $module->object_name;
529 529
             } else
530 530
             {
531
-                $object = $moduleName ;
531
+                $object = $moduleName;
532 532
             }
533 533
             
534 534
             $relName = $moduleName;
535
-            foreach ( $definitions as $definition )
535
+            foreach ($definitions as $definition)
536 536
             {
537 537
             	if (!empty($definition['relationship']))
538 538
             	{
@@ -541,26 +541,26 @@  discard block
 block discarded – undo
541 541
             	}
542 542
             }
543 543
             
544
-            $filename = "$basepath/vardefs/{$relName}_{$moduleName}.php" ;
544
+            $filename = "$basepath/vardefs/{$relName}_{$moduleName}.php";
545 545
             
546
-            $out =  "<?php\n// created: " . date('Y-m-d H:i:s') . "\n";
547
-            foreach ( $definitions as $definition )
546
+            $out = "<?php\n// created: ".date('Y-m-d H:i:s')."\n";
547
+            foreach ($definitions as $definition)
548 548
             {
549
-                $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
550
-               	$out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = '
551
-               		  . var_export_helper($definition) . ";\n";
549
+                $GLOBALS ['log']->debug(get_class($this)."->saveVardefs(): saving the following to {$filename}".print_r($definition, true));
550
+               	$out .= '$dictionary["'.$object.'"]["fields"]["'.$definition ['name'].'"] = '
551
+               		  . var_export_helper($definition).";\n";
552 552
             }
553 553
             file_put_contents($filename, $out);
554 554
             
555
-            $installDefs [ $moduleName ] = array ( 
556
-            	'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" , 
555
+            $installDefs [$moduleName] = array( 
556
+            	'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php", 
557 557
             	'to_module' => $moduleName 
558
-            ) ;
558
+            );
559 559
         }
560 560
         
561
-        $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): installDefs =" . print_r ( $installDefs, true ) ) ;
561
+        $GLOBALS ['log']->debug(get_class($this)."->saveVardefs(): installDefs =".print_r($installDefs, true));
562 562
         
563
-        return $installDefs ;
563
+        return $installDefs;
564 564
     
565 565
     }
566 566
 
@@ -571,37 +571,37 @@  discard block
 block discarded – undo
571 571
      * @param $deployedName Name of the module in the deployed form - that is, keyname_modulename or modulename
572 572
      * @return array ('moduleName'=>name, 'packageName'=>package) if undeployed, ('moduleName'=>name) if deployed
573 573
      */
574
-    static function parseDeployedModuleName ($deployedName)
574
+    static function parseDeployedModuleName($deployedName)
575 575
     {
576
-        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
577
-        $mb = new ModuleBuilder ( ) ;
576
+        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
577
+        $mb = new ModuleBuilder( );
578 578
         
579
-        $packageName = '' ;
580
-        $moduleName = $deployedName ;
579
+        $packageName = '';
580
+        $moduleName = $deployedName;
581 581
         
582
-        foreach ( $mb->getPackageList () as $name )
582
+        foreach ($mb->getPackageList() as $name)
583 583
         {
584 584
             // convert the keyName into a packageName, needed for checking to see if this is really an undeployed module, or just a module with a _ in the name...
585
-            $package = $mb->getPackage ( $name ) ; // seem to need to call getPackage twice to get the key correctly... TODO: figure out why...
586
-            $key = $mb->getPackage ( $name )->key ;
587
-            if (strlen ( $key ) < strlen ( $deployedName ))
585
+            $package = $mb->getPackage($name); // seem to need to call getPackage twice to get the key correctly... TODO: figure out why...
586
+            $key = $mb->getPackage($name)->key;
587
+            if (strlen($key) < strlen($deployedName))
588 588
             {
589
-                $position = stripos ( $deployedName, $key ) ;
590
-                $moduleName = trim( substr( $deployedName , strlen($key) ) , '_' ); //use trim rather than just assuming that _ is between packageName and moduleName in the deployedName
591
-                if ( $position !== false && $position == 0 && (isset ( $mb->packages [ $name ]->modules [ $moduleName ] )))
589
+                $position = stripos($deployedName, $key);
590
+                $moduleName = trim(substr($deployedName, strlen($key)), '_'); //use trim rather than just assuming that _ is between packageName and moduleName in the deployedName
591
+                if ($position !== false && $position == 0 && (isset ($mb->packages [$name]->modules [$moduleName])))
592 592
                 {
593
-                    $packageName = $name ;
594
-                    break ;
593
+                    $packageName = $name;
594
+                    break;
595 595
                 }
596 596
             }
597 597
         }
598 598
         
599
-        if (! empty ( $packageName ))
599
+        if (!empty ($packageName))
600 600
         {
601
-            return array ( 'moduleName' => $moduleName , 'packageName' => $packageName ) ;
601
+            return array('moduleName' => $moduleName, 'packageName' => $packageName);
602 602
         } else
603 603
         {
604
-            return array ( 'moduleName' => $deployedName ) ;
604
+            return array('moduleName' => $deployedName);
605 605
         }
606 606
     }
607 607
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 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
@@ -97,8 +98,9 @@  discard block
 block discarded – undo
97 98
         while ( list( $moduleName , $module ) = each($browser->modules) )
98 99
         {
99 100
             // do not include the submodules of Activities as already have the parent...
100
-            if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities ))
101
-                continue ;
101
+            if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities )) {
102
+                            continue ;
103
+            }
102 104
             $providedSubpanels = $module->getProvidedSubpanels();
103 105
             if ( $providedSubpanels !== false ) {
104 106
                 $relatableModules [ $module->module ] = $providedSubpanels;
@@ -111,8 +113,9 @@  discard block
 block discarded – undo
111 113
 
112 114
     static function validSubpanel ($filename)
113 115
     {
114
-        if (! file_exists ( $filename ))
115
-            return false ;
116
+        if (! file_exists ( $filename )) {
117
+                    return false ;
118
+        }
116 119
         
117 120
         include $filename ;
118 121
         return (isset ( $subpanel_layout ) && (isset ( $subpanel_layout [ 'top_buttons' ] ) && isset ( $subpanel_layout [ 'list_fields' ] ))) ;
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
         $list = array ( ) ;
128 131
         foreach ( $this->relationships as $name => $relationship )
129 132
         {
130
-            if (! $relationship->deleted ())
131
-                $list [ $name ] = $name ;
133
+            if (! $relationship->deleted ()) {
134
+                            $list [ $name ] = $name ;
135
+            }
132 136
         }
133 137
         return $list ;
134 138
     }
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
             if ($relationship = $this->get ( $_REQUEST [ 'relationship_name' ] ))
173 177
             {
174 178
                 unset( $definition[ 'relationship_name' ] ) ; // in case the related modules have changed; this name is probably no longer appropriate
175
-                if (! $relationship->readonly ())
176
-                    $this->delete ( $_REQUEST [ 'relationship_name' ] ) ;
179
+                if (! $relationship->readonly ()) {
180
+                                    $this->delete ( $_REQUEST [ 'relationship_name' ] ) ;
181
+                }
177 182
         }
178 183
         }
179 184
         
@@ -298,8 +303,7 @@  discard block
 block discarded – undo
298 303
         {
299 304
             $name = $basename . '_1' ;
300 305
             $suffix = 2 ;
301
-        }
302
-        else
306
+        } else
303 307
         {
304 308
             $name = $basename ;
305 309
             $suffix = 1 ;
@@ -351,9 +355,11 @@  discard block
 block discarded – undo
351 355
                     {
352 356
                         $metadata = $relationship->$buildMethod () ;
353 357
                         
354
-                        if (count ( $metadata ) > 0) // don't clutter up the filesystem with empty files...
358
+                        if (count ( $metadata ) > 0) {
359
+                            // don't clutter up the filesystem with empty files...
355 360
                         {
356 361
                             $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": BUILD is running METHOD $saveMethod" ) ;
362
+                        }
357 363
                             $installDef = $this->$saveMethod ( $basepath, $installDefPrefix, $name, $metadata ) ;
358 364
                             
359 365
                             // some save methods (e.g., saveRelateFieldDefinition) handle the installDefs internally and so return null
@@ -406,8 +412,9 @@  discard block
 block discarded – undo
406 412
         	
407 413
         	$filename = "{$basepath}/language/{$definition['module']}.php" ;
408 414
     	
409
-	    	if (file_exists ( $filename ))
410
-	    		include ($filename);
415
+	    	if (file_exists ( $filename )) {
416
+	    		    		include ($filename);
417
+	    	}
411 418
 	    		
412 419
             
413 420
             //Check for app strings
@@ -415,12 +422,14 @@  discard block
 block discarded – undo
415 422
                                       . print_r ( $definition, true ) ) ;
416 423
             if ($definition['module'] == 'application') {
417 424
             	$app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
418
-            	foreach ($app_list_strings as $key => $val)
419
-            		$out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
425
+            	foreach ($app_list_strings as $key => $val) {
426
+            	            		$out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
427
+            	}
420 428
             } else {
421 429
             	$mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ];
422
-            	foreach ($mod_strings as $key => $val)
423
-            		$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
430
+            	foreach ($mod_strings as $key => $val) {
431
+            	            		$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
432
+            	}
424 433
             }
425 434
             
426 435
             $fh = fopen ( $filename, 'w' ) ;
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
             }
285 285
             $module->setAppListStrings ( 'en_us', $appStrings ) ;
286 286
             $module->save () ;
287
-			//Bug42170================================
288
-		}
287
+            //Bug42170================================
288
+        }
289 289
         
290 290
         // use an installDefPrefix of <basepath>/SugarModules for compatibility with the rest of ModuleBuilder
291 291
         $this->installDefs = parent::build ( $basepath, "<basepath>/SugarModules", $relationships ) ;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                         $fieldsToAdd [$deployedModuleName] = $fieldName;
419 419
                     }
420 420
                 }
421
-        	}
421
+            }
422 422
         }
423 423
         return array(array('additional_fields' => $fieldsToAdd));
424 424
     }
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 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,16 +40,16 @@  discard block
 block discarded – undo
40 40
  ********************************************************************************/
41 41
 
42 42
 
43
-require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
44
-require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php' ;
45
-require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ;
43
+require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php';
44
+require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php';
45
+require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php';
46 46
 
47 47
 class UndeployedRelationships extends AbstractRelationships implements RelationshipsInterface
48 48
 {
49 49
     
50
-    protected $basepath ; // Base directory for the lhs_module
51
-    protected $packageName ;
52
-    private $activitiesToAdd ; // if we need to add in the composite Activities and History subpanels to the module during the build
50
+    protected $basepath; // Base directory for the lhs_module
51
+    protected $packageName;
52
+    private $activitiesToAdd; // if we need to add in the composite Activities and History subpanels to the module during the build
53 53
 
54 54
     
55 55
     /*
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
      * Automatically loads in any saved relationships
58 58
      * @param string $path  The pathname of the base module directory
59 59
      */
60
-    function __construct ($path)
60
+    function __construct($path)
61 61
     {
62
-        $this->basepath = $path ;
62
+        $this->basepath = $path;
63 63
         // pull the module and package names out of the path
64
-        $this->moduleName = basename ( $path, "/" ) ; // just in case there are any trailing /
65
-        $this->packageName = basename ( dirname ( dirname ( $path ) ) ) ; // simpler than explode :)
66
-        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
67
-        $mb = new ModuleBuilder ( ) ;
68
-        $this->packageKey = $mb->getPackageKey ( $this->packageName ) ;
64
+        $this->moduleName = basename($path, "/"); // just in case there are any trailing /
65
+        $this->packageName = basename(dirname(dirname($path))); // simpler than explode :)
66
+        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
67
+        $mb = new ModuleBuilder( );
68
+        $this->packageKey = $mb->getPackageKey($this->packageName);
69 69
         
70
-        $this->load () ;
70
+        $this->load();
71 71
     
72 72
     }
73 73
 
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
      * Find all modules, deployed and undeployed, that can participate in a relationship
76 76
      * @return array    Array of [$module][$subpanel]
77 77
      */
78
-    static function findRelatableModules ($includeActivitiesSubmodules = true)
78
+    static function findRelatableModules($includeActivitiesSubmodules = true)
79 79
     {
80 80
         // first find all deployed modules that we might participate in a relationship
81
-        $relatableModules = parent::findRelatableModules ($includeActivitiesSubmodules ) ;
81
+        $relatableModules = parent::findRelatableModules($includeActivitiesSubmodules);
82 82
         
83 83
         // now add in the undeployed modules - those in custom/modulebuilder
84 84
         // note that if a module exists in both deployed and undeployed forms, the subpanels from the undeployed form are used...  
85 85
 
86
-        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
87
-        $mb = new ModuleBuilder ( ) ;
88
-        $mb->getPackages () ;
89
-        foreach ( $mb->getPackageList () as $packageName )
86
+        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
87
+        $mb = new ModuleBuilder( );
88
+        $mb->getPackages();
89
+        foreach ($mb->getPackageList() as $packageName)
90 90
         {
91
-            $package = $mb->packages [ $packageName ] ;
92
-            foreach ( $package->modules as $module )
91
+            $package = $mb->packages [$packageName];
92
+            foreach ($package->modules as $module)
93 93
             {
94
-                $relatableModules [ $package->key . "_" . $module->name ] = $module->getProvidedSubpanels () ;
94
+                $relatableModules [$package->key."_".$module->name] = $module->getProvidedSubpanels();
95 95
             }
96 96
         }
97 97
         
98
-        return $relatableModules ;
98
+        return $relatableModules;
99 99
     
100 100
     }
101 101
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
      * that the admin may move them around or otherwise edit them before the module is deployed
106 106
      * @param AbstractRelationship $relationship    The relationship to add
107 107
      */
108
-    function add ($relationship)
108
+    function add($relationship)
109 109
     {
110
-        parent::add ( $relationship ) ;
111
-        $this->addFieldsToUndeployedLayouts ( $relationship ) ; // must come after parent::add as we need the relationship_name in the relationships getFieldsToLayouts() which is called by addFieldsToUndeployedLayouts() 
110
+        parent::add($relationship);
111
+        $this->addFieldsToUndeployedLayouts($relationship); // must come after parent::add as we need the relationship_name in the relationships getFieldsToLayouts() which is called by addFieldsToUndeployedLayouts() 
112 112
     }
113 113
 
114 114
     /*
@@ -116,29 +116,29 @@  discard block
 block discarded – undo
116 116
      * In future, if we need to actually track deleted relationships then just call $relationship->delete() instead
117 117
      * @param string $relationshipName  The unique name for this relationship, as returned by $relationship->getName()
118 118
      */
119
-    function delete ($relationshipName)
119
+    function delete($relationshipName)
120 120
     {
121
-        if ($relationship = $this->get ( $relationshipName ))
121
+        if ($relationship = $this->get($relationshipName))
122 122
         {
123
-            $this->removeFieldsFromUndeployedLayouts ( $relationship ) ;
124
-            unset ( $this->relationships [ $relationshipName ] ) ;
123
+            $this->removeFieldsFromUndeployedLayouts($relationship);
124
+            unset ($this->relationships [$relationshipName]);
125 125
         }
126 126
     }
127 127
 
128 128
     /*
129 129
      * Load the saved relationship definitions for this module
130 130
      */
131
-    function load ()
131
+    function load()
132 132
     {
133
-        $this->relationships = parent::_load ( $this->basepath ) ;
133
+        $this->relationships = parent::_load($this->basepath);
134 134
     }
135 135
 
136 136
     /*
137 137
      * Save this modules relationship definitions out to a working file
138 138
      */
139
-    function save ()
139
+    function save()
140 140
     {
141
-        parent::_save ( $this->relationships, $this->basepath ) ;
141
+        parent::_save($this->relationships, $this->basepath);
142 142
     }
143 143
 
144 144
     /*
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
      * @param array definition  The 5.0 relationship definition
147 147
      * @return array            The definition updated to 5.1 format
148 148
      */
149
-    protected function _updateRelationshipDefinition ($definition)
149
+    protected function _updateRelationshipDefinition($definition)
150 150
     {
151
-        if (isset ( $definition [ 'relate' ] ))
151
+        if (isset ($definition ['relate']))
152 152
         {
153
-            $newDefinition = array ( ) ;
154
-            foreach ( array ( 'relate' => 'rhs_module' , 'rsub' => 'rhs_subpanel' , 'msub' => 'lhs_subpanel' , 'label' => 'label' ) as $oldParameter => $newParameter )
153
+            $newDefinition = array( );
154
+            foreach (array('relate' => 'rhs_module', 'rsub' => 'rhs_subpanel', 'msub' => 'lhs_subpanel', 'label' => 'label') as $oldParameter => $newParameter)
155 155
             {
156
-                if (isset ( $definition [ $oldParameter ] ))
156
+                if (isset ($definition [$oldParameter]))
157 157
                 {
158
-                    $definition [ $newParameter ] = $definition [ $oldParameter ] ;
159
-                    unset ( $definition [ $oldParameter ] ) ;
158
+                    $definition [$newParameter] = $definition [$oldParameter];
159
+                    unset ($definition [$oldParameter]);
160 160
                 }
161 161
             }
162
-            $definition [ 'lhs_module' ] = "{$this->packageKey}_{$this->moduleName}" ;
162
+            $definition ['lhs_module'] = "{$this->packageKey}_{$this->moduleName}";
163 163
             // finally update the relationship name
164
-            unset ( $definition [ 'name' ] ) ; // clear the oldstyle name
164
+            unset ($definition ['name']); // clear the oldstyle name
165 165
         }
166
-        return $definition ;
166
+        return $definition;
167 167
     }
168 168
 
169 169
     /*
@@ -171,30 +171,30 @@  discard block
 block discarded – undo
171 171
      * The set of all relevant relationships for undeployed modules is the superset of that for deployed modules and all of the relationships known to ModuleBuilder
172 172
      * @return array Set of all relevant relationships
173 173
      */
174
-    protected function getAllRelationships ()
174
+    protected function getAllRelationships()
175 175
     {
176 176
         // start with the set of relationships known to this module plus those already deployed
177
-        $allRelationships = array_merge ( $this->relationships, parent::getDeployedRelationships () ) ;
177
+        $allRelationships = array_merge($this->relationships, parent::getDeployedRelationships());
178 178
         
179 179
         // add in the relationships known to ModuleBuilder
180
-        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
181
-        $mb = new ModuleBuilder ( ) ;
182
-        $mb->getPackages () ;
183
-        foreach ( $mb->getPackageList () as $packageName )
180
+        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
181
+        $mb = new ModuleBuilder( );
182
+        $mb->getPackages();
183
+        foreach ($mb->getPackageList() as $packageName)
184 184
         {
185
-            $package = $mb->packages [ $packageName ] ;
186
-            foreach ( $package->modules as $module )
185
+            $package = $mb->packages [$packageName];
186
+            foreach ($package->modules as $module)
187 187
             {
188 188
                 
189
-                foreach ( $module->relationships->getRelationshipList () as $relationshipName )
189
+                foreach ($module->relationships->getRelationshipList() as $relationshipName)
190 190
                 {
191
-                    $relationship = $module->relationships->get ( $relationshipName ) ;
192
-                    $allRelationships [ $relationship->getName () ] = $relationship->getDefinition () ;
191
+                    $relationship = $module->relationships->get($relationshipName);
192
+                    $allRelationships [$relationship->getName()] = $relationship->getDefinition();
193 193
                 }
194 194
             }
195 195
         }
196 196
         
197
-        return $allRelationships ;
197
+        return $allRelationships;
198 198
     
199 199
     }
200 200
 
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
      * This function is called from the view when constructing a new relationship
205 205
      * @param AbstractRelationship $relationship The relationship to be enforced
206 206
      */
207
-    public function enforceRelationshipOnly ($relationship)
207
+    public function enforceRelationshipOnly($relationship)
208 208
     {
209 209
         // if we already have a relationship between this lhs_module and this rhs_module then set RelationshipOnly flag
210
-        foreach ( $this->relationships as $rel )
210
+        foreach ($this->relationships as $rel)
211 211
         {
212 212
             if ($rel->lhs_module == $relationship->lhs_module && $rel->rhs_module == $relationship->rhs_module)
213 213
             {
214
-                $rel->setRelationship_only () ;
215
-                break ;
214
+                $rel->setRelationship_only();
215
+                break;
216 216
             }
217 217
         }
218 218
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * Translate the set of relationship objects into files that the Module Loader can work with
226 226
      * @param $basepath string Pathname of the directory to contain the build
227 227
      */
228
-    function build ($basepath, $installDefPrefix, $relationships)
228
+    function build($basepath, $installDefPrefix, $relationships)
229 229
     {
230 230
         
231 231
         // first expand out any reference to Activities to its submodules
@@ -233,62 +233,62 @@  discard block
 block discarded – undo
233 233
         // as the relationship name, that must be unique
234 234
         // the only special case is the subpanel for Activities, which is a composite, and is applied only once for all the submodules - this is handled in saveSubpanelDefinitions() for Undeployed modules
235 235
         
236
-        $relationships = array ( ) ;
237
-        $this->activitiesToAdd = false ;
238
-        foreach ( $this->relationships as $relationshipName => $relationship )
236
+        $relationships = array( );
237
+        $this->activitiesToAdd = false;
238
+        foreach ($this->relationships as $relationshipName => $relationship)
239 239
         {
240
-            $definition = $relationship->getDefinition () ;
240
+            $definition = $relationship->getDefinition();
241 241
             // activities will always appear on the rhs only - lhs will be always be this module in MB
242
-            if (strtolower ( $definition [ 'rhs_module' ] ) == 'activities')
242
+            if (strtolower($definition ['rhs_module']) == 'activities')
243 243
             {
244
-                $this->activitiesToAdd = true ;
245
-                $relationshipName = $definition [ 'relationship_name' ] ;
246
-                foreach ( self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName )
244
+                $this->activitiesToAdd = true;
245
+                $relationshipName = $definition ['relationship_name'];
246
+                foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName)
247 247
                 {
248
-                    $definition [ 'rhs_module' ] = $activitiesSubModuleName ;
249
-                    $definition [ 'for_activities' ] = true ;
250
-                    $definition [ 'relationship_name' ] = $relationshipName . '_' . $activitiesSubModuleLower ;
251
-                    $relationships [ $definition [ 'relationship_name' ] ] = RelationshipFactory::newRelationship ( $definition ) ;
248
+                    $definition ['rhs_module'] = $activitiesSubModuleName;
249
+                    $definition ['for_activities'] = true;
250
+                    $definition ['relationship_name'] = $relationshipName.'_'.$activitiesSubModuleLower;
251
+                    $relationships [$definition ['relationship_name']] = RelationshipFactory::newRelationship($definition);
252 252
                 }
253 253
             
254 254
             } else
255 255
             {
256
-                $relationships [ $definition [ 'relationship_name' ] ] = $relationship ;
256
+                $relationships [$definition ['relationship_name']] = $relationship;
257 257
             }
258 258
         }
259 259
         
260
-        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
261
-        $mb = new ModuleBuilder ( ) ;
262
-        $module = $mb->getPackageModule ( $this->packageName, $this->moduleName ) ;
260
+        require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
261
+        $mb = new ModuleBuilder( );
262
+        $module = $mb->getPackageModule($this->packageName, $this->moduleName);
263 263
         if ($this->activitiesToAdd)
264 264
         {
265
-            $appStrings = $module->getAppListStrings () ;
266
-            foreach(getTypeDisplayList() as $typeDisplay)
265
+            $appStrings = $module->getAppListStrings();
266
+            foreach (getTypeDisplayList() as $typeDisplay)
267 267
             {
268
-                $appStrings[$typeDisplay][$module->key_name] = $module->getlabel ( 'en_us', 'LBL_MODULE_TITLE' ) ;
268
+                $appStrings[$typeDisplay][$module->key_name] = $module->getlabel('en_us', 'LBL_MODULE_TITLE');
269 269
             }
270
-            $module->setAppListStrings ( 'en_us', $appStrings ) ;
271
-            $module->save () ;
270
+            $module->setAppListStrings('en_us', $appStrings);
271
+            $module->save();
272 272
 
273 273
         }
274 274
         else
275 275
         {
276 276
             //Bug42170================================
277
-            $appStrings = $module->getAppListStrings () ;
278
-            foreach(getTypeDisplayList() as $typeDisplay)
277
+            $appStrings = $module->getAppListStrings();
278
+            foreach (getTypeDisplayList() as $typeDisplay)
279 279
             {
280
-                if(isset($appStrings[$typeDisplay][$module->key_name]))
280
+                if (isset($appStrings[$typeDisplay][$module->key_name]))
281 281
                 {
282 282
                     unset($appStrings[$typeDisplay][$module->key_name]);
283 283
                 }
284 284
             }
285
-            $module->setAppListStrings ( 'en_us', $appStrings ) ;
286
-            $module->save () ;
285
+            $module->setAppListStrings('en_us', $appStrings);
286
+            $module->save();
287 287
 			//Bug42170================================
288 288
 		}
289 289
         
290 290
         // use an installDefPrefix of <basepath>/SugarModules for compatibility with the rest of ModuleBuilder
291
-        $this->installDefs = parent::build ( $basepath, "<basepath>/SugarModules", $relationships ) ;
291
+        $this->installDefs = parent::build($basepath, "<basepath>/SugarModules", $relationships);
292 292
     }
293 293
 
294 294
     /*
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
      * Required by MBModule
297 297
      * @param reference installDef  Reference to the set of installDefs to which this relationship's installDefs should be added
298 298
      */
299
-    function addInstallDefs (&$installDef)
299
+    function addInstallDefs(&$installDef)
300 300
     {
301
-        foreach ( $this->installDefs as $name => $def )
301
+        foreach ($this->installDefs as $name => $def)
302 302
         {
303
-            if (! empty ( $def ))
303
+            if (!empty ($def))
304 304
             {
305
-                foreach ( $def as $val )
305
+                foreach ($def as $val)
306 306
                 {
307
-                    $installDef [ $name ] [] = $val ;
307
+                    $installDef [$name] [] = $val;
308 308
                 }
309 309
             }
310 310
         }
311 311
     }
312 312
 
313
-    private function addFieldsToUndeployedLayouts ($relationship)
313
+    private function addFieldsToUndeployedLayouts($relationship)
314 314
     {
315
-        return $this->updateUndeployedLayout ( $relationship, true ) ;
315
+        return $this->updateUndeployedLayout($relationship, true);
316 316
     }
317 317
 
318
-    private function removeFieldsFromUndeployedLayouts ($relationship)
318
+    private function removeFieldsFromUndeployedLayouts($relationship)
319 319
     {
320
-        return $this->updateUndeployedLayout ( $relationship, false ) ;
320
+        return $this->updateUndeployedLayout($relationship, false);
321 321
     }
322 322
 
323 323
     /**
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
      */
327 327
     private function removeAppLangStrings($relationship) {
328 328
         $def = $relationship->getDefinition();
329
-        if (strtolower ( $def [ 'rhs_module' ] ) == 'activities' && !empty($_REQUEST [ 'view_package' ]) && !empty($_REQUEST [ 'view_module' ] ))
329
+        if (strtolower($def ['rhs_module']) == 'activities' && !empty($_REQUEST ['view_package']) && !empty($_REQUEST ['view_module']))
330 330
         {
331
-            $mb = new ModuleBuilder ( ) ;
332
-            $module = $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
333
-            $appStrings = $module->getAppListStrings () ;
334
-            foreach(getTypeDisplayList() as $key)
331
+            $mb = new ModuleBuilder( );
332
+            $module = $mb->getPackageModule($_REQUEST ['view_package'], $_REQUEST ['view_module']);
333
+            $appStrings = $module->getAppListStrings();
334
+            foreach (getTypeDisplayList() as $key)
335 335
             {
336
-                if (isset($appStrings[$key][ $module->key_name ]))
337
-                    unset($appStrings[$key][ $module->key_name ]);
336
+                if (isset($appStrings[$key][$module->key_name]))
337
+                    unset($appStrings[$key][$module->key_name]);
338 338
             }
339
-            $module->setAppListStrings ( 'en_us', $appStrings ) ;
340
-            $module->save () ;
339
+            $module->setAppListStrings('en_us', $appStrings);
340
+            $module->save();
341 341
         }
342 342
     }
343 343
 
@@ -347,41 +347,41 @@  discard block
 block discarded – undo
347 347
      * @param boolean $actionAdd True if we are to add; false if to remove
348 348
      * return null
349 349
      */
350
-    private function updateUndeployedLayout ($relationship , $actionAdd = true)
350
+    private function updateUndeployedLayout($relationship, $actionAdd = true)
351 351
     {
352 352
         
353 353
         // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
354
-        if ($relationship->getType () == MB_MANYTOMANY)
355
-            return false ;
354
+        if ($relationship->getType() == MB_MANYTOMANY)
355
+            return false;
356 356
         
357
-        $successful = true ;
358
-        $layoutAdditions = $relationship->buildFieldsToLayouts () ;
357
+        $successful = true;
358
+        $layoutAdditions = $relationship->buildFieldsToLayouts();
359 359
         
360
-        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
361
-        foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
360
+        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
361
+        foreach ($layoutAdditions as $deployedModuleName => $fieldName)
362 362
         {
363
-            foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
363
+            foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view)
364 364
             {
365
-                $parsedName = AbstractRelationships::parseDeployedModuleName ( $deployedModuleName ) ;
366
-                if (isset ( $parsedName [ 'packageName' ] ))
365
+                $parsedName = AbstractRelationships::parseDeployedModuleName($deployedModuleName);
366
+                if (isset ($parsedName ['packageName']))
367 367
                 {
368
-                    $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": " . (($actionAdd) ? "adding" : "removing") . " $fieldName on $view layout for undeployed module {$parsedName [ 'moduleName' ]} in package {$parsedName [ 'packageName' ]}" ) ;
369
-                    $parser = new GridLayoutMetaDataParser ( $view, $parsedName [ 'moduleName' ], $parsedName [ 'packageName' ] ) ;
368
+                    $GLOBALS ['log']->debug(get_class($this).": ".(($actionAdd) ? "adding" : "removing")." $fieldName on $view layout for undeployed module {$parsedName ['moduleName']} in package {$parsedName ['packageName']}");
369
+                    $parser = new GridLayoutMetaDataParser($view, $parsedName ['moduleName'], $parsedName ['packageName']);
370 370
                     
371
-                    if (($actionAdd) ? $parser->addField ( array ( 'name' => $fieldName ) ) : $parser->removeField ( $fieldName ))
371
+                    if (($actionAdd) ? $parser->addField(array('name' => $fieldName)) : $parser->removeField($fieldName))
372 372
                     {
373
-                        $parser->handleSave ( false ) ;
373
+                        $parser->handleSave(false);
374 374
                     } 
375 375
                     else
376 376
                     {
377
-                        $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": couldn't " . (($actionAdd) ? "add" : "remove") . " $fieldName on $view layout for undeployed module $deployedModuleName" ) ;
378
-                        $successful = false ;
377
+                        $GLOBALS ['log']->debug(get_class($this).": couldn't ".(($actionAdd) ? "add" : "remove")." $fieldName on $view layout for undeployed module $deployedModuleName");
378
+                        $successful = false;
379 379
                     }
380 380
                 }
381 381
             }
382 382
         }
383 383
         
384
-        return $successful ;
384
+        return $successful;
385 385
     }
386 386
 
387 387
     /*
@@ -392,29 +392,29 @@  discard block
 block discarded – undo
392 392
      * @param array $layoutAdditions  An array of module => fieldname
393 393
      * return null
394 394
      */
395
-    protected function saveFieldsToLayouts ($basepath , $dummy , $relationshipName , $layoutAdditions)
395
+    protected function saveFieldsToLayouts($basepath, $dummy, $relationshipName, $layoutAdditions)
396 396
     {
397
-        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
397
+        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
398 398
         
399 399
         // these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. In either case, we don't want to attempt to add a relate field to them
400 400
         // would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here
401
-        $invalidModules = array ( 'emails' , 'kbdocuments' ) ;
401
+        $invalidModules = array('emails', 'kbdocuments');
402 402
         
403 403
         $fieldsToAdd = array();
404
-        foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
404
+        foreach ($layoutAdditions as $deployedModuleName => $fieldName)
405 405
         {
406
-            if ( ! in_array( strtolower ( $deployedModuleName ) , $invalidModules ) ) {
407
-                foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
406
+            if (!in_array(strtolower($deployedModuleName), $invalidModules)) {
407
+                foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view)
408 408
                 {
409
-                    $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ;
410
-                    $parsedName = self::parseDeployedModuleName ( $deployedModuleName ) ;
411
-                    if (! isset ( $parsedName [ 'packageName' ] ))
409
+                    $GLOBALS ['log']->debug(get_class($this).": adding $fieldName to $view layout for module $deployedModuleName");
410
+                    $parsedName = self::parseDeployedModuleName($deployedModuleName);
411
+                    if (!isset ($parsedName ['packageName']))
412 412
                     {
413
-                        $fieldsToAdd [$parsedName [ 'moduleName' ]] = $fieldName;
413
+                        $fieldsToAdd [$parsedName ['moduleName']] = $fieldName;
414 414
                     } 
415 415
                     //Bug 22348: We should add in the field for custom modules not in this package, if they have been deployed.
416
-                    else if ($parsedName [ 'packageName' ] != $this->packageName 
417
-                            && isset ( $GLOBALS [ 'beanList' ] [ $deployedModuleName ])){
416
+                    else if ($parsedName ['packageName'] != $this->packageName 
417
+                            && isset ($GLOBALS ['beanList'] [$deployedModuleName])) {
418 418
                         $fieldsToAdd [$deployedModuleName] = $fieldName;
419 419
                     }
420 420
                 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 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.
@@ -270,8 +271,7 @@  discard block
 block discarded – undo
270 271
             $module->setAppListStrings ( 'en_us', $appStrings ) ;
271 272
             $module->save () ;
272 273
 
273
-        }
274
-        else
274
+        } else
275 275
         {
276 276
             //Bug42170================================
277 277
             $appStrings = $module->getAppListStrings () ;
@@ -333,8 +333,9 @@  discard block
 block discarded – undo
333 333
             $appStrings = $module->getAppListStrings () ;
334 334
             foreach(getTypeDisplayList() as $key)
335 335
             {
336
-                if (isset($appStrings[$key][ $module->key_name ]))
337
-                    unset($appStrings[$key][ $module->key_name ]);
336
+                if (isset($appStrings[$key][ $module->key_name ])) {
337
+                                    unset($appStrings[$key][ $module->key_name ]);
338
+                }
338 339
             }
339 340
             $module->setAppListStrings ( 'en_us', $appStrings ) ;
340 341
             $module->save () ;
@@ -351,8 +352,9 @@  discard block
 block discarded – undo
351 352
     {
352 353
         
353 354
         // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
354
-        if ($relationship->getType () == MB_MANYTOMANY)
355
-            return false ;
355
+        if ($relationship->getType () == MB_MANYTOMANY) {
356
+                    return false ;
357
+        }
356 358
         
357 359
         $successful = true ;
358 360
         $layoutAdditions = $relationship->buildFieldsToLayouts () ;
@@ -371,8 +373,7 @@  discard block
 block discarded – undo
371 373
                     if (($actionAdd) ? $parser->addField ( array ( 'name' => $fieldName ) ) : $parser->removeField ( $fieldName ))
372 374
                     {
373 375
                         $parser->handleSave ( false ) ;
374
-                    } 
375
-                    else
376
+                    } else
376 377
                     {
377 378
                         $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": couldn't " . (($actionAdd) ? "add" : "remove") . " $fieldName on $view layout for undeployed module $deployedModuleName" ) ;
378 379
                         $successful = false ;
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
                         
105 105
 
106 106
                         if (! empty ( $dictionary ) && ! empty ( $dictionary [ $name ] ) ) {
107
-                        	if (! empty ( $dictionary [ $name ] [ 'true_relationship_type' ] )) {
108
-                        		$definition [ 'relationship_type' ] = $dictionary [ $name ] [ 'true_relationship_type' ] ;
109
-                        	}
107
+                            if (! empty ( $dictionary [ $name ] [ 'true_relationship_type' ] )) {
108
+                                $definition [ 'relationship_type' ] = $dictionary [ $name ] [ 'true_relationship_type' ] ;
109
+                            }
110 110
                             if (! empty ( $dictionary [ $name ] [ 'from_studio' ] )) {
111 111
                                 $definition [ 'from_studio' ] = $dictionary [ $name ] [ 'from_studio' ] ;
112 112
                             }
113
-                        	$definition [ 'is_custom' ] = true;
113
+                            $definition [ 'is_custom' ] = true;
114 114
                         }
115 115
                             
116 116
                         
@@ -155,23 +155,23 @@  discard block
 block discarded – undo
155 155
      */
156 156
     function delete ($rel_name)
157 157
     {
158
-    	//Remove any fields from layouts
158
+        //Remove any fields from layouts
159 159
         $rel = $this->get($rel_name);
160 160
         if (!empty($rel))
161 161
         {
162 162
             $this->removeFieldsFromDeployedLayout($rel);
163 163
         }
164 164
         require_once("ModuleInstall/ModuleInstaller.php");
165
-    	require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
166
-    	$mi = new ModuleInstaller();
167
-    	$mi->silent = true;
165
+        require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
166
+        $mi = new ModuleInstaller();
167
+        $mi->silent = true;
168 168
         $mi->id_name = 'custom' . $rel_name; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
169
-    	$mi->uninstall_relationship("custom/metadata/{$rel_name}MetaData.php");
169
+        $mi->uninstall_relationship("custom/metadata/{$rel_name}MetaData.php");
170 170
         $mi->uninstallLabels('custom/Extension/modules/relationships/language/',$rel->buildLabels());
171 171
         $mi->uninstallExtLabels($rel->buildLabels());
172 172
     	
173
-    	// now clear all caches so that our changes are visible
174
-    	Relationship::delete_cache();
173
+        // now clear all caches so that our changes are visible
174
+        Relationship::delete_cache();
175 175
         $mi->rebuild_tabledictionary();
176 176
         
177 177
         $MBmodStrings = $GLOBALS [ 'mod_strings' ];
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         foreach ( $this->relationships as $name => $relationship )
314 314
         {
315 315
             $relationship->setFromStudio();
316
-        	$GLOBALS [ 'mod_strings' ] = $MBModStrings ;
316
+            $GLOBALS [ 'mod_strings' ] = $MBModStrings ;
317 317
             $installDefs = parent::build ( $basepath, "<basepath>",  array ($name => $relationship ) ) ;
318 318
 
319 319
             // and mark as built so that the next time we come through we'll know and won't build again
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      * @param $relationship    The relationship that is getting deleted
408 408
      * return null
409 409
      */
410
-	private function removeFieldsFromDeployedLayout ($relationship)
410
+    private function removeFieldsFromDeployedLayout ($relationship)
411 411
     {
412 412
         
413 413
         // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 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,23 +40,23 @@  discard block
 block discarded – undo
40 40
  ********************************************************************************/
41 41
 
42 42
 
43
-require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
44
-require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php' ;
45
-require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ;
43
+require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php';
44
+require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php';
45
+require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php';
46 46
 
47 47
 
48 48
 class DeployedRelationships extends AbstractRelationships implements RelationshipsInterface
49 49
 {
50 50
 
51
-    function __construct ($moduleName)
51
+    function __construct($moduleName)
52 52
     {
53
-        $this->moduleName = $moduleName ;
54
-        $this->load () ;
53
+        $this->moduleName = $moduleName;
54
+        $this->load();
55 55
     }
56 56
 
57
-    static function findRelatableModules ($includeActivitiesSubmodules = true)
57
+    static function findRelatableModules($includeActivitiesSubmodules = true)
58 58
     {
59
-        return parent::findRelatableModules ( true ) ;
59
+        return parent::findRelatableModules(true);
60 60
     }
61 61
 
62 62
     /*
@@ -71,50 +71,50 @@  discard block
 block discarded – undo
71 71
      * Instead we must obtain the true cardinality from a property we added to the relationship metadata when we created the relationship
72 72
      * This relationship metadata is accessed through the Table Dictionary
73 73
      */ 
74
-    function load ()
74
+    function load()
75 75
     {
76 76
         
77
-        $relationships = $this->getDeployedRelationships () ;
77
+        $relationships = $this->getDeployedRelationships();
78 78
         
79
-        if (! empty ( $relationships ))
79
+        if (!empty ($relationships))
80 80
         {
81 81
             // load the relationship definitions for all installed custom relationships into $dictionary
82
-            $dictionary = array ( ) ;
83
-            if (file_exists ( 'custom/application/Ext/TableDictionary/tabledictionary.ext.php' ))
82
+            $dictionary = array( );
83
+            if (file_exists('custom/application/Ext/TableDictionary/tabledictionary.ext.php'))
84 84
             {
85
-                include ('custom/application/Ext/TableDictionary/tabledictionary.ext.php') ;
85
+                include ('custom/application/Ext/TableDictionary/tabledictionary.ext.php');
86 86
             }
87 87
             
88 88
             $invalidModules = array();
89
-            $validModules = array_keys ( self::findRelatableModules () ) ;
89
+            $validModules = array_keys(self::findRelatableModules());
90 90
             
91 91
             // now convert the relationships array into an array of AbstractRelationship objects
92
-            foreach ( $relationships as $name => $definition )
92
+            foreach ($relationships as $name => $definition)
93 93
             {
94
-                if (($definition [ 'lhs_module' ] == $this->moduleName) || ($definition [ 'rhs_module' ] == $this->moduleName))
94
+                if (($definition ['lhs_module'] == $this->moduleName) || ($definition ['rhs_module'] == $this->moduleName))
95 95
                 {
96
-                    if (in_array ( $definition [ 'lhs_module' ], $validModules ) && in_array ( $definition [ 'rhs_module' ], $validModules )
97
-                        && ! in_array ( $definition [ 'lhs_module' ], $invalidModules ) && ! in_array ( $definition [ 'rhs_module' ], $invalidModules ))
96
+                    if (in_array($definition ['lhs_module'], $validModules) && in_array($definition ['rhs_module'], $validModules)
97
+                        && !in_array($definition ['lhs_module'], $invalidModules) && !in_array($definition ['rhs_module'], $invalidModules))
98 98
                     {
99 99
                         // identify the subpanels for this relationship - TODO: optimize this - currently does m x n scans through the subpanel list...
100
-                        $definition [ 'rhs_subpanel' ] = self::identifySubpanel ( $definition [ 'lhs_module' ], $definition [ 'rhs_module' ] ) ;
101
-                        $definition [ 'lhs_subpanel' ] = self::identifySubpanel ( $definition [ 'rhs_module' ], $definition [ 'lhs_module' ] ) ;
100
+                        $definition ['rhs_subpanel'] = self::identifySubpanel($definition ['lhs_module'], $definition ['rhs_module']);
101
+                        $definition ['lhs_subpanel'] = self::identifySubpanel($definition ['rhs_module'], $definition ['lhs_module']);
102 102
                         
103 103
                         // now adjust the cardinality with the true cardinality found in the relationships metadata (see method comment above)
104 104
                         
105 105
 
106
-                        if (! empty ( $dictionary ) && ! empty ( $dictionary [ $name ] ) ) {
107
-                        	if (! empty ( $dictionary [ $name ] [ 'true_relationship_type' ] )) {
108
-                        		$definition [ 'relationship_type' ] = $dictionary [ $name ] [ 'true_relationship_type' ] ;
106
+                        if (!empty ($dictionary) && !empty ($dictionary [$name])) {
107
+                        	if (!empty ($dictionary [$name] ['true_relationship_type'])) {
108
+                        		$definition ['relationship_type'] = $dictionary [$name] ['true_relationship_type'];
109 109
                         	}
110
-                            if (! empty ( $dictionary [ $name ] [ 'from_studio' ] )) {
111
-                                $definition [ 'from_studio' ] = $dictionary [ $name ] [ 'from_studio' ] ;
110
+                            if (!empty ($dictionary [$name] ['from_studio'])) {
111
+                                $definition ['from_studio'] = $dictionary [$name] ['from_studio'];
112 112
                             }
113
-                        	$definition [ 'is_custom' ] = true;
113
+                        	$definition ['is_custom'] = true;
114 114
                         }
115 115
                             
116 116
                         
117
-                        $this->relationships [ $name ] = RelationshipFactory::newRelationship ( $definition ) ;
117
+                        $this->relationships [$name] = RelationshipFactory::newRelationship($definition);
118 118
                     }
119 119
                 }
120 120
             }
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     /*
135 135
      * Save this modules relationship definitions out to a working file
136 136
      */
137
-    function save ()
137
+    function save()
138 138
     {
139
-        parent::_save ( $this->relationships, "custom/working/modules/{$this->moduleName}" ) ;
139
+        parent::_save($this->relationships, "custom/working/modules/{$this->moduleName}");
140 140
     }
141 141
 
142 142
     /*
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
      * @param array definition  The 5.0 relationship definition
146 146
      * @return array            The definition updated to 5.1 format
147 147
      */
148
-    protected function _updateRelationshipDefinition ($definition)
148
+    protected function _updateRelationshipDefinition($definition)
149 149
     {
150
-        return $definition ;
150
+        return $definition;
151 151
     }
152 152
 
153 153
     /*
154 154
      * Use the module Loader to delete the relationship from the instance.
155 155
      */
156
-    function delete ($rel_name)
156
+    function delete($rel_name)
157 157
     {
158 158
     	//Remove any fields from layouts
159 159
         $rel = $this->get($rel_name);
@@ -162,23 +162,23 @@  discard block
 block discarded – undo
162 162
             $this->removeFieldsFromDeployedLayout($rel);
163 163
         }
164 164
         require_once("ModuleInstall/ModuleInstaller.php");
165
-    	require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
165
+    	require_once ('modules/Administration/QuickRepairAndRebuild.php');
166 166
     	$mi = new ModuleInstaller();
167 167
     	$mi->silent = true;
168
-        $mi->id_name = 'custom' . $rel_name; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
168
+        $mi->id_name = 'custom'.$rel_name; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
169 169
     	$mi->uninstall_relationship("custom/metadata/{$rel_name}MetaData.php");
170
-        $mi->uninstallLabels('custom/Extension/modules/relationships/language/',$rel->buildLabels());
170
+        $mi->uninstallLabels('custom/Extension/modules/relationships/language/', $rel->buildLabels());
171 171
         $mi->uninstallExtLabels($rel->buildLabels());
172 172
     	
173 173
     	// now clear all caches so that our changes are visible
174 174
     	Relationship::delete_cache();
175 175
         $mi->rebuild_tabledictionary();
176 176
         
177
-        $MBmodStrings = $GLOBALS [ 'mod_strings' ];
178
-        $GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
179
-        $rac = new RepairAndClear ( ) ;
180
-        $rac->repairAndClearAll ( array ( 'clearAll', 'rebuildExtensions',  ), array ( $GLOBALS [ 'mod_strings' ] [ 'LBL_ALL_MODULES' ] ), true, false ) ;
181
-        $GLOBALS [ 'mod_strings' ] = $MBmodStrings;
177
+        $MBmodStrings = $GLOBALS ['mod_strings'];
178
+        $GLOBALS ['mod_strings'] = return_module_language('', 'Administration');
179
+        $rac = new RepairAndClear( );
180
+        $rac->repairAndClearAll(array('clearAll', 'rebuildExtensions',), array($GLOBALS ['mod_strings'] ['LBL_ALL_MODULES']), true, false);
181
+        $GLOBALS ['mod_strings'] = $MBmodStrings;
182 182
 
183 183
         //Bug 41070, supercedes the previous 40941 fix in this section
184 184
         if (isset($this->relationships[$rel_name]))
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
      * The set is made up of the relationships held in this class, plus all those already deployed in the application
193 193
      * @return array Set of all relevant relationships
194 194
      */
195
-    protected function getAllRelationships ()
195
+    protected function getAllRelationships()
196 196
     {
197
-        return array_merge ( $this->relationships, parent::getDeployedRelationships () ) ;
197
+        return array_merge($this->relationships, parent::getDeployedRelationships());
198 198
     }
199 199
 
200 200
     /*
@@ -204,28 +204,28 @@  discard block
 block discarded – undo
204 204
      * @param string $sourceModuleName  Name of the primary module
205 205
      * @return string Name of the subpanel if found; null otherwise
206 206
      */
207
-    static private function identifySubpanel ($thisModuleName , $sourceModuleName)
207
+    static private function identifySubpanel($thisModuleName, $sourceModuleName)
208 208
     {
209
-        $module = get_module_info ( $thisModuleName ) ;
210
-        require_once ('include/SubPanel/SubPanelDefinitions.php') ;
211
-        $spd = new SubPanelDefinitions ( $module ) ;
212
-        $subpanelNames = $spd->get_available_tabs () ; // actually these are the displayed subpanels
209
+        $module = get_module_info($thisModuleName);
210
+        require_once ('include/SubPanel/SubPanelDefinitions.php');
211
+        $spd = new SubPanelDefinitions($module);
212
+        $subpanelNames = $spd->get_available_tabs(); // actually these are the displayed subpanels
213 213
         
214
-        foreach ( $subpanelNames as $key => $name )
214
+        foreach ($subpanelNames as $key => $name)
215 215
         {
216
-            $GLOBALS [ 'log' ]->debug ( $thisModuleName . " " . $name ) ;
216
+            $GLOBALS ['log']->debug($thisModuleName." ".$name);
217 217
             
218
-            $subPanel = $spd->load_subpanel ( $name ) ;
219
-            if ($subPanel && ! isset ( $subPanel->_instance_properties [ 'collection_list' ] ))
218
+            $subPanel = $spd->load_subpanel($name);
219
+            if ($subPanel && !isset ($subPanel->_instance_properties ['collection_list']))
220 220
             {
221
-                if ($sourceModuleName == $subPanel->_instance_properties [ 'module' ])
221
+                if ($sourceModuleName == $subPanel->_instance_properties ['module'])
222 222
                 {
223
-                    return $subPanel->_instance_properties [ 'subpanel_name' ] ;
223
+                    return $subPanel->_instance_properties ['subpanel_name'];
224 224
                 }
225 225
             }
226 226
         }
227 227
         
228
-        return null ;
228
+        return null;
229 229
     
230 230
     }
231 231
 
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
      * @return string Name of the relate field, if found; null otherwise    
238 238
      */
239 239
     
240
-    static private function identifyRelateField ($thisModuleName , $sourceModuleName)
240
+    static private function identifyRelateField($thisModuleName, $sourceModuleName)
241 241
     {
242
-        $module = get_module_info ( $thisModuleName ) ;
242
+        $module = get_module_info($thisModuleName);
243 243
         
244
-        foreach ( $module->field_defs as $field )
244
+        foreach ($module->field_defs as $field)
245 245
         {
246
-            if ($field [ 'type' ] == 'relate' && isset ( $field [ 'module' ] ) && $field [ 'module' ] == $sourceModuleName)
247
-                return $field [ 'name' ] ;
246
+            if ($field ['type'] == 'relate' && isset ($field ['module']) && $field ['module'] == $sourceModuleName)
247
+                return $field ['name'];
248 248
         }
249
-        return null ;
249
+        return null;
250 250
     }
251 251
 
252 252
     /*
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
      * We can assume that both sides of the relationship are deployed modules as this is only called within the context of DeployedRelationships
257 257
      * @param AbstractRelationship $relationship The relationship to be enforced
258 258
      */
259
-    public function enforceRelationshipOnly ($relationship)
259
+    public function enforceRelationshipOnly($relationship)
260 260
     {
261
-        $lhs = $relationship->lhs_module ;
262
-        $rhs = $relationship->rhs_module ;
261
+        $lhs = $relationship->lhs_module;
262
+        $rhs = $relationship->rhs_module;
263 263
         // if the lhs_module already has a subpanel or relate field sourced from the rhs_module, 
264 264
     // or the rhs_module already has a subpanel or relate field sourced from the lhs_module,
265 265
     // then set "relationship_only" in the relationship
@@ -279,46 +279,46 @@  discard block
 block discarded – undo
279 279
      * We use the Extension mechanism to do this for DeployedRelationships
280 280
      * All metadata is placed in the modules Ext directory, and then Rebuild is called to activate them
281 281
      */
282
-    function build ($basepath, $installDefPrefix, $relationships)
282
+    function build($basepath, $installDefPrefix, $relationships)
283 283
     {
284
-        $basepath = "custom/Extension/modules" ;
284
+        $basepath = "custom/Extension/modules";
285 285
         
286
-        $this->activitiesToAdd = false ;
286
+        $this->activitiesToAdd = false;
287 287
         
288 288
         // and mark all as built so that the next time we come through we'll know and won't build again
289
-        foreach ( $this->relationships as $name => $relationship )
289
+        foreach ($this->relationships as $name => $relationship)
290 290
         {
291
-            $definition = $relationship->getDefinition () ;
291
+            $definition = $relationship->getDefinition();
292 292
             // activities will always appear on the rhs only - lhs will be always be this module in MB
293
-            if (strtolower ( $definition [ 'rhs_module' ] ) == 'activities')
293
+            if (strtolower($definition ['rhs_module']) == 'activities')
294 294
             {
295
-                $this->activitiesToAdd = true ;
296
-                $relationshipName = $definition [ 'relationship_name' ] ;
297
-                foreach ( self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName )
295
+                $this->activitiesToAdd = true;
296
+                $relationshipName = $definition ['relationship_name'];
297
+                foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName)
298 298
                 {
299
-                    $definition [ 'rhs_module' ] = $activitiesSubModuleName ;
300
-                    $definition [ 'for_activities' ] = true ;
301
-                    $definition [ 'relationship_name' ] = $relationshipName . '_' . $activitiesSubModuleLower ;
302
-                    $this->relationships [ $definition [ 'relationship_name' ] ] = RelationshipFactory::newRelationship ( $definition ) ;
299
+                    $definition ['rhs_module'] = $activitiesSubModuleName;
300
+                    $definition ['for_activities'] = true;
301
+                    $definition ['relationship_name'] = $relationshipName.'_'.$activitiesSubModuleLower;
302
+                    $this->relationships [$definition ['relationship_name']] = RelationshipFactory::newRelationship($definition);
303 303
                 }
304
-                unset ( $this->relationships [ $name ] ) ;
304
+                unset ($this->relationships [$name]);
305 305
             }
306 306
         }
307 307
         
308
-        $GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->build(): installing relationships" ) ;
308
+        $GLOBALS ['log']->info(get_class($this)."->build(): installing relationships");
309 309
 
310
-        $MBModStrings = $GLOBALS [ 'mod_strings' ] ;
311
-        $adminModStrings = return_module_language ( '', 'Administration' ) ; // required by ModuleInstaller
310
+        $MBModStrings = $GLOBALS ['mod_strings'];
311
+        $adminModStrings = return_module_language('', 'Administration'); // required by ModuleInstaller
312 312
             
313
-        foreach ( $this->relationships as $name => $relationship )
313
+        foreach ($this->relationships as $name => $relationship)
314 314
         {
315 315
             $relationship->setFromStudio();
316
-        	$GLOBALS [ 'mod_strings' ] = $MBModStrings ;
317
-            $installDefs = parent::build ( $basepath, "<basepath>",  array ($name => $relationship ) ) ;
316
+        	$GLOBALS ['mod_strings'] = $MBModStrings;
317
+            $installDefs = parent::build($basepath, "<basepath>", array($name => $relationship));
318 318
 
319 319
             // and mark as built so that the next time we come through we'll know and won't build again
320
-            $relationship->setReadonly () ;
321
-            $this->relationships [ $name ] = $relationship ;
320
+            $relationship->setReadonly();
321
+            $this->relationships [$name] = $relationship;
322 322
 
323 323
             // now install the relationship - ModuleInstaller normally only does this as part of a package load where it installs the relationships defined in the manifest. However, we don't have a manifest or a package, so...
324 324
             
@@ -332,43 +332,43 @@  discard block
 block discarded – undo
332 332
             // and rather than building a full manifest file to carry them, we manually add these installDefs to the ModuleInstaller, and then
333 333
             // individually call the appropriate ModuleInstaller->install_...() methods to take our relationship out of our staging area and expand it out to the individual module Ext areas       
334 334
 
335
-            $GLOBALS [ 'mod_strings' ] = $adminModStrings ;
336
-            require_once 'ModuleInstall/ModuleInstaller.php' ;
337
-            $mi = new ModuleInstaller ( ) ;
335
+            $GLOBALS ['mod_strings'] = $adminModStrings;
336
+            require_once 'ModuleInstall/ModuleInstaller.php';
337
+            $mi = new ModuleInstaller( );
338 338
 
339
-            $mi->id_name = 'custom' . $name ; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
340
-            $mi->installdefs = $installDefs ;
341
-            $mi->base_dir = $basepath ;
342
-            $mi->silent = true ;
339
+            $mi->id_name = 'custom'.$name; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
340
+            $mi->installdefs = $installDefs;
341
+            $mi->base_dir = $basepath;
342
+            $mi->silent = true;
343 343
 
344 344
             
345
-            VardefManager::clearVardef () ;
345
+            VardefManager::clearVardef();
346 346
 
347
-            $mi->install_relationships () ;
348
-            $mi->install_languages () ;
349
-            $mi->install_vardefs () ;
350
-            $mi->install_layoutdefs () ;
347
+            $mi->install_relationships();
348
+            $mi->install_languages();
349
+            $mi->install_vardefs();
350
+            $mi->install_layoutdefs();
351 351
             $mi->install_extensions();
352 352
 
353 353
         }
354 354
         
355 355
         // Run through the module installer to rebuild the relationships once after everything is done.
356
-        require_once 'ModuleInstall/ModuleInstaller.php' ;
357
-        $mi = new ModuleInstaller ( ) ;
356
+        require_once 'ModuleInstall/ModuleInstaller.php';
357
+        $mi = new ModuleInstaller( );
358 358
         $mi->silent = true;
359 359
         $mi->rebuild_relationships();
360 360
 
361 361
         // now clear all caches so that our changes are visible
362
-        require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
363
-        $rac = new RepairAndClear ( ) ;
364
-        $rac->repairAndClearAll ( array ( 'clearAll' ), array ( $GLOBALS [ 'mod_strings' ] [ 'LBL_ALL_MODULES' ] ), true, false ) ;
362
+        require_once ('modules/Administration/QuickRepairAndRebuild.php');
363
+        $rac = new RepairAndClear( );
364
+        $rac->repairAndClearAll(array('clearAll'), array($GLOBALS ['mod_strings'] ['LBL_ALL_MODULES']), true, false);
365 365
 
366
-        $GLOBALS [ 'mod_strings' ] = $MBModStrings ; // finally, restore the ModuleBuilder mod_strings
366
+        $GLOBALS ['mod_strings'] = $MBModStrings; // finally, restore the ModuleBuilder mod_strings
367 367
 
368 368
         // save out the updated definitions so that we keep track of the change in built status
369
-        $this->save () ;
369
+        $this->save();
370 370
         
371
-        $GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->build(): finished relationship installation" ) ;
371
+        $GLOBALS ['log']->info(get_class($this)."->build(): finished relationship installation");
372 372
 
373 373
     }
374 374
 
@@ -379,23 +379,23 @@  discard block
 block discarded – undo
379 379
      * @param array $layoutAdditions  An array of module => fieldname
380 380
      * return null
381 381
      */
382
-    protected function saveFieldsToLayouts ($basepath , $dummy , $relationshipName , $layoutAdditions)
382
+    protected function saveFieldsToLayouts($basepath, $dummy, $relationshipName, $layoutAdditions)
383 383
     {
384
-        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
384
+        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
385 385
         
386 386
         // these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. In either case, we don't want to attempt to add a relate field to them
387 387
         // would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here
388
-        $invalidModules = array ( 'emails' , 'kbdocuments' ) ;
388
+        $invalidModules = array('emails', 'kbdocuments');
389 389
         
390
-        foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
390
+        foreach ($layoutAdditions as $deployedModuleName => $fieldName)
391 391
         {
392
-            if (! in_array ( strtolower ( $deployedModuleName ), $invalidModules ))
393
-                foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
392
+            if (!in_array(strtolower($deployedModuleName), $invalidModules))
393
+                foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view)
394 394
                 {
395
-                    $GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ;
396
-                    $parser = new GridLayoutMetaDataParser ( $view, $deployedModuleName ) ;
397
-                    $parser->addField ( array ( 'name' => $fieldName ) ) ;
398
-                    $parser->handleSave ( false ) ;
395
+                    $GLOBALS ['log']->info(get_class($this).": adding $fieldName to $view layout for module $deployedModuleName");
396
+                    $parser = new GridLayoutMetaDataParser($view, $deployedModuleName);
397
+                    $parser->addField(array('name' => $fieldName));
398
+                    $parser->handleSave(false);
399 399
                 }
400 400
         }
401 401
     }
@@ -407,29 +407,29 @@  discard block
 block discarded – undo
407 407
      * @param $relationship    The relationship that is getting deleted
408 408
      * return null
409 409
      */
410
-	private function removeFieldsFromDeployedLayout ($relationship)
410
+	private function removeFieldsFromDeployedLayout($relationship)
411 411
     {
412 412
         
413 413
         // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
414
-        if ($relationship->getType () == MB_MANYTOMANY)
415
-            return false ;
414
+        if ($relationship->getType() == MB_MANYTOMANY)
415
+            return false;
416 416
         
417
-        $successful = true ;
418
-        $layoutAdditions = $relationship->buildFieldsToLayouts () ;
417
+        $successful = true;
418
+        $layoutAdditions = $relationship->buildFieldsToLayouts();
419 419
         
420
-        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
421
-        foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
420
+        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php';
421
+        foreach ($layoutAdditions as $deployedModuleName => $fieldName)
422 422
         {
423
-            foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
423
+            foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view)
424 424
             {
425
-                $parser = new GridLayoutMetaDataParser ( $view, $deployedModuleName ) ;
426
-                $parser->removeField ( $fieldName );
427
-                $parser->handleSave ( false ) ;
425
+                $parser = new GridLayoutMetaDataParser($view, $deployedModuleName);
426
+                $parser->removeField($fieldName);
427
+                $parser->handleSave(false);
428 428
              
429 429
             }
430 430
         }
431 431
         
432
-        return $successful ;
432
+        return $successful;
433 433
     }
434 434
 
435 435
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -7 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.
@@ -243,8 +244,9 @@  discard block
 block discarded – undo
243 244
         
244 245
         foreach ( $module->field_defs as $field )
245 246
         {
246
-            if ($field [ 'type' ] == 'relate' && isset ( $field [ 'module' ] ) && $field [ 'module' ] == $sourceModuleName)
247
-                return $field [ 'name' ] ;
247
+            if ($field [ 'type' ] == 'relate' && isset ( $field [ 'module' ] ) && $field [ 'module' ] == $sourceModuleName) {
248
+                            return $field [ 'name' ] ;
249
+            }
248 250
         }
249 251
         return null ;
250 252
     }
@@ -389,10 +391,11 @@  discard block
 block discarded – undo
389 391
         
390 392
         foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
391 393
         {
392
-            if (! in_array ( strtolower ( $deployedModuleName ), $invalidModules ))
393
-                foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
394
+            if (! in_array ( strtolower ( $deployedModuleName ), $invalidModules )) {
395
+                            foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
394 396
                 {
395 397
                     $GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ;
398
+            }
396 399
                     $parser = new GridLayoutMetaDataParser ( $view, $deployedModuleName ) ;
397 400
                     $parser->addField ( array ( 'name' => $fieldName ) ) ;
398 401
                     $parser->handleSave ( false ) ;
@@ -411,8 +414,9 @@  discard block
 block discarded – undo
411 414
     {
412 415
         
413 416
         // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
414
-        if ($relationship->getType () == MB_MANYTOMANY)
415
-            return false ;
417
+        if ($relationship->getType () == MB_MANYTOMANY) {
418
+                    return false ;
419
+        }
416 420
         
417 421
         $successful = true ;
418 422
         $layoutAdditions = $relationship->buildFieldsToLayouts () ;
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php 2 patches
Spacing   +6 added lines, -6 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.
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
 interface RelationshipsInterface
43 43
 {
44 44
 
45
-    static public function findRelatableModules () ;
45
+    static public function findRelatableModules();
46 46
     
47
-    public function load () ;
47
+    public function load();
48 48
 
49 49
 //  public function build () ;
50 50
     
51
-    public function getRelationshipList ();
51
+    public function getRelationshipList();
52 52
     
53
-    public function get ($relationshipName) ;
53
+    public function get($relationshipName);
54 54
 
55
-    public function add ($relationship) ;
55
+    public function add($relationship);
56 56
 
57 57
 //    public function delete ($relationshipName) ;
58 58
     
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 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.
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,9 +54,9 @@
 block discarded – undo
54 54
         if (! isset ( $definition [ 'relationship_type' ] ))
55 55
             $definition [ 'relationship_type' ] = MB_MANYTOMANY ;
56 56
             
57
-    	if (!empty ($definition['for_activities']) && $definition['for_activities'] == true) {
58
-        	require_once 'modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php';
59
-        	return new ActivitiesRelationship ($definition);
57
+        if (!empty ($definition['for_activities']) && $definition['for_activities'] == true) {
58
+            require_once 'modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php';
59
+            return new ActivitiesRelationship ($definition);
60 60
         }
61 61
         
62 62
         switch ( strtolower ( $definition [ 'relationship_type' ] ))
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.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-require_once 'modules/ModuleBuilder/parsers/constants.php' ;
42
+require_once 'modules/ModuleBuilder/parsers/constants.php';
43 43
 
44 44
 class RelationshipFactory
45 45
 {
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
      * Construct a new relationship of type as provided by the $definition
49 49
      * @param array $definition Complete definition of the relationship, as specified by AbstractRelationship::keys
50 50
      */
51
-    static function newRelationship ($definition = array())
51
+    static function newRelationship($definition = array())
52 52
     {
53 53
         // handle the case where a relationship_type is not provided - set it to Many-To-Many as this was the usual type in ModuleBuilder
54
-        if (! isset ( $definition [ 'relationship_type' ] ))
55
-            $definition [ 'relationship_type' ] = MB_MANYTOMANY ;
54
+        if (!isset ($definition ['relationship_type']))
55
+            $definition ['relationship_type'] = MB_MANYTOMANY;
56 56
             
57 57
     	if (!empty ($definition['for_activities']) && $definition['for_activities'] == true) {
58 58
         	require_once 'modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php';
59
-        	return new ActivitiesRelationship ($definition);
59
+        	return new ActivitiesRelationship($definition);
60 60
         }
61 61
         
62
-        switch ( strtolower ( $definition [ 'relationship_type' ] ))
62
+        switch (strtolower($definition ['relationship_type']))
63 63
         {
64
-            case strtolower ( MB_ONETOONE ) :
65
-                require_once 'modules/ModuleBuilder/parsers/relationships/OneToOneRelationship.php' ;
66
-                return new OneToOneRelationship ( $definition ) ;
64
+            case strtolower(MB_ONETOONE) :
65
+                require_once 'modules/ModuleBuilder/parsers/relationships/OneToOneRelationship.php';
66
+                return new OneToOneRelationship($definition);
67 67
             
68
-            case strtolower ( MB_ONETOMANY ) :
69
-                require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
70
-                return new OneToManyRelationship ( $definition ) ;
68
+            case strtolower(MB_ONETOMANY) :
69
+                require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php';
70
+                return new OneToManyRelationship($definition);
71 71
                 
72
-            case strtolower ( MB_MANYTOONE ) :
73
-                require_once 'modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php' ;
74
-                return new ManyToOneRelationship ( $definition ) ;
72
+            case strtolower(MB_MANYTOONE) :
73
+                require_once 'modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php';
74
+                return new ManyToOneRelationship($definition);
75 75
             
76 76
             // default case is Many-To-Many as this was the only type ModuleBuilder could create and so much of the MB code assumes Many-To-Many
77 77
             default :
78
-                $definition [ 'relationship_type' ] = MB_MANYTOMANY ;
79
-                require_once 'modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php' ;
80
-                return new ManyToManyRelationship ( $definition ) ;
78
+                $definition ['relationship_type'] = MB_MANYTOMANY;
79
+                require_once 'modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php';
80
+                return new ManyToManyRelationship($definition);
81 81
         }
82 82
     
83 83
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 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.
@@ -51,8 +53,9 @@  discard block
 block discarded – undo
51 53
     static function newRelationship ($definition = array())
52 54
     {
53 55
         // handle the case where a relationship_type is not provided - set it to Many-To-Many as this was the usual type in ModuleBuilder
54
-        if (! isset ( $definition [ 'relationship_type' ] ))
55
-            $definition [ 'relationship_type' ] = MB_MANYTOMANY ;
56
+        if (! isset ( $definition [ 'relationship_type' ] )) {
57
+                    $definition [ 'relationship_type' ] = MB_MANYTOMANY ;
58
+        }
56 59
             
57 60
     	if (!empty ($definition['for_activities']) && $definition['for_activities'] == true) {
58 61
         	require_once 'modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php';
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
         $source = "";
100 100
         if ($this->rhs_module == $this->lhs_module)
101 101
         {
102
-        	$source = $this->getJoinKeyLHS();
102
+            $source = $this->getJoinKeyLHS();
103 103
         }
104 104
  
105 105
         return array( 
106
-        	$this->lhs_module => $this->getSubpanelDefinition ( 
107
-        		$this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source
108
-        	) 
106
+            $this->lhs_module => $this->getSubpanelDefinition ( 
107
+                $this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source
108
+            ) 
109 109
         );
110 110
     }
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     /*
114 114
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
115 115
      */
116
-	function buildVardefs ( )
116
+    function buildVardefs ( )
117 117
     {
118 118
         $vardefs = array ( ) ;
119 119
         
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         ) ;
124 124
         if ($this->rhs_module != $this->lhs_module )
125 125
         {
126
-        	$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true,
126
+            $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true,
127 127
                 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()  ) . '_TITLE');
128 128
         }
129 129
         if (! $this->relationship_only)
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 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.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
42
+require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php';
43 43
 
44 44
 /*
45 45
  * Class to manage the metadata for a One-To-Many Relationship
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @param array $definition Parameters passed in as array defined in parent::$definitionKeys
78 78
      * The lhs_module value is for the One side; the rhs_module value is for the Many
79 79
      */
80
-    function __construct ($definition)
80
+    function __construct($definition)
81 81
     {
82
-        parent::__construct ( $definition ) ;
82
+        parent::__construct($definition);
83 83
     }
84 84
 
85 85
     /*
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
      * The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
92 92
      * @return array    An array of subpanel definitions, keyed by the module
93 93
      */
94
-    function buildSubpanelDefinitions ()
94
+    function buildSubpanelDefinitions()
95 95
     {        
96 96
         if ($this->relationship_only)
97
-            return array () ;
97
+            return array();
98 98
         
99 99
         $source = "";
100 100
         if ($this->rhs_module == $this->lhs_module)
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
         }
104 104
  
105 105
         return array( 
106
-        	$this->lhs_module => $this->getSubpanelDefinition ( 
107
-        		$this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source
106
+        	$this->lhs_module => $this->getSubpanelDefinition( 
107
+        		$this->relationship_name, $this->rhs_module, $this->rhs_subpanel, $this->getRightModuleSystemLabel(), $source
108 108
         	) 
109 109
         );
110 110
     }
@@ -113,47 +113,47 @@  discard block
 block discarded – undo
113 113
     /*
114 114
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
115 115
      */
116
-	function buildVardefs ( )
116
+	function buildVardefs( )
117 117
     {
118
-        $vardefs = array ( ) ;
118
+        $vardefs = array( );
119 119
         
120
-        $vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name, false,
121
-            'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE',
122
-            $this->relationship_only ? false : $this->getIDName( $this->lhs_module )
123
-        ) ;
124
-        if ($this->rhs_module != $this->lhs_module )
120
+        $vardefs [$this->rhs_module] [] = $this->getLinkFieldDefinition($this->lhs_module, $this->relationship_name, false,
121
+            'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE',
122
+            $this->relationship_only ? false : $this->getIDName($this->lhs_module)
123
+        );
124
+        if ($this->rhs_module != $this->lhs_module)
125 125
         {
126
-        	$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true,
127
-                'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()  ) . '_TITLE');
126
+        	$vardefs [$this->lhs_module] [] = $this->getLinkFieldDefinition($this->rhs_module, $this->relationship_name, true,
127
+                'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE');
128 128
         }
129
-        if (! $this->relationship_only)
129
+        if (!$this->relationship_only)
130 130
         {
131
-            $vardefs [ $this->rhs_module ] [] = $this->getRelateFieldDefinition ( $this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel() ) ;
132
-            $vardefs [ $this->rhs_module ] [] = $this->getLink2FieldDefinition ( $this->lhs_module, $this->relationship_name, true,
133
-                'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()  ) . '_TITLE');
131
+            $vardefs [$this->rhs_module] [] = $this->getRelateFieldDefinition($this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel());
132
+            $vardefs [$this->rhs_module] [] = $this->getLink2FieldDefinition($this->lhs_module, $this->relationship_name, true,
133
+                'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE');
134 134
         }
135 135
         
136
-        return $vardefs ;
136
+        return $vardefs;
137 137
     }
138 138
     
139 139
     /*
140 140
      * Define what fields to add to which modules layouts
141 141
      * @return array    An array of module => fieldname
142 142
      */
143
-    function buildFieldsToLayouts ()
143
+    function buildFieldsToLayouts()
144 144
     {
145 145
         if ($this->relationship_only)
146
-            return array () ;
146
+            return array();
147 147
  
148
-        return array( $this->rhs_module =>$this->getValidDBName($this->relationship_name . "_name")); // this must match the name of the relate field from buildVardefs
148
+        return array($this->rhs_module =>$this->getValidDBName($this->relationship_name."_name")); // this must match the name of the relate field from buildVardefs
149 149
     }
150 150
        
151 151
     /*
152 152
      * @return array    An array of relationship metadata definitions
153 153
      */
154
-    function buildRelationshipMetaData ()
154
+    function buildRelationshipMetaData()
155 155
     {
156
-        return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_ONETOMANY ) ) ;
156
+        return array($this->lhs_module => $this->getRelationshipMetaData(MB_ONETOMANY));
157 157
     }
158 158
 
159 159
 }
Please login to merge, or discard this patch.
Braces   +9 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.
@@ -93,8 +95,9 @@  discard block
 block discarded – undo
93 95
      */
94 96
     function buildSubpanelDefinitions ()
95 97
     {        
96
-        if ($this->relationship_only)
97
-            return array () ;
98
+        if ($this->relationship_only) {
99
+                    return array () ;
100
+        }
98 101
         
99 102
         $source = "";
100 103
         if ($this->rhs_module == $this->lhs_module)
@@ -142,8 +145,9 @@  discard block
 block discarded – undo
142 145
      */
143 146
     function buildFieldsToLayouts ()
144 147
     {
145
-        if ($this->relationship_only)
146
-            return array () ;
148
+        if ($this->relationship_only) {
149
+                    return array () ;
150
+        }
147 151
  
148 152
         return array( $this->rhs_module =>$this->getValidDBName($this->relationship_name . "_name")); // this must match the name of the relate field from buildVardefs
149 153
     }
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -60,21 +60,21 @@  discard block
 block discarded – undo
60 60
     function __construct ($definition) 
61 61
     {
62 62
         
63
-    	parent::__construct ( $definition ) ;
64
-    	$onetomanyDef = array_merge($definition, array(
65
-	        'rhs_label'    => isset($definition['lhs_label'])    ? $definition['lhs_label']    : null,
66
-	        'lhs_label'    => isset($definition['rhs_label'])    ? $definition['rhs_label']    : null,
67
-	        'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null,
68
-	        'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null,
69
-	        'lhs_module'   => isset($definition['rhs_module'])   ? $definition['rhs_module']   : null,
70
-	        'lhs_table'    => isset($definition['rhs_table'])    ? $definition['rhs_table']    : null,
71
-	        'lhs_key'      => isset($definition['rhs_key'])      ? $definition['rhs_key']      : null,
72
-	        'rhs_module'   => isset($definition['lhs_module'])   ? $definition['lhs_module']   : null,
73
-	        'rhs_table'    => isset($definition['lhs_table'])    ? $definition['lhs_table']    : null,
74
-	        'rhs_key'      => isset($definition['lhs_key'])      ? $definition['lhs_key']      : null,
75
-	        'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null,
76
-	        'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null,
77
-	        'relationship_type' => MB_ONETOMANY,
63
+        parent::__construct ( $definition ) ;
64
+        $onetomanyDef = array_merge($definition, array(
65
+            'rhs_label'    => isset($definition['lhs_label'])    ? $definition['lhs_label']    : null,
66
+            'lhs_label'    => isset($definition['rhs_label'])    ? $definition['rhs_label']    : null,
67
+            'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null,
68
+            'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null,
69
+            'lhs_module'   => isset($definition['rhs_module'])   ? $definition['rhs_module']   : null,
70
+            'lhs_table'    => isset($definition['rhs_table'])    ? $definition['rhs_table']    : null,
71
+            'lhs_key'      => isset($definition['rhs_key'])      ? $definition['rhs_key']      : null,
72
+            'rhs_module'   => isset($definition['lhs_module'])   ? $definition['lhs_module']   : null,
73
+            'rhs_table'    => isset($definition['lhs_table'])    ? $definition['lhs_table']    : null,
74
+            'rhs_key'      => isset($definition['lhs_key'])      ? $definition['lhs_key']      : null,
75
+            'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null,
76
+            'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null,
77
+            'relationship_type' => MB_ONETOMANY,
78 78
         ));
79 79
         $this->one_to_many = new OneToManyRelationship($onetomanyDef);
80 80
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * BUILD methods called during the build
84 84
      */
85 85
 	
86
-	function buildLabels ()
86
+    function buildLabels ()
87 87
     {
88 88
         return $this->one_to_many->buildLabels();
89 89
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function buildVardefs ( )
106 106
     {
107
-       return $this->one_to_many->buildVardefs();
107
+        return $this->one_to_many->buildVardefs();
108 108
     }
109 109
     
110 110
     /*
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
     public function setName ($relationshipName)
131 131
     {
132 132
         parent::setName($relationshipName);
133
-    	$this->one_to_many->setname($relationshipName);
133
+        $this->one_to_many->setname($relationshipName);
134 134
     }
135 135
     
136 136
     public function setReadonly ()
137 137
     {
138 138
         parent::setReadonly();
139
-    	$this->one_to_many->setReadonly();
139
+        $this->one_to_many->setReadonly();
140 140
     }
141 141
     
142 142
     public function delete ()
143 143
     {
144 144
         parent::delete();
145
-    	$this->one_to_many->delete();
145
+        $this->one_to_many->delete();
146 146
     }
147 147
     
148 148
     public function setRelationship_only ()
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 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.
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
43
-require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
44
-require_once 'modules/ModuleBuilder/parsers/constants.php' ;
42
+require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php';
43
+require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php';
44
+require_once 'modules/ModuleBuilder/parsers/constants.php';
45 45
 
46 46
 /*
47 47
  * Class to manage the metadata for a many-To-one Relationship
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
      * @param array $definition Parameters passed in as array defined in parent::$definitionKeys
58 58
      * The lhs_module value is for the One side; the rhs_module value is for the Many
59 59
      */
60
-    function __construct ($definition) 
60
+    function __construct($definition) 
61 61
     {
62 62
         
63
-    	parent::__construct ( $definition ) ;
63
+    	parent::__construct($definition);
64 64
     	$onetomanyDef = array_merge($definition, array(
65
-	        'rhs_label'    => isset($definition['lhs_label'])    ? $definition['lhs_label']    : null,
66
-	        'lhs_label'    => isset($definition['rhs_label'])    ? $definition['rhs_label']    : null,
65
+	        'rhs_label'    => isset($definition['lhs_label']) ? $definition['lhs_label'] : null,
66
+	        'lhs_label'    => isset($definition['rhs_label']) ? $definition['rhs_label'] : null,
67 67
 	        'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null,
68 68
 	        'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null,
69
-	        'lhs_module'   => isset($definition['rhs_module'])   ? $definition['rhs_module']   : null,
70
-	        'lhs_table'    => isset($definition['rhs_table'])    ? $definition['rhs_table']    : null,
71
-	        'lhs_key'      => isset($definition['rhs_key'])      ? $definition['rhs_key']      : null,
72
-	        'rhs_module'   => isset($definition['lhs_module'])   ? $definition['lhs_module']   : null,
73
-	        'rhs_table'    => isset($definition['lhs_table'])    ? $definition['lhs_table']    : null,
74
-	        'rhs_key'      => isset($definition['lhs_key'])      ? $definition['lhs_key']      : null,
69
+	        'lhs_module'   => isset($definition['rhs_module']) ? $definition['rhs_module'] : null,
70
+	        'lhs_table'    => isset($definition['rhs_table']) ? $definition['rhs_table'] : null,
71
+	        'lhs_key'      => isset($definition['rhs_key']) ? $definition['rhs_key'] : null,
72
+	        'rhs_module'   => isset($definition['lhs_module']) ? $definition['lhs_module'] : null,
73
+	        'rhs_table'    => isset($definition['lhs_table']) ? $definition['lhs_table'] : null,
74
+	        'rhs_key'      => isset($definition['lhs_key']) ? $definition['lhs_key'] : null,
75 75
 	        'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null,
76 76
 	        'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null,
77 77
 	        'relationship_type' => MB_ONETOMANY,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * BUILD methods called during the build
84 84
      */
85 85
 	
86
-	function buildLabels ()
86
+	function buildLabels()
87 87
     {
88 88
         return $this->one_to_many->buildLabels();
89 89
     }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
94 94
      * @return array    An array of subpanel definitions, keyed by the module
95 95
      */
96
-    function buildSubpanelDefinitions ()
96
+    function buildSubpanelDefinitions()
97 97
     {        
98 98
         return $this->one_to_many->buildSubpanelDefinitions();
99 99
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     /*
103 103
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
104 104
      */
105
-    function buildVardefs ( )
105
+    function buildVardefs( )
106 106
     {
107 107
        return $this->one_to_many->buildVardefs();
108 108
     }
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
      * Define what fields to add to which modules layouts
112 112
      * @return array    An array of module => fieldname
113 113
      */
114
-    function buildFieldsToLayouts ()
114
+    function buildFieldsToLayouts()
115 115
     {
116 116
         if ($this->relationship_only)
117
-            return array () ;
117
+            return array();
118 118
  
119
-        return array( $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") ) ; // this must match the name of the relate field from buildVardefs
119
+        return array($this->lhs_module => $this->getValidDBName($this->relationship_name."_name")); // this must match the name of the relate field from buildVardefs
120 120
     }
121 121
        
122 122
     /*
123 123
      * @return array    An array of relationship metadata definitions
124 124
      */
125
-    function buildRelationshipMetaData ()
125
+    function buildRelationshipMetaData()
126 126
     {
127 127
         return $this->one_to_many->buildRelationshipMetaData();
128 128
     }
129 129
     
130
-    public function setName ($relationshipName)
130
+    public function setName($relationshipName)
131 131
     {
132 132
         parent::setName($relationshipName);
133 133
     	$this->one_to_many->setname($relationshipName);
134 134
     }
135 135
     
136
-    public function setReadonly ()
136
+    public function setReadonly()
137 137
     {
138 138
         parent::setReadonly();
139 139
     	$this->one_to_many->setReadonly();
140 140
     }
141 141
     
142
-    public function delete ()
142
+    public function delete()
143 143
     {
144 144
         parent::delete();
145 145
     	$this->one_to_many->delete();
146 146
     }
147 147
     
148
-    public function setRelationship_only ()
148
+    public function setRelationship_only()
149 149
     {
150 150
         parent::setRelationship_only();
151 151
         $this->one_to_many->setRelationship_only();
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -113,8 +115,9 @@  discard block
 block discarded – undo
113 115
      */
114 116
     function buildFieldsToLayouts ()
115 117
     {
116
-        if ($this->relationship_only)
117
-            return array () ;
118
+        if ($this->relationship_only) {
119
+                    return array () ;
120
+        }
118 121
  
119 122
         return array( $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") ) ; // this must match the name of the relate field from buildVardefs
120 123
     }
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 class ActivitiesRelationship extends OneToManyRelationship
73 73
 {
74 74
 
75
-	protected static $subpanelsAdded = array();
76
-	protected static $labelsAdded = array();
75
+    protected static $subpanelsAdded = array();
76
+    protected static $labelsAdded = array();
77 77
 
78
-	/*
78
+    /*
79 79
      * Constructor
80 80
      * @param array $definition Parameters passed in as array defined in parent::$definitionKeys
81 81
      * The lhs_module value is for the One side; the rhs_module value is for the Many
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * BUILD methods called during the build
90 90
      */
91 91
 
92
-	/*
92
+    /*
93 93
      * Define the labels to be added to the module for the new relationships
94 94
      * @return array    An array of system value => display value
95 95
      */
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
 
143
-	/*
143
+    /*
144 144
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
145 145
      */
146 146
     function buildVardefs ( )
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         return $vardefs ;
155 155
     }
156 156
 
157
-	protected function getLinkFieldDefinition ($sourceModule , $relationshipName)
157
+    protected function getLinkFieldDefinition ($sourceModule , $relationshipName)
158 158
     {
159 159
         $vardef = array ( ) ;
160 160
         $vardef [ 'name' ] = $relationshipName;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
180 180
     }
181 181
 
182
- 	function buildSubpanelDefinitions ()
182
+        function buildSubpanelDefinitions ()
183 183
     {
184 184
         if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module]))
185 185
             return array () ;
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
         ActivitiesRelationship::$subpanelsAdded[$this->lhs_module] = true;
188 188
         $relationshipName = substr($this->relationship_name, 0, strrpos($this->relationship_name, '_'));
189 189
         return array( $this->lhs_module => array (
190
-        			  'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ),
191
-        			  'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) ,
192
-        			));
190
+                        'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ),
191
+                        'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) ,
192
+                    ));
193 193
     }
194 194
 
195 195
     /*
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
         $relMetadata ['relationship_role_column'] = 'parent_type';
210 210
         $relMetadata ['relationship_role_column_value'] = $this->definition [ 'lhs_module' ] ;
211 211
 
212
-    	return array( $this->lhs_module => array(
213
-    		'relationships' => array ($relationshipName => $relMetadata),
214
-    		'fields' => '', 'indices' => '', 'table' => '')
215
-    	) ;
212
+        return array( $this->lhs_module => array(
213
+            'relationships' => array ($relationshipName => $relMetadata),
214
+            'fields' => '', 'indices' => '', 'table' => '')
215
+        ) ;
216 216
     }
217 217
 
218 218
 /*
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     protected function buildActivitiesSubpanelDefinition ( $relationshipName )
223 223
     {
224
-		return array (
224
+        return array (
225 225
             'order' => 10 ,
226 226
             'sort_order' => 'desc' ,
227 227
             'sort_by' => 'date_start' ,
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             'module' => 'History' ,
266 266
             'top_buttons' => array (
267 267
                 array ( 'widget_class' => 'SubPanelTopCreateNoteButton' ) ,
268
-				array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'),
268
+                array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'),
269 269
                 array ( 'widget_class' => 'SubPanelTopSummaryButton' ) ) ,
270 270
                 'collection_list' => array (
271 271
                     'meetings' => array (
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 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.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
42
+require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php';
43 43
 
44 44
 /*
45 45
  * Class to manage the metadata for a One-To-Many Relationship
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
      * @param array $definition Parameters passed in as array defined in parent::$definitionKeys
81 81
      * The lhs_module value is for the One side; the rhs_module value is for the Many
82 82
      */
83
-    function __construct ($definition)
83
+    function __construct($definition)
84 84
     {
85
-        parent::__construct ( $definition ) ;
85
+        parent::__construct($definition);
86 86
     }
87 87
 
88 88
     /*
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
      * Define the labels to be added to the module for the new relationships
94 94
      * @return array    An array of system value => display value
95 95
      */
96
-    function buildLabels ()
96
+    function buildLabels()
97 97
     {
98
-        $labelDefinitions = array ( ) ;
99
-        if (!$this->relationship_only )
98
+        $labelDefinitions = array( );
99
+        if (!$this->relationship_only)
100 100
         {
101 101
             if (!isset(ActivitiesRelationship::$labelsAdded[$this->lhs_module])) {
102
-                foreach(getTypeDisplayList() as $typeDisplay)
102
+                foreach (getTypeDisplayList() as $typeDisplay)
103 103
                 {
104
-                    $labelDefinitions [] = array (
104
+                    $labelDefinitions [] = array(
105 105
                         'module' => 'application',
106 106
                         'system_label' => $typeDisplay,
107 107
                         'display_label' => array(
@@ -113,180 +113,180 @@  discard block
 block discarded – undo
113 113
 
114 114
             $rhs_display_label = '';
115 115
             if (!empty($this->rhs_label)) {
116
-                $rhs_display_label .= $this->rhs_label . ':';
116
+                $rhs_display_label .= $this->rhs_label.':';
117 117
             }
118 118
             $rhs_display_label .= translate($this->rhs_module);
119 119
 
120 120
             $lhs_display_label = '';
121 121
             if (!empty($this->rhs_label)) {
122
-                $lhs_display_label .= $this->rhs_label . ':';
122
+                $lhs_display_label .= $this->rhs_label.':';
123 123
             }
124 124
             $lhs_display_label .= translate($this->lhs_module);
125 125
 
126
-            $labelDefinitions[] = array (
127
-                'module' => $this->lhs_module ,
128
-                'system_label' => 'LBL_' . strtoupper($this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()) . '_TITLE',
126
+            $labelDefinitions[] = array(
127
+                'module' => $this->lhs_module,
128
+                'system_label' => 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE',
129 129
                 'display_label' => $rhs_display_label
130 130
             );
131 131
             $labelDefinitions[] = array(
132 132
                 'module' => $this->rhs_module,
133
-                'system_label' => 'LBL_' . strtoupper($this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel()) . '_TITLE',
133
+                'system_label' => 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE',
134 134
                 'display_label' => $lhs_display_label
135 135
             );
136 136
 
137 137
             ActivitiesRelationship::$labelsAdded[$this->lhs_module] = true;
138 138
         }
139
-        return $labelDefinitions ;
139
+        return $labelDefinitions;
140 140
     }
141 141
 
142 142
 
143 143
 	/*
144 144
      * @return array    An array of field definitions, ready for the vardefs, keyed by module
145 145
      */
146
-    function buildVardefs ( )
146
+    function buildVardefs( )
147 147
     {
148
-        $vardefs = array ( ) ;
148
+        $vardefs = array( );
149 149
 
150
-        $vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name ) ;
151
-        $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name ) ;
150
+        $vardefs [$this->rhs_module] [] = $this->getLinkFieldDefinition($this->lhs_module, $this->relationship_name);
151
+        $vardefs [$this->lhs_module] [] = $this->getLinkFieldDefinition($this->rhs_module, $this->relationship_name);
152 152
 
153 153
 
154
-        return $vardefs ;
154
+        return $vardefs;
155 155
     }
156 156
 
157
-	protected function getLinkFieldDefinition ($sourceModule , $relationshipName)
157
+	protected function getLinkFieldDefinition($sourceModule, $relationshipName)
158 158
     {
159
-        $vardef = array ( ) ;
160
-        $vardef [ 'name' ] = $relationshipName;
161
-        $vardef [ 'type' ] = 'link' ;
162
-        $vardef [ 'relationship' ] = $relationshipName ;
163
-        $vardef [ 'source' ] = 'non-db' ;
164
-        $vardef [ 'module' ] = $sourceModule ;
165
-        $vardef [ 'bean_name' ] = BeanFactory::getObjectName($sourceModule) ;
166
-        $vardef [ 'vname' ] = strtoupper("LBL_{$relationshipName}_FROM_{$sourceModule}_TITLE");
167
-        return $vardef ;
159
+        $vardef = array( );
160
+        $vardef ['name'] = $relationshipName;
161
+        $vardef ['type'] = 'link';
162
+        $vardef ['relationship'] = $relationshipName;
163
+        $vardef ['source'] = 'non-db';
164
+        $vardef ['module'] = $sourceModule;
165
+        $vardef ['bean_name'] = BeanFactory::getObjectName($sourceModule);
166
+        $vardef ['vname'] = strtoupper("LBL_{$relationshipName}_FROM_{$sourceModule}_TITLE");
167
+        return $vardef;
168 168
     }
169 169
 
170 170
     /*
171 171
      * Define what fields to add to which modules layouts
172 172
      * @return array    An array of module => fieldname
173 173
      */
174
-    function buildFieldsToLayouts ()
174
+    function buildFieldsToLayouts()
175 175
     {
176 176
         if ($this->relationship_only)
177
-            return array () ;
177
+            return array();
178 178
 
179
-        return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
179
+        return array($this->rhs_module => $this->relationship_name."_name"); // this must match the name of the relate field from buildVardefs
180 180
     }
181 181
 
182
- 	function buildSubpanelDefinitions ()
182
+ 	function buildSubpanelDefinitions()
183 183
     {
184 184
         if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module]))
185
-            return array () ;
185
+            return array();
186 186
 
187 187
         ActivitiesRelationship::$subpanelsAdded[$this->lhs_module] = true;
188 188
         $relationshipName = substr($this->relationship_name, 0, strrpos($this->relationship_name, '_'));
189
-        return array( $this->lhs_module => array (
190
-        			  'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ),
191
-        			  'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) ,
189
+        return array($this->lhs_module => array(
190
+        			  'activities' => $this->buildActivitiesSubpanelDefinition($relationshipName),
191
+        			  'history' => $this->buildHistorySubpanelDefinition($relationshipName),
192 192
         			));
193 193
     }
194 194
 
195 195
     /*
196 196
      * @return array    An array of relationship metadata definitions
197 197
      */
198
-    function buildRelationshipMetaData ()
198
+    function buildRelationshipMetaData()
199 199
     {
200
-        $relationshipName = $this->definition [ 'relationship_name' ];
201
-        $relMetadata = array ( ) ;
202
-        $relMetadata [ 'lhs_module' ] = $this->definition [ 'lhs_module' ] ;
203
-        $relMetadata [ 'lhs_table' ] = $this->getTablename($this->definition [ 'lhs_module' ]) ;
204
-        $relMetadata [ 'lhs_key' ] = 'id' ;
205
-        $relMetadata [ 'rhs_module' ] = $this->definition [ 'rhs_module' ] ;
206
-        $relMetadata [ 'rhs_table' ] = $this->getTablename($this->definition [ 'rhs_module' ]) ;
200
+        $relationshipName = $this->definition ['relationship_name'];
201
+        $relMetadata = array( );
202
+        $relMetadata ['lhs_module'] = $this->definition ['lhs_module'];
203
+        $relMetadata ['lhs_table'] = $this->getTablename($this->definition ['lhs_module']);
204
+        $relMetadata ['lhs_key'] = 'id';
205
+        $relMetadata ['rhs_module'] = $this->definition ['rhs_module'];
206
+        $relMetadata ['rhs_table'] = $this->getTablename($this->definition ['rhs_module']);
207 207
         $relMetadata ['rhs_key'] = 'parent_id';
208 208
         $relMetadata ['relationship_type'] = 'one-to-many';
209 209
         $relMetadata ['relationship_role_column'] = 'parent_type';
210
-        $relMetadata ['relationship_role_column_value'] = $this->definition [ 'lhs_module' ] ;
210
+        $relMetadata ['relationship_role_column_value'] = $this->definition ['lhs_module'];
211 211
 
212
-    	return array( $this->lhs_module => array(
213
-    		'relationships' => array ($relationshipName => $relMetadata),
212
+    	return array($this->lhs_module => array(
213
+    		'relationships' => array($relationshipName => $relMetadata),
214 214
     		'fields' => '', 'indices' => '', 'table' => '')
215
-    	) ;
215
+    	);
216 216
     }
217 217
 
218 218
 /*
219 219
      * Shortcut to construct an Activities collection subpanel
220 220
      * @param AbstractRelationship $relationship    Source relationship to Activities module
221 221
      */
222
-    protected function buildActivitiesSubpanelDefinition ( $relationshipName )
222
+    protected function buildActivitiesSubpanelDefinition($relationshipName)
223 223
     {
224
-		return array (
225
-            'order' => 10 ,
226
-            'sort_order' => 'desc' ,
227
-            'sort_by' => 'date_start' ,
228
-            'title_key' => 'LBL_ACTIVITIES_SUBPANEL_TITLE' ,
229
-            'type' => 'collection' ,
230
-            'subpanel_name' => 'activities' , //this value is not associated with a physical file
231
-            'module' => 'Activities' ,
232
-            'top_buttons' => array (
233
-                array ( 'widget_class' => 'SubPanelTopCreateTaskButton' ) ,
234
-                array ( 'widget_class' => 'SubPanelTopScheduleMeetingButton' ) ,
235
-                array ( 'widget_class' => 'SubPanelTopScheduleCallButton' ) ,
236
-                array ( 'widget_class' => 'SubPanelTopComposeEmailButton' ) ) ,
237
-                'collection_list' => array (
238
-                    'meetings' => array (
239
-                        'module' => 'Meetings' ,
240
-                        'subpanel_name' => 'ForActivities' ,
241
-                        'get_subpanel_data' => $relationshipName. '_meetings' ) ,
242
-                    'tasks' => array (
243
-                        'module' => 'Tasks' ,
244
-                        'subpanel_name' => 'ForActivities' ,
245
-                        'get_subpanel_data' => $relationshipName. '_tasks' ) ,
246
-                    'calls' => array (
247
-                        'module' => 'Calls' ,
248
-                        'subpanel_name' => 'ForActivities' ,
249
-                        'get_subpanel_data' => $relationshipName. '_calls' ) ) ) ;
224
+		return array(
225
+            'order' => 10,
226
+            'sort_order' => 'desc',
227
+            'sort_by' => 'date_start',
228
+            'title_key' => 'LBL_ACTIVITIES_SUBPANEL_TITLE',
229
+            'type' => 'collection',
230
+            'subpanel_name' => 'activities', //this value is not associated with a physical file
231
+            'module' => 'Activities',
232
+            'top_buttons' => array(
233
+                array('widget_class' => 'SubPanelTopCreateTaskButton'),
234
+                array('widget_class' => 'SubPanelTopScheduleMeetingButton'),
235
+                array('widget_class' => 'SubPanelTopScheduleCallButton'),
236
+                array('widget_class' => 'SubPanelTopComposeEmailButton') ),
237
+                'collection_list' => array(
238
+                    'meetings' => array(
239
+                        'module' => 'Meetings',
240
+                        'subpanel_name' => 'ForActivities',
241
+                        'get_subpanel_data' => $relationshipName.'_meetings' ),
242
+                    'tasks' => array(
243
+                        'module' => 'Tasks',
244
+                        'subpanel_name' => 'ForActivities',
245
+                        'get_subpanel_data' => $relationshipName.'_tasks' ),
246
+                    'calls' => array(
247
+                        'module' => 'Calls',
248
+                        'subpanel_name' => 'ForActivities',
249
+                        'get_subpanel_data' => $relationshipName.'_calls' ) ) );
250 250
     }
251 251
 
252 252
     /*
253 253
      * Shortcut to construct a History collection subpanel
254 254
      * @param AbstractRelationship $relationship    Source relationship to Activities module
255 255
      */
256
-    protected function buildHistorySubpanelDefinition ( $relationshipName )
256
+    protected function buildHistorySubpanelDefinition($relationshipName)
257 257
     {
258
-        return array (
259
-            'order' => 20 ,
260
-            'sort_order' => 'desc' ,
261
-            'sort_by' => 'date_modified' ,
262
-            'title_key' => 'LBL_HISTORY' ,
263
-            'type' => 'collection' ,
264
-            'subpanel_name' => 'history' , //this values is not associated with a physical file.
265
-            'module' => 'History' ,
266
-            'top_buttons' => array (
267
-                array ( 'widget_class' => 'SubPanelTopCreateNoteButton' ) ,
268
-				array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'),
269
-                array ( 'widget_class' => 'SubPanelTopSummaryButton' ) ) ,
270
-                'collection_list' => array (
271
-                    'meetings' => array (
272
-                        'module' => 'Meetings' ,
273
-                        'subpanel_name' => 'ForHistory' ,
274
-                        'get_subpanel_data' => $relationshipName. '_meetings' ) ,
275
-                    'tasks' => array (
276
-                        'module' => 'Tasks' ,
277
-                        'subpanel_name' => 'ForHistory' ,
278
-                        'get_subpanel_data' => $relationshipName. '_tasks' ) ,
279
-                    'calls' => array (
280
-                        'module' => 'Calls' ,
281
-                        'subpanel_name' => 'ForHistory' ,
282
-                        'get_subpanel_data' => $relationshipName. '_calls' ) ,
283
-                    'notes' => array (
284
-                        'module' => 'Notes' ,
285
-                        'subpanel_name' => 'ForHistory' ,
286
-                        'get_subpanel_data' => $relationshipName. '_notes' ) ,
287
-                    'emails' => array (
288
-                        'module' => 'Emails' ,
289
-                        'subpanel_name' => 'ForHistory' ,
290
-                        'get_subpanel_data' => $relationshipName. '_emails' ) ) )  ;
258
+        return array(
259
+            'order' => 20,
260
+            'sort_order' => 'desc',
261
+            'sort_by' => 'date_modified',
262
+            'title_key' => 'LBL_HISTORY',
263
+            'type' => 'collection',
264
+            'subpanel_name' => 'history', //this values is not associated with a physical file.
265
+            'module' => 'History',
266
+            'top_buttons' => array(
267
+                array('widget_class' => 'SubPanelTopCreateNoteButton'),
268
+				array('widget_class' => 'SubPanelTopArchiveEmailButton'),
269
+                array('widget_class' => 'SubPanelTopSummaryButton') ),
270
+                'collection_list' => array(
271
+                    'meetings' => array(
272
+                        'module' => 'Meetings',
273
+                        'subpanel_name' => 'ForHistory',
274
+                        'get_subpanel_data' => $relationshipName.'_meetings' ),
275
+                    'tasks' => array(
276
+                        'module' => 'Tasks',
277
+                        'subpanel_name' => 'ForHistory',
278
+                        'get_subpanel_data' => $relationshipName.'_tasks' ),
279
+                    'calls' => array(
280
+                        'module' => 'Calls',
281
+                        'subpanel_name' => 'ForHistory',
282
+                        'get_subpanel_data' => $relationshipName.'_calls' ),
283
+                    'notes' => array(
284
+                        'module' => 'Notes',
285
+                        'subpanel_name' => 'ForHistory',
286
+                        'get_subpanel_data' => $relationshipName.'_notes' ),
287
+                    'emails' => array(
288
+                        'module' => 'Emails',
289
+                        'subpanel_name' => 'ForHistory',
290
+                        'get_subpanel_data' => $relationshipName.'_emails' ) ) );
291 291
     }
292 292
 }
Please login to merge, or discard this patch.
Braces   +9 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.
@@ -173,16 +175,18 @@  discard block
 block discarded – undo
173 175
      */
174 176
     function buildFieldsToLayouts ()
175 177
     {
176
-        if ($this->relationship_only)
177
-            return array () ;
178
+        if ($this->relationship_only) {
179
+                    return array () ;
180
+        }
178 181
 
179 182
         return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
180 183
     }
181 184
 
182 185
  	function buildSubpanelDefinitions ()
183 186
     {
184
-        if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module]))
185
-            return array () ;
187
+        if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module])) {
188
+                    return array () ;
189
+        }
186 190
 
187 191
         ActivitiesRelationship::$subpanelsAdded[$this->lhs_module] = true;
188 192
         $relationshipName = substr($this->relationship_name, 0, strrpos($this->relationship_name, '_'));
Please login to merge, or discard this patch.