Completed
Push — develop ( edae1e...431cf5 )
by Adam
20:48
created
modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php 1 patch
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.
modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php 1 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.
modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php 1 patch
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.
modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php 1 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.
modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php 1 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.
modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php 1 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.
modules/ModuleBuilder/parsers/constants.php 1 patch
Spacing   +24 added lines, -24 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,34 +39,34 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-define('MB_BASEMETADATALOCATION','base');
43
-define('MB_CUSTOMMETADATALOCATION','custom');
44
-define('MB_WORKINGMETADATALOCATION','working');
45
-define('MB_HISTORYMETADATALOCATION','history');
46
-define('MB_GRIDLAYOUTMETADATA','gridLayoutMetaData');
47
-define('MB_LISTLAYOUTMETADATA','listLayoutMetaData');
48
-define('MB_LISTVIEW','listview');
49
-define('MB_SEARCHVIEW','searchview');
50
-define('MB_BASICSEARCH','basic_search' );
51
-define('MB_ADVANCEDSEARCH','advanced_search' );
52
-define('MB_DASHLET','dashlet');
53
-define('MB_DASHLETSEARCH','dashletsearch');
54
-define('MB_EDITVIEW','editview');
55
-define('MB_DETAILVIEW','detailview');
56
-define('MB_QUICKCREATE','quickcreate');
57
-define('MB_POPUPLIST','popuplist');
58
-define('MB_POPUPSEARCH','popupsearch');
59
-define('MB_LABEL','label');
42
+define('MB_BASEMETADATALOCATION', 'base');
43
+define('MB_CUSTOMMETADATALOCATION', 'custom');
44
+define('MB_WORKINGMETADATALOCATION', 'working');
45
+define('MB_HISTORYMETADATALOCATION', 'history');
46
+define('MB_GRIDLAYOUTMETADATA', 'gridLayoutMetaData');
47
+define('MB_LISTLAYOUTMETADATA', 'listLayoutMetaData');
48
+define('MB_LISTVIEW', 'listview');
49
+define('MB_SEARCHVIEW', 'searchview');
50
+define('MB_BASICSEARCH', 'basic_search');
51
+define('MB_ADVANCEDSEARCH', 'advanced_search');
52
+define('MB_DASHLET', 'dashlet');
53
+define('MB_DASHLETSEARCH', 'dashletsearch');
54
+define('MB_EDITVIEW', 'editview');
55
+define('MB_DETAILVIEW', 'detailview');
56
+define('MB_QUICKCREATE', 'quickcreate');
57
+define('MB_POPUPLIST', 'popuplist');
58
+define('MB_POPUPSEARCH', 'popupsearch');
59
+define('MB_LABEL', 'label');
60 60
 define('MB_ONETOONE', 'one-to-one');
61 61
 define('MB_ONETOMANY', 'one-to-many');
62 62
 define('MB_MANYTOONE', 'many-to-one');
63 63
 define('MB_MANYTOMANY', 'many-to-many');
64
-define('MB_MAXDBIDENTIFIERLENGTH',30); // maximum length of any identifier in our supported databases
65
-define('MB_EXPORTPREPEND','project_');
66
-define('MB_VISIBILITY','visibility');
64
+define('MB_MAXDBIDENTIFIERLENGTH', 30); // maximum length of any identifier in our supported databases
65
+define('MB_EXPORTPREPEND', 'project_');
66
+define('MB_VISIBILITY', 'visibility');
67 67
 
68 68
 class MBConstants
69 69
 {
70
-	static $EMPTY = array ( 'name' => '(empty)' , 'label' => '(empty)' ) ;
71
-	static $FILLER = array ( 'name' => '(filler)' , 'label' => 'LBL_FILLER' ) ; // would prefer to have label => translate('LBL_FILLER') but can't be done in a static, and don't want to require instantiating a new object to get these constants
70
+	static $EMPTY = array('name' => '(empty)', 'label' => '(empty)');
71
+	static $FILLER = array('name' => '(filler)', 'label' => 'LBL_FILLER'); // would prefer to have label => translate('LBL_FILLER') but can't be done in a static, and don't want to require instantiating a new object to get these constants
72 72
 }
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.dropdown.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @param REQUEST params  $params
51 51
      */
52
-    function saveDropDown($params){
52
+    function saveDropDown($params) {
53 53
         require_once('modules/Administration/Common.php');
54 54
 		$emptyMarker = translate('LBL_BLANK');
55
-		$selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);
55
+		$selected_lang = (!empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']);
56 56
 		$type = $_REQUEST['view_package'];
57 57
 		$dir = '';
58 58
 		$dropdown_name = $params['dropdown_name'];
@@ -60,63 +60,63 @@  discard block
 block discarded – undo
60 60
 
61 61
 		$list_value = str_replace('&quot;&quot;:&quot;&quot;', '&quot;__empty__&quot;:&quot;&quot;', $params['list_value']);
62 62
 		//Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes.
63
-		$temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES) );
64
-		$dropdown = array () ;
63
+		$temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES));
64
+		$dropdown = array();
65 65
 		// dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order
66 66
 		// we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered
67
-        if(is_array($temp))
67
+        if (is_array($temp))
68 68
         {
69
-            foreach ( $temp as $item )
69
+            foreach ($temp as $item)
70 70
             {
71
-                $dropdown[ SugarCleaner::stripTags(from_html($item [ 0 ]), false) ] = SugarCleaner::stripTags(from_html($item [ 1 ]), false) ;
71
+                $dropdown[SugarCleaner::stripTags(from_html($item [0]), false)] = SugarCleaner::stripTags(from_html($item [1]), false);
72 72
             }
73 73
         }
74
-		if(array_key_exists($emptyMarker, $dropdown)){
75
-            $output=array();
76
-            foreach($dropdown as $key => $value){
77
-                if($emptyMarker===$key)
78
-                    $output['']='';
74
+		if (array_key_exists($emptyMarker, $dropdown)) {
75
+            $output = array();
76
+            foreach ($dropdown as $key => $value) {
77
+                if ($emptyMarker === $key)
78
+                    $output[''] = '';
79 79
                 else
80
-                    $output[$key]=$value;
80
+                    $output[$key] = $value;
81 81
 		}
82
-            $dropdown=$output;
82
+            $dropdown = $output;
83 83
 		}
84 84
 
85
-		if($type != 'studio'){
85
+		if ($type != 'studio') {
86 86
 			$mb = new ModuleBuilder();
87 87
 			$module = $mb->getPackageModule($params['view_package'], $params['view_module']);
88 88
 			$this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module);
89 89
 			//Can't use synch on selected lang as we want to overwrite values, not just keys
90 90
 			$module->mblanguage->appListStrings[$selected_lang.'.lang.php'][$dropdown_name] = $dropdown;
91 91
 			$module->mblanguage->save($module->key_name); // tyoung - key is required parameter as of
92
-		}else{
92
+		} else {
93 93
 			$contents = return_custom_app_list_strings_file_contents($selected_lang);
94 94
 			$my_list_strings = return_app_list_strings_language($selected_lang);
95
-			if($selected_lang == $GLOBALS['current_language']){
95
+			if ($selected_lang == $GLOBALS['current_language']) {
96 96
 	           $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown;
97 97
 	        }
98 98
 			//write to contents
99 99
 			$contents = str_replace("?>", '', $contents);
100
-			if(empty($contents))$contents = "<?php";
100
+			if (empty($contents))$contents = "<?php";
101 101
 	        //add new drop down to the bottom
102
-	        if(!empty($params['use_push'])){
102
+	        if (!empty($params['use_push'])) {
103 103
 	        	//this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed
104
-	        	foreach($dropdown as $key=>$value){
104
+	        	foreach ($dropdown as $key=>$value) {
105 105
 	        		//only if the value has changed or does not exist do we want to add it this way
106
-	        		if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){
106
+	        		if (!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0) {
107 107
 		        		//clear out the old value
108 108
 		        		$pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism';
109 109
 		        		$contents = preg_replace($pattern_match, "\n", $contents);
110 110
 		        		//add the new ones
111
-		        		$contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']['$key']=" . var_export_helper($value) . ";";
111
+		        		$contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']['$key']=".var_export_helper($value).";";
112 112
 	        		}
113 113
 	        	}
114
-	        }else{
114
+	        } else {
115 115
 	        	//Now synch up the keys in other langauges to ensure that removed/added Drop down values work properly under all langs.
116 116
 	        	$this->synchDropDown($dropdown_name, $dropdown, $selected_lang, $dir);
117 117
 	        	$contents = $this->getNewCustomContents($dropdown_name, $dropdown, $selected_lang);
118 118
 	        }
119
-		    if(!empty($dir) && !is_dir($dir))
119
+		    if (!empty($dir) && !is_dir($dir))
120 120
 		    {
121 121
 		     	$continue = mkdir_recursive($dir);
122 122
 		    }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param $saveLov String the path to the directory to save the new lang file in.
137 137
 	 */
138 138
     function synchDropDown($dropdown_name, $dropdown, $selected_lang, $saveLoc) {
139
-   		$allLanguages =  get_languages();
139
+   		$allLanguages = get_languages();
140 140
         foreach ($allLanguages as $lang => $langName) {
141 141
         	if ($lang != $selected_lang) {
142 142
         		$listStrings = return_app_list_strings_language($lang);
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 * @param $module MBModule the module to update the languages in
166 166
 	 */
167 167
     function synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module) {
168
-    	$selected_lang	= $selected_lang . '.lang.php';
169
-		foreach($module->mblanguage->appListStrings as $lang => $listStrings) {
168
+    	$selected_lang = $selected_lang.'.lang.php';
169
+		foreach ($module->mblanguage->appListStrings as $lang => $listStrings) {
170 170
 			if ($lang != $selected_lang)
171 171
 			{
172 172
 				$langDropDown = array();
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 
186 186
     private function synchDDKeys($dom, $sub) {
187 187
     	//check for extra keys
188
-        foreach($sub as $key=>$value) {
188
+        foreach ($sub as $key=>$value) {
189 189
         	if (!isset($dom[$key])) {
190 190
         		unset ($sub[$key]);
191 191
         	}
192 192
         }
193 193
         //check for missing keys
194
-        foreach($dom as $key=>$value) {
194
+        foreach ($dom as $key=>$value) {
195 195
         	if (!isset($sub[$key])) {
196 196
         		$sub[$key] = $value;
197 197
         	}
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
     function getNewCustomContents($dropdown_name, $dropdown, $lang) {
208 208
     	$contents = return_custom_app_list_strings_file_contents($lang);
209 209
         $contents = str_replace("?>", '', $contents);
210
-		if(empty($contents))$contents = "<?php";
210
+		if (empty($contents))$contents = "<?php";
211 211
     	$contents = preg_replace($this->getPatternMatch($dropdown_name), "\n", $contents);
212
-	    $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']=" . var_export_helper($dropdown) . ";";
212
+	    $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']=".var_export_helper($dropdown).";";
213 213
 	    return $contents;
214 214
     }
215 215
 }
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.modifysubpanel.php 1 patch
Spacing   +93 added lines, -93 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.
@@ -50,141 +50,141 @@  discard block
 block discarded – undo
50 50
  * There are two relevant modules for every subpanel - the module whose detailview this subpanel will appear in ($module_name), and the module that is the source of the data for the subpanel ($subPanelParentModule)
51 51
  */
52 52
 
53
-require_once ('modules/ModuleBuilder/parsers/parser.modifylistview.php') ;
53
+require_once ('modules/ModuleBuilder/parsers/parser.modifylistview.php');
54 54
 
55 55
 class ParserModifySubPanel extends ParserModifyListView
56 56
 {
57 57
     
58
-    var $listViewDefs = false ;
59
-    var $defaults = array ( ) ;
60
-    var $additional = array ( ) ;
61
-    var $available = array ( ) ;
62
-    var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
58
+    var $listViewDefs = false;
59
+    var $defaults = array( );
60
+    var $additional = array( );
61
+    var $available = array( );
62
+    var $columns = array('LBL_DEFAULT' => 'getDefaultFields', 'LBL_HIDDEN' => 'getAvailableFields');
63 63
     
64
-    function init ($module_name , $subPanelName)
64
+    function init($module_name, $subPanelName)
65 65
     {
66
-        $GLOBALS [ 'log' ]->debug ( "in ParserModifySubPanel: module_name={$module_name} child_module={$subPanelName}" ) ;
67
-        $this->moduleName = $module_name ;
68
-        $this->subPanelName = $subPanelName ;
69
-        global $beanList, $beanFiles ;
66
+        $GLOBALS ['log']->debug("in ParserModifySubPanel: module_name={$module_name} child_module={$subPanelName}");
67
+        $this->moduleName = $module_name;
68
+        $this->subPanelName = $subPanelName;
69
+        global $beanList, $beanFiles;
70 70
         
71 71
         // Sometimes we receive a module name which is not in the correct CamelCase, so shift to lower case for all beanList lookups
72
-        $beanListLower = array_change_key_case ( $beanList ) ;
72
+        $beanListLower = array_change_key_case($beanList);
73 73
         
74 74
         // Retrieve the definitions for all the available subpanels for this module
75
-        $class = $beanListLower [ strtolower ( $this->moduleName ) ] ;
76
-        require_once ($beanFiles [ $class ]) ;
77
-        $module = new $class ( ) ;
78
-        require_once ('include/SubPanel/SubPanelDefinitions.php') ;
79
-        $spd = new SubPanelDefinitions ( $module ) ;
75
+        $class = $beanListLower [strtolower($this->moduleName)];
76
+        require_once ($beanFiles [$class]);
77
+        $module = new $class( );
78
+        require_once ('include/SubPanel/SubPanelDefinitions.php');
79
+        $spd = new SubPanelDefinitions($module);
80 80
         
81 81
         // Get the lists of fields already in the subpanel and those that can be added in
82 82
         // Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object
83
-        $this->originalListViewDefs = array ( ) ;
84
-        if (array_key_exists ( strtolower ( $this->subPanelName ), $spd->layout_defs [ 'subpanel_setup' ] ))
83
+        $this->originalListViewDefs = array( );
84
+        if (array_key_exists(strtolower($this->subPanelName), $spd->layout_defs ['subpanel_setup']))
85 85
         {
86
-            $originalPanel = $spd->load_subpanel ( $this->subPanelName, true ) ;
87
-            $this->originalListViewDefs = $originalPanel->get_list_fields () ;
88
-            $this->panel = $spd->load_subpanel ( $subPanelName, false ) ;
89
-            $this->listViewDefs = $this->panel->get_list_fields () ;
86
+            $originalPanel = $spd->load_subpanel($this->subPanelName, true);
87
+            $this->originalListViewDefs = $originalPanel->get_list_fields();
88
+            $this->panel = $spd->load_subpanel($subPanelName, false);
89
+            $this->listViewDefs = $this->panel->get_list_fields();
90 90
             
91 91
             // Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout
92
-            $subPanelParentModuleName = $this->panel->get_module_name () ;
93
-            $this->subPanelParentModule = null ;
92
+            $subPanelParentModuleName = $this->panel->get_module_name();
93
+            $this->subPanelParentModule = null;
94 94
 
95
-            if (! empty ( $subPanelParentModuleName ) && isset($beanListLower[strtolower($subPanelParentModuleName)]))
95
+            if (!empty ($subPanelParentModuleName) && isset($beanListLower[strtolower($subPanelParentModuleName)]))
96 96
             {
97 97
                 $class = $beanListLower[strtolower($subPanelParentModuleName)];
98
-                if (isset($beanFiles [ $class ]))
98
+                if (isset($beanFiles [$class]))
99 99
                 {
100
-                    require_once ($beanFiles [ $class ]) ;
101
-                    $this->subPanelParentModule = new $class ( ) ;
100
+                    require_once ($beanFiles [$class]);
101
+                    $this->subPanelParentModule = new $class( );
102 102
                 }
103 103
             }
104 104
         }
105 105
         
106
-        $this->language_module = $this->panel->template_instance->module_dir ;
106
+        $this->language_module = $this->panel->template_instance->module_dir;
107 107
     }
108 108
     
109 109
     /**
110 110
      * Return a list of the fields that will be displayed in the subpanel
111 111
      */
112
-    function getDefaultFields ()
112
+    function getDefaultFields()
113 113
     {
114
-        $this->defaults = array ( ) ;
115
-        foreach ( $this->listViewDefs as $key => $def )
114
+        $this->defaults = array( );
115
+        foreach ($this->listViewDefs as $key => $def)
116 116
         {
117
-            if (! empty ( $def [ 'usage' ] ) && strcmp ( $def [ 'usage' ], 'query_only' ) == 0)
118
-                continue ;
119
-            if (! empty ( $def [ 'vname' ] ))
120
-                $def [ 'label' ] = $def [ 'vname' ] ;
121
-            $this->defaults [ $key ] = $def ;
117
+            if (!empty ($def ['usage']) && strcmp($def ['usage'], 'query_only') == 0)
118
+                continue;
119
+            if (!empty ($def ['vname']))
120
+                $def ['label'] = $def ['vname'];
121
+            $this->defaults [$key] = $def;
122 122
         }
123
-        return $this->defaults ;
123
+        return $this->defaults;
124 124
     }
125 125
     
126 126
     /**
127 127
      * Return a list of fields that are not currently included in the subpanel but that are available for use
128 128
      */
129
-    function getAvailableFields ()
129
+    function getAvailableFields()
130 130
     {
131
-        $this->availableFields = array ( ) ;
131
+        $this->availableFields = array( );
132 132
         if ($this->subPanelParentModule != null)
133 133
         {
134
-            $lowerFieldList = array_change_key_case ( $this->listViewDefs ) ;
135
-            foreach ( $this->originalListViewDefs as $key => $def )
134
+            $lowerFieldList = array_change_key_case($this->listViewDefs);
135
+            foreach ($this->originalListViewDefs as $key => $def)
136 136
             {
137
-                $key = strtolower ( $key ) ;
138
-                if (! isset ( $lowerFieldList [ $key ] ))
137
+                $key = strtolower($key);
138
+                if (!isset ($lowerFieldList [$key]))
139 139
                 {
140
-                    $this->availableFields [ $key ] = $def ;
140
+                    $this->availableFields [$key] = $def;
141 141
                 }
142 142
             }
143
-            $GLOBALS [ 'log' ]->debug ( 'parser.modifylistview.php->getAvailableFields(): field_defs=' . print_r ( $this->availableFields, true ) ) ;
144
-            foreach ( $this->subPanelParentModule->field_defs as $key => $fieldDefinition )
143
+            $GLOBALS ['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields, true));
144
+            foreach ($this->subPanelParentModule->field_defs as $key => $fieldDefinition)
145 145
             {
146
-                $fieldName = strtolower ( $key ) ;
147
-                if (! isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
146
+                $fieldName = strtolower($key);
147
+                if (!isset ($lowerFieldList [$fieldName])) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
148 148
                 {
149
-                    if ((empty ( $fieldDefinition [ 'source' ] ) || $fieldDefinition [ 'source' ] == 'db' || $fieldDefinition [ 'source' ] == 'custom_fields') && $fieldDefinition [ 'type' ] != 'id' && strcmp ( $fieldName, 'deleted' ) != 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) != false) || ! empty ( $def [ 'custom_type' ] ) && (empty ( $fieldDefinition [ 'dbType' ] ) || $fieldDefinition [ 'dbType' ] != 'id') && (empty ( $fieldDefinition [ 'dbtype' ] ) || $fieldDefinition [ 'dbtype' ] != 'id') || (! empty ( $fieldDefinition [ 'studio' ] ) && $fieldDefinition [ 'studio' ] == 'visible'))
149
+                    if ((empty ($fieldDefinition ['source']) || $fieldDefinition ['source'] == 'db' || $fieldDefinition ['source'] == 'custom_fields') && $fieldDefinition ['type'] != 'id' && strcmp($fieldName, 'deleted') != 0 || (isset ($def ['name']) && strpos($def ['name'], "_name") != false) || !empty ($def ['custom_type']) && (empty ($fieldDefinition ['dbType']) || $fieldDefinition ['dbType'] != 'id') && (empty ($fieldDefinition ['dbtype']) || $fieldDefinition ['dbtype'] != 'id') || (!empty ($fieldDefinition ['studio']) && $fieldDefinition ['studio'] == 'visible'))
150 150
                     {
151
-                        $label = (isset ( $fieldDefinition [ 'vname' ] )) ? $fieldDefinition [ 'vname' ] : (isset ( $fieldDefinition [ 'label' ] ) ? $fieldDefinition [ 'label' ] : $fieldDefinition [ 'name' ]) ;
152
-                        $this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ;
151
+                        $label = (isset ($fieldDefinition ['vname'])) ? $fieldDefinition ['vname'] : (isset ($fieldDefinition ['label']) ? $fieldDefinition ['label'] : $fieldDefinition ['name']);
152
+                        $this->availableFields [$fieldName] = array('width' => '10', 'label' => $label);
153 153
                     }
154 154
                 }
155 155
             }
156 156
         }
157 157
         
158
-        return $this->availableFields ;
158
+        return $this->availableFields;
159 159
     }
160 160
     
161
-    function getField ($fieldName)
161
+    function getField($fieldName)
162 162
     {
163
-        foreach ( $this->listViewDefs as $key => $def )
163
+        foreach ($this->listViewDefs as $key => $def)
164 164
         {
165
-            $key = strtolower ( $key ) ;
165
+            $key = strtolower($key);
166 166
             if ($key == $fieldName)
167 167
             {
168
-                return $def ;
168
+                return $def;
169 169
             }
170 170
         }
171
-        foreach ( $this->originalListViewDefs as $key => $def )
171
+        foreach ($this->originalListViewDefs as $key => $def)
172 172
         {
173
-            $key = strtolower ( $key ) ;
173
+            $key = strtolower($key);
174 174
             if ($key == $fieldName)
175 175
             {
176
-                return $def ;
176
+                return $def;
177 177
             }
178 178
         }
179
-        foreach ( $this->panel->template_instance->field_defs as $key => $def )
179
+        foreach ($this->panel->template_instance->field_defs as $key => $def)
180 180
         {
181
-            $key = strtolower ( $key ) ;
181
+            $key = strtolower($key);
182 182
             if ($key == $fieldName)
183 183
             {
184
-                return $def ;
184
+                return $def;
185 185
             }
186 186
         }
187
-        return array ( ) ;
187
+        return array( );
188 188
     }
189 189
     
190 190
     /*
@@ -192,67 +192,67 @@  discard block
 block discarded – undo
192 192
      * Obtains the field definitions from a _REQUEST array, and merges them with the other fields from the original definitions
193 193
      * Uses the subpanel override mechanism from SubPanel to save them 
194 194
      */
195
-    function handleSave ()
195
+    function handleSave()
196 196
     {
197
-        $GLOBALS [ 'log' ]->debug ( "in ParserModifySubPanel->handleSave()" ) ;
198
-        require_once ('include/SubPanel/SubPanel.php') ;
199
-        $subpanel = new SubPanel ( $this->moduleName, 'fab4', $this->subPanelName, $this->panel ) ;
197
+        $GLOBALS ['log']->debug("in ParserModifySubPanel->handleSave()");
198
+        require_once ('include/SubPanel/SubPanel.php');
199
+        $subpanel = new SubPanel($this->moduleName, 'fab4', $this->subPanelName, $this->panel);
200 200
         
201
-        $newFields = array ( ) ;
202
-        foreach ( $this->listViewDefs as $name => $field )
201
+        $newFields = array( );
202
+        foreach ($this->listViewDefs as $name => $field)
203 203
         {
204
-            if (! isset ( $field [ 'usage' ] ) || $field [ 'usage' ] != 'query_only')
204
+            if (!isset ($field ['usage']) || $field ['usage'] != 'query_only')
205 205
             {
206
-                $existingFields [ $name ] = $field ;
206
+                $existingFields [$name] = $field;
207 207
             
208 208
             } else
209 209
             {
210
-                $newFields [ $name ] = $field ;
210
+                $newFields [$name] = $field;
211 211
             }
212 212
         }
213 213
         
214 214
         // Loop through all of the fields defined in the 'Default' group of the ListView data in $_REQUEST
215 215
         // Replace the field specification in the originalListViewDef with this new updated specification
216
-        foreach ( $_REQUEST [ 'group_0' ] as $field )
216
+        foreach ($_REQUEST ['group_0'] as $field)
217 217
         {
218
-            if (! empty ( $this->originalListViewDefs [ $field ] ))
218
+            if (!empty ($this->originalListViewDefs [$field]))
219 219
             {
220
-                $newFields [ $field ] = $this->originalListViewDefs [ $field ] ;
220
+                $newFields [$field] = $this->originalListViewDefs [$field];
221 221
             } else
222 222
             {
223 223
                 
224
-                $vname = '' ;
225
-                if (isset ( $this->panel->template_instance->field_defs [ $field ] ))
224
+                $vname = '';
225
+                if (isset ($this->panel->template_instance->field_defs [$field]))
226 226
                 {
227
-                    $vname = $this->panel->template_instance->field_defs [ $field ] [ 'vname' ] ;
227
+                    $vname = $this->panel->template_instance->field_defs [$field] ['vname'];
228 228
                 }
229
-                if (($this->subPanelParentModule != null) && (isset ( $this->subPanelParentModule->field_name_map [ $field ] ) && ($this->subPanelParentModule->field_name_map [ $field ] [ 'type' ] == 'bool' || (isset ( $this->subPanelParentModule->field_name_map [ $field ] [ 'custom_type' ] ) && $this->subPanelParentModule->field_name_map [ $field ] [ 'custom_type' ] == 'bool'))))
229
+                if (($this->subPanelParentModule != null) && (isset ($this->subPanelParentModule->field_name_map [$field]) && ($this->subPanelParentModule->field_name_map [$field] ['type'] == 'bool' || (isset ($this->subPanelParentModule->field_name_map [$field] ['custom_type']) && $this->subPanelParentModule->field_name_map [$field] ['custom_type'] == 'bool'))))
230 230
                 {
231
-                    $newFields [ $field ] = array ( 'name' => $field , 'vname' => $vname , 'widget_type' => 'checkbox' ) ;
231
+                    $newFields [$field] = array('name' => $field, 'vname' => $vname, 'widget_type' => 'checkbox');
232 232
                 } else
233 233
                 {
234
-                    $newFields [ $field ] = array ( 'name' => $field , 'vname' => $vname ) ;
234
+                    $newFields [$field] = array('name' => $field, 'vname' => $vname);
235 235
                 }
236 236
             }
237 237
             
238 238
             // Now set the field width if specified in the $_REQUEST data
239
-            if (isset ( $_REQUEST [ strtolower ( $field ) . 'width' ] ))
239
+            if (isset ($_REQUEST [strtolower($field).'width']))
240 240
             {
241
-                $width = substr ( $_REQUEST [ strtolower ( $field ) . 'width' ], 6, 3 ) ;
242
-                if (strpos ( $width, "%" ) != false)
241
+                $width = substr($_REQUEST [strtolower($field).'width'], 6, 3);
242
+                if (strpos($width, "%") != false)
243 243
                 {
244
-                    $width = substr ( $width, 0, 2 ) ;
244
+                    $width = substr($width, 0, 2);
245 245
                 }
246 246
                 if ($width < 101 && $width > 0)
247 247
                 {
248
-                    $newFields [ $field ] [ 'width' ] = $width ;
248
+                    $newFields [$field] ['width'] = $width;
249 249
                 }
250
-            } else if (isset ( $this->listViewDefs [ $field ] [ 'width' ] ))
250
+            } else if (isset ($this->listViewDefs [$field] ['width']))
251 251
             {
252
-                $newFields [ $field ] [ 'width' ] = $this->listViewDefs [ $field ] [ 'width' ] ;
252
+                $newFields [$field] ['width'] = $this->listViewDefs [$field] ['width'];
253 253
             }
254 254
         }
255
-        $subpanel->saveSubPanelDefOverride ( $this->panel, 'list_fields', $newFields ) ;
255
+        $subpanel->saveSubPanelDefOverride($this->panel, 'list_fields', $newFields);
256 256
     
257 257
     }
258 258
 
Please login to merge, or discard this patch.