@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | class ViewModulefield extends SugarView |
44 | 44 | { |
45 | 45 | /** |
46 | - * @see SugarView::_getModuleTitleParams() |
|
47 | - */ |
|
48 | - protected function _getModuleTitleParams($browserTitle = false) |
|
49 | - { |
|
50 | - global $mod_strings; |
|
46 | + * @see SugarView::_getModuleTitleParams() |
|
47 | + */ |
|
48 | + protected function _getModuleTitleParams($browserTitle = false) |
|
49 | + { |
|
50 | + global $mod_strings; |
|
51 | 51 | |
52 | - return array( |
|
53 | - translate('LBL_MODULE_NAME','Administration'), |
|
54 | - ModuleBuilderController::getModuleTitle(), |
|
55 | - ); |
|
52 | + return array( |
|
53 | + translate('LBL_MODULE_NAME','Administration'), |
|
54 | + ModuleBuilderController::getModuleTitle(), |
|
55 | + ); |
|
56 | 56 | } |
57 | 57 | |
58 | - function display() |
|
59 | - { |
|
58 | + function display() |
|
59 | + { |
|
60 | 60 | $ac = $this->fetch(); |
61 | 61 | echo $ac->getJavascript(); |
62 | 62 | } |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $field_name = ''; |
77 | 77 | |
78 | 78 | $action = 'saveField'; // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB |
79 | - // fields we override this so don't create a new dynamic field instead of updating the existing field |
|
79 | + // fields we override this so don't create a new dynamic field instead of updating the existing field |
|
80 | 80 | |
81 | 81 | $isClone = false; |
82 | 82 | if(!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] |
83 | 83 | && (strcmp($field_name, "name") != 0) // bug #35767, do not allow cloning of name field |
84 | 84 | ) |
85 | 85 | $isClone = true; |
86 | - /* |
|
86 | + /* |
|
87 | 87 | $field_types = array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown', |
88 | 88 | 'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio', |
89 | 89 | 'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link'); |
90 | 90 | */ |
91 | - $field_types = $GLOBALS['mod_strings']['fieldTypes']; |
|
92 | - if (isset($field_types['encrypt'])) |
|
93 | - unset($field_types['encrypt']); |
|
91 | + $field_types = $GLOBALS['mod_strings']['fieldTypes']; |
|
92 | + if (isset($field_types['encrypt'])) |
|
93 | + unset($field_types['encrypt']); |
|
94 | 94 | $field_name_exceptions = array( |
95 | 95 | //bug 22264: Field name must not be an SQL keyword. |
96 | 96 | //Taken from SQL Server's list of reserved keywords; http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | 'DROP','OPENROWSET','VIEW','DUMMY','OPENXML','WAITFOR','DUMP','OPTION','WHEN','ELSE','OR','WHERE', |
111 | 111 | 'END','ORDER','WHILE','ERRLVL','OUTER','WITH','ESCAPE','OVER','WRITETEXT', |
112 | 112 | //Mysql Keywords from http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html (those not in MSSQL's list) |
113 | - 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', |
|
114 | - 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', |
|
115 | - 'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN', |
|
116 | - 'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', |
|
117 | - 'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', |
|
118 | - 'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', |
|
119 | - 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', |
|
120 | - 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE', |
|
121 | - 'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', |
|
122 | - 'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME', |
|
123 | - 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', |
|
124 | - 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', |
|
125 | - 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', |
|
126 | - 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', |
|
127 | - //Oracle datatypes |
|
113 | + 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', |
|
114 | + 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', |
|
115 | + 'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN', |
|
116 | + 'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', |
|
117 | + 'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', |
|
118 | + 'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', |
|
119 | + 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', |
|
120 | + 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE', |
|
121 | + 'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', |
|
122 | + 'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME', |
|
123 | + 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', |
|
124 | + 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', |
|
125 | + 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', |
|
126 | + 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', |
|
127 | + //Oracle datatypes |
|
128 | 128 | 'DATE','VARCHAR','VARCHAR2','NVARCHAR2','CHAR','NCHAR','NUMBER','PLS_INTEGER','BINARY_INTEGER','LONG','TIMESTAMP', |
129 | - 'INTERVAL','RAW','ROWID','UROWID','MLSLABEL','CLOB','NCLOB','BLOB','BFILE','XMLTYPE', |
|
130 | - //SugarCRM reserved |
|
131 | - 'ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID', |
|
132 | - ); |
|
129 | + 'INTERVAL','RAW','ROWID','UROWID','MLSLABEL','CLOB','NCLOB','BLOB','BFILE','XMLTYPE', |
|
130 | + //SugarCRM reserved |
|
131 | + 'ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID', |
|
132 | + ); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | //C.L. - Add support to mark related module id columns as reserved keywords |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | $fv->ss->assign('hideLevel', 3); |
174 | 174 | } |
175 | 175 | if($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime'){ |
176 | - $vardef['type'] = 'datetimecombo'; |
|
176 | + $vardef['type'] = 'datetimecombo'; |
|
177 | 177 | } |
178 | 178 | |
179 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
179 | + require_once ('modules/DynamicFields/FieldCases.php') ; |
|
180 | 180 | $tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ; |
181 | 181 | $tf->module = $module; |
182 | 182 | $tf->populateFromRow($vardef); |
183 | - $vardef = array_merge($vardef, $tf->get_field_def()); |
|
183 | + $vardef = array_merge($vardef, $tf->get_field_def()); |
|
184 | 184 | |
185 | 185 | // $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true)); |
186 | 186 | |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | $enumFields = array(); |
191 | 191 | foreach($module->field_defs as $field => $def) |
192 | 192 | { |
193 | - if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) { |
|
194 | - $allowAutoInc = false; |
|
195 | - continue; |
|
196 | - } |
|
193 | + if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) { |
|
194 | + $allowAutoInc = false; |
|
195 | + continue; |
|
196 | + } |
|
197 | 197 | if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) |
198 | 198 | { |
199 | 199 | if(!empty($def['studio']) && $def['studio'] == "false") continue; //bug51866 |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | $fv->ss->assign('module', $module); |
212 | 212 | if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
213 | - $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
213 | + $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
214 | 214 | |
215 | 215 | $edit_or_add = 'editField' ; |
216 | 216 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
247 | + require_once ('modules/DynamicFields/FieldCases.php') ; |
|
248 | 248 | $tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ; |
249 | 249 | $tf->module = $module; |
250 | 250 | $tf->populateFromRow($vardef); |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | |
259 | 259 | if(isset($vardef['vname'])) |
260 | 260 | $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8')); |
261 | - if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
262 | - $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
261 | + if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
262 | + $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
263 | 263 | |
264 | 264 | $enumFields = array(); |
265 | 265 | if (!empty($module->mbvardefs->vardefs['fields'])) |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | if($_REQUEST['action'] == 'RefreshField'){ |
283 | - require_once('modules/DynamicFields/FieldCases.php'); |
|
283 | + require_once('modules/DynamicFields/FieldCases.php'); |
|
284 | 284 | $field = get_widget($_POST['type']); |
285 | 285 | $field->populateFromPost(); |
286 | 286 | $vardef = $field->get_field_def(); |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | foreach(array("formula", "default", "comments", "help", "visiblityGrid") as $toEscape) |
292 | - { |
|
293 | - if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) { |
|
294 | - $vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8'); |
|
295 | - } |
|
296 | - } |
|
292 | + { |
|
293 | + if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) { |
|
294 | + $vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8'); |
|
295 | + } |
|
296 | + } |
|
297 | 297 | |
298 | 298 | if((!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true) |
299 | 299 | || (strcmp($field_name, "name") == 0) || (isset($vardef['type']) && $vardef['type'] == 'name')) // bug #35767, do not allow cloning of name field |
300 | 300 | { |
301 | - $fv->ss->assign('no_duplicate', true); |
|
301 | + $fv->ss->assign('no_duplicate', true); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | $fv->ss->assign('action',$action); |
@@ -318,25 +318,25 @@ discard block |
||
318 | 318 | $existing_field_names = array () ; |
319 | 319 | foreach ( $module->mbvardefs->vardefs['fields'] as $field ) |
320 | 320 | { |
321 | - if ($field [ 'type' ] == 'enum' || $field [ 'type'] == 'multienum' ) |
|
322 | - { |
|
323 | - $triggers [] = $field [ 'name' ] ; |
|
324 | - } |
|
321 | + if ($field [ 'type' ] == 'enum' || $field [ 'type'] == 'multienum' ) |
|
322 | + { |
|
323 | + $triggers [] = $field [ 'name' ] ; |
|
324 | + } |
|
325 | 325 | |
326 | - if (!isset($field['source']) || $field['source'] != 'non-db') { |
|
327 | - if(preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) |
|
328 | - { |
|
329 | - $existing_field_names [] = strtoupper($matches[1]); |
|
330 | - } |
|
331 | - } |
|
326 | + if (!isset($field['source']) || $field['source'] != 'non-db') { |
|
327 | + if(preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) |
|
328 | + { |
|
329 | + $existing_field_names [] = strtoupper($matches[1]); |
|
330 | + } |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | $fv->ss->assign('triggers',$triggers); |
335 | 335 | $fv->ss->assign('existing_field_names', $json->encode($existing_field_names)); |
336 | 336 | $fv->ss->assign('mod_strings',$GLOBALS['mod_strings']); |
337 | 337 | |
338 | - // jchi #24880 |
|
339 | - // end |
|
338 | + // jchi #24880 |
|
339 | + // end |
|
340 | 340 | |
341 | 341 | |
342 | 342 | $layout = $fv->getLayout($vardef); |
@@ -66,14 +66,17 @@ discard block |
||
66 | 66 | ) |
67 | 67 | { |
68 | 68 | $fv = new FieldViewer(); |
69 | - if(empty($_REQUEST['field'])&& !empty($_REQUEST['name']))$_REQUEST['field'] = $_REQUEST['name']; |
|
69 | + if(empty($_REQUEST['field'])&& !empty($_REQUEST['name'])) { |
|
70 | + $_REQUEST['field'] = $_REQUEST['name']; |
|
71 | + } |
|
70 | 72 | $field_name = ''; |
71 | - if(!empty($this->view_object_map['field_name'])) |
|
72 | - $field_name = $this->view_object_map['field_name']; |
|
73 | - elseif(!empty($_REQUEST['field'])) |
|
74 | - $field_name = $_REQUEST['field']; |
|
75 | - else |
|
76 | - $field_name = ''; |
|
73 | + if(!empty($this->view_object_map['field_name'])) { |
|
74 | + $field_name = $this->view_object_map['field_name']; |
|
75 | + } elseif(!empty($_REQUEST['field'])) { |
|
76 | + $field_name = $_REQUEST['field']; |
|
77 | + } else { |
|
78 | + $field_name = ''; |
|
79 | + } |
|
77 | 80 | |
78 | 81 | $action = 'saveField'; // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB |
79 | 82 | // fields we override this so don't create a new dynamic field instead of updating the existing field |
@@ -81,16 +84,18 @@ discard block |
||
81 | 84 | $isClone = false; |
82 | 85 | if(!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] |
83 | 86 | && (strcmp($field_name, "name") != 0) // bug #35767, do not allow cloning of name field |
84 | - ) |
|
85 | - $isClone = true; |
|
87 | + ) { |
|
88 | + $isClone = true; |
|
89 | + } |
|
86 | 90 | /* |
87 | 91 | $field_types = array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown', |
88 | 92 | 'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio', |
89 | 93 | 'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link'); |
90 | 94 | */ |
91 | 95 | $field_types = $GLOBALS['mod_strings']['fieldTypes']; |
92 | - if (isset($field_types['encrypt'])) |
|
93 | - unset($field_types['encrypt']); |
|
96 | + if (isset($field_types['encrypt'])) { |
|
97 | + unset($field_types['encrypt']); |
|
98 | + } |
|
94 | 99 | $field_name_exceptions = array( |
95 | 100 | //bug 22264: Field name must not be an SQL keyword. |
96 | 101 | //Taken from SQL Server's list of reserved keywords; http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx |
@@ -163,12 +168,13 @@ discard block |
||
163 | 168 | } |
164 | 169 | |
165 | 170 | if(empty($vardef['name'])){ |
166 | - if(!empty($_REQUEST['type'])) |
|
167 | - $vardef['type'] = $_REQUEST['type']; |
|
171 | + if(!empty($_REQUEST['type'])) { |
|
172 | + $vardef['type'] = $_REQUEST['type']; |
|
173 | + } |
|
168 | 174 | $fv->ss->assign('hideLevel', 0); |
169 | - }elseif(isset($vardef['custom_module'])){ |
|
175 | + } elseif(isset($vardef['custom_module'])){ |
|
170 | 176 | $fv->ss->assign('hideLevel', 2); |
171 | - }else{ |
|
177 | + } else{ |
|
172 | 178 | $action = 'saveSugarField'; // tyoung - for OOB fields we currently only support modifying the label |
173 | 179 | $fv->ss->assign('hideLevel', 3); |
174 | 180 | } |
@@ -196,10 +202,14 @@ discard block |
||
196 | 202 | } |
197 | 203 | if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) |
198 | 204 | { |
199 | - if(!empty($def['studio']) && $def['studio'] == "false") continue; //bug51866 |
|
205 | + if(!empty($def['studio']) && $def['studio'] == "false") { |
|
206 | + continue; |
|
207 | + } |
|
208 | + //bug51866 |
|
200 | 209 | $enumFields[$field] = translate($def['vname'], $moduleName); |
201 | - if (substr($enumFields[$field], -1) == ":") |
|
202 | - $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1); |
|
210 | + if (substr($enumFields[$field], -1) == ":") { |
|
211 | + $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1); |
|
212 | + } |
|
203 | 213 | } |
204 | 214 | } |
205 | 215 | $fv->ss->assign( 'allowAutoInc', $allowAutoInc); |
@@ -209,8 +219,9 @@ discard block |
||
209 | 219 | $fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8')); |
210 | 220 | } |
211 | 221 | $fv->ss->assign('module', $module); |
212 | - if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
213 | - $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
222 | + if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) { |
|
223 | + $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
224 | + } |
|
214 | 225 | |
215 | 226 | $edit_or_add = 'editField' ; |
216 | 227 | |
@@ -232,14 +243,16 @@ discard block |
||
232 | 243 | } |
233 | 244 | |
234 | 245 | if(empty($vardef['name'])){ |
235 | - if(!empty($_REQUEST['type']))$vardef['type'] = $_REQUEST['type']; |
|
246 | + if(!empty($_REQUEST['type'])) { |
|
247 | + $vardef['type'] = $_REQUEST['type']; |
|
248 | + } |
|
236 | 249 | $fv->ss->assign('hideLevel', 0); |
237 | - }else{ |
|
250 | + } else{ |
|
238 | 251 | if(!empty($module->mbvardefs->vardef['fields'][$vardef['name']])){ |
239 | 252 | $fv->ss->assign('hideLevel', 1); |
240 | - }elseif(isset($vardef['custom_module'])){ |
|
253 | + } elseif(isset($vardef['custom_module'])){ |
|
241 | 254 | $fv->ss->assign('hideLevel', 2); |
242 | - }else{ |
|
255 | + } else{ |
|
243 | 256 | $fv->ss->assign('hideLevel', 3); // tyoung bug 17350 - effectively mark template derived fields as readonly |
244 | 257 | } |
245 | 258 | } |
@@ -256,10 +269,12 @@ discard block |
||
256 | 269 | $fv->ss->assign('package', $package); |
257 | 270 | $fv->ss->assign('MB','1'); |
258 | 271 | |
259 | - if(isset($vardef['vname'])) |
|
260 | - $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8')); |
|
261 | - if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
262 | - $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
272 | + if(isset($vardef['vname'])) { |
|
273 | + $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8')); |
|
274 | + } |
|
275 | + if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) { |
|
276 | + $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
|
277 | + } |
|
263 | 278 | |
264 | 279 | $enumFields = array(); |
265 | 280 | if (!empty($module->mbvardefs->vardefs['fields'])) |
@@ -270,8 +285,9 @@ discard block |
||
270 | 285 | { |
271 | 286 | $enumFields[$field] = isset($module->mblanguage->strings[$current_language][$def['vname']]) ? |
272 | 287 | $this->mbModule->mblanguage->strings[$current_language][$def['vname']] : translate($field); |
273 | - if (substr($enumFields[$field], -1) == ":") |
|
274 | - $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) -1); |
|
288 | + if (substr($enumFields[$field], -1) == ":") { |
|
289 | + $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) -1); |
|
290 | + } |
|
275 | 291 | } |
276 | 292 | } |
277 | 293 | } |
@@ -296,9 +312,11 @@ discard block |
||
296 | 312 | } |
297 | 313 | |
298 | 314 | if((!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true) |
299 | - || (strcmp($field_name, "name") == 0) || (isset($vardef['type']) && $vardef['type'] == 'name')) // bug #35767, do not allow cloning of name field |
|
315 | + || (strcmp($field_name, "name") == 0) || (isset($vardef['type']) && $vardef['type'] == 'name')) { |
|
316 | + // bug #35767, do not allow cloning of name field |
|
300 | 317 | { |
301 | 318 | $fv->ss->assign('no_duplicate', true); |
319 | + } |
|
302 | 320 | } |
303 | 321 | |
304 | 322 | $fv->ss->assign('action',$action); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | global $mod_strings; |
51 | 51 | |
52 | 52 | return array( |
53 | - translate('LBL_MODULE_NAME','Administration'), |
|
53 | + translate('LBL_MODULE_NAME', 'Administration'), |
|
54 | 54 | ModuleBuilderController::getModuleTitle(), |
55 | 55 | ); |
56 | 56 | } |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | ) |
67 | 67 | { |
68 | 68 | $fv = new FieldViewer(); |
69 | - if(empty($_REQUEST['field'])&& !empty($_REQUEST['name']))$_REQUEST['field'] = $_REQUEST['name']; |
|
69 | + if (empty($_REQUEST['field']) && !empty($_REQUEST['name']))$_REQUEST['field'] = $_REQUEST['name']; |
|
70 | 70 | $field_name = ''; |
71 | - if(!empty($this->view_object_map['field_name'])) |
|
71 | + if (!empty($this->view_object_map['field_name'])) |
|
72 | 72 | $field_name = $this->view_object_map['field_name']; |
73 | - elseif(!empty($_REQUEST['field'])) |
|
73 | + elseif (!empty($_REQUEST['field'])) |
|
74 | 74 | $field_name = $_REQUEST['field']; |
75 | 75 | else |
76 | 76 | $field_name = ''; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // fields we override this so don't create a new dynamic field instead of updating the existing field |
80 | 80 | |
81 | 81 | $isClone = false; |
82 | - if(!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] |
|
82 | + if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] |
|
83 | 83 | && (strcmp($field_name, "name") != 0) // bug #35767, do not allow cloning of name field |
84 | 84 | ) |
85 | 85 | $isClone = true; |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | $field_name_exceptions = array( |
95 | 95 | //bug 22264: Field name must not be an SQL keyword. |
96 | 96 | //Taken from SQL Server's list of reserved keywords; http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx |
97 | - 'ADD','EXCEPT','PERCENT','ALL','EXEC','PLAN','ALTER','EXECUTE','PRECISION','AND','EXISTS','PRIMARY', |
|
98 | - 'ANY','EXIT','PRINT','AS','FETCH','PROC','ASC','FILE','PROCEDURE','AUTHORIZATION','FILLFACTOR','PUBLIC', |
|
99 | - 'BACKUP','FOR','RAISERROR','BEGIN','FOREIGN','READ','BETWEEN','FREETEXT','READTEXT','BREAK','FREETEXTTABLE', |
|
100 | - 'RECONFIGURE','BROWSE','FROM','REFERENCES','BULK','FULL','REPLICATION','BY','FUNCTION','RESTORE', |
|
101 | - 'CASCADE','GOTO','RESTRICT','CASE','GRANT','RETURN','CHECK','GROUP','REVOKE','CHECKPOINT','HAVING','RIGHT','CLOSE', |
|
102 | - 'HOLDLOCK','ROLLBACK','CLUSTERED','IDENTITY','ROWCOUNT','COALESCE','IDENTITY_INSERT','ROWGUIDCOL','COLLATE','IDENTITYCOL', |
|
103 | - 'RULE','COLUMN','IF','SAVE','COMMIT','IN','SCHEMA','COMPUTE','INDEX','SELECT','CONSTRAINT','INNER','SESSION_USER', |
|
104 | - 'CONTAINS','INSERT','SET','CONTAINSTABLE','INTERSECT','SETUSER','CONTINUE','INTO','SHUTDOWN','CONVERT','IS','SOME', |
|
105 | - 'CREATE','JOIN','STATISTICS','CROSS','KEY','SYSTEM_USER','CURRENT','KILL','TABLE','CURRENT_DATE','LEFT','TEXTSIZE', |
|
106 | - 'CURRENT_TIME','LIKE','THEN','CURRENT_TIMESTAMP','LINENO','TO','CURRENT_USER','LOAD','TOP','CURSOR','NATIONAL','TRAN', |
|
107 | - 'DATABASE','NOCHECK','TRANSACTION','DBCC','NONCLUSTERED','TRIGGER','DEALLOCATE','NOT','TRUNCATE','DECLARE','NULL','TSEQUAL', |
|
108 | - 'DEFAULT','NULLIF','UNION','DELETE','OF','UNIQUE','DENY','OFF','UPDATE','DESC','OFFSETS','UPDATETEXT', |
|
109 | - 'DISK','ON','USE','DISTINCT','OPEN','USER','DISTRIBUTED','OPENCONNECTOR','VALUES','DOUBLE','OPENQUERY','VARYING', |
|
110 | - 'DROP','OPENROWSET','VIEW','DUMMY','OPENXML','WAITFOR','DUMP','OPTION','WHEN','ELSE','OR','WHERE', |
|
111 | - 'END','ORDER','WHILE','ERRLVL','OUTER','WITH','ESCAPE','OVER','WRITETEXT', |
|
97 | + 'ADD', 'EXCEPT', 'PERCENT', 'ALL', 'EXEC', 'PLAN', 'ALTER', 'EXECUTE', 'PRECISION', 'AND', 'EXISTS', 'PRIMARY', |
|
98 | + 'ANY', 'EXIT', 'PRINT', 'AS', 'FETCH', 'PROC', 'ASC', 'FILE', 'PROCEDURE', 'AUTHORIZATION', 'FILLFACTOR', 'PUBLIC', |
|
99 | + 'BACKUP', 'FOR', 'RAISERROR', 'BEGIN', 'FOREIGN', 'READ', 'BETWEEN', 'FREETEXT', 'READTEXT', 'BREAK', 'FREETEXTTABLE', |
|
100 | + 'RECONFIGURE', 'BROWSE', 'FROM', 'REFERENCES', 'BULK', 'FULL', 'REPLICATION', 'BY', 'FUNCTION', 'RESTORE', |
|
101 | + 'CASCADE', 'GOTO', 'RESTRICT', 'CASE', 'GRANT', 'RETURN', 'CHECK', 'GROUP', 'REVOKE', 'CHECKPOINT', 'HAVING', 'RIGHT', 'CLOSE', |
|
102 | + 'HOLDLOCK', 'ROLLBACK', 'CLUSTERED', 'IDENTITY', 'ROWCOUNT', 'COALESCE', 'IDENTITY_INSERT', 'ROWGUIDCOL', 'COLLATE', 'IDENTITYCOL', |
|
103 | + 'RULE', 'COLUMN', 'IF', 'SAVE', 'COMMIT', 'IN', 'SCHEMA', 'COMPUTE', 'INDEX', 'SELECT', 'CONSTRAINT', 'INNER', 'SESSION_USER', |
|
104 | + 'CONTAINS', 'INSERT', 'SET', 'CONTAINSTABLE', 'INTERSECT', 'SETUSER', 'CONTINUE', 'INTO', 'SHUTDOWN', 'CONVERT', 'IS', 'SOME', |
|
105 | + 'CREATE', 'JOIN', 'STATISTICS', 'CROSS', 'KEY', 'SYSTEM_USER', 'CURRENT', 'KILL', 'TABLE', 'CURRENT_DATE', 'LEFT', 'TEXTSIZE', |
|
106 | + 'CURRENT_TIME', 'LIKE', 'THEN', 'CURRENT_TIMESTAMP', 'LINENO', 'TO', 'CURRENT_USER', 'LOAD', 'TOP', 'CURSOR', 'NATIONAL', 'TRAN', |
|
107 | + 'DATABASE', 'NOCHECK', 'TRANSACTION', 'DBCC', 'NONCLUSTERED', 'TRIGGER', 'DEALLOCATE', 'NOT', 'TRUNCATE', 'DECLARE', 'NULL', 'TSEQUAL', |
|
108 | + 'DEFAULT', 'NULLIF', 'UNION', 'DELETE', 'OF', 'UNIQUE', 'DENY', 'OFF', 'UPDATE', 'DESC', 'OFFSETS', 'UPDATETEXT', |
|
109 | + 'DISK', 'ON', 'USE', 'DISTINCT', 'OPEN', 'USER', 'DISTRIBUTED', 'OPENCONNECTOR', 'VALUES', 'DOUBLE', 'OPENQUERY', 'VARYING', |
|
110 | + 'DROP', 'OPENROWSET', 'VIEW', 'DUMMY', 'OPENXML', 'WAITFOR', 'DUMP', 'OPTION', 'WHEN', 'ELSE', 'OR', 'WHERE', |
|
111 | + 'END', 'ORDER', 'WHILE', 'ERRLVL', 'OUTER', 'WITH', 'ESCAPE', 'OVER', 'WRITETEXT', |
|
112 | 112 | //Mysql Keywords from http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html (those not in MSSQL's list) |
113 | 113 | 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', |
114 | 114 | 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', |
126 | 126 | 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', |
127 | 127 | //Oracle datatypes |
128 | - 'DATE','VARCHAR','VARCHAR2','NVARCHAR2','CHAR','NCHAR','NUMBER','PLS_INTEGER','BINARY_INTEGER','LONG','TIMESTAMP', |
|
129 | - 'INTERVAL','RAW','ROWID','UROWID','MLSLABEL','CLOB','NCLOB','BLOB','BFILE','XMLTYPE', |
|
128 | + 'DATE', 'VARCHAR', 'VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'NUMBER', 'PLS_INTEGER', 'BINARY_INTEGER', 'LONG', 'TIMESTAMP', |
|
129 | + 'INTERVAL', 'RAW', 'ROWID', 'UROWID', 'MLSLABEL', 'CLOB', 'NCLOB', 'BLOB', 'BFILE', 'XMLTYPE', |
|
130 | 130 | //SugarCRM reserved |
131 | 131 | 'ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID', |
132 | 132 | ); |
@@ -134,56 +134,56 @@ discard block |
||
134 | 134 | |
135 | 135 | //C.L. - Add support to mark related module id columns as reserved keywords |
136 | 136 | require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php'; |
137 | - $relatedModules = array_keys(DeployedRelationships::findRelatableModules()) ; |
|
137 | + $relatedModules = array_keys(DeployedRelationships::findRelatableModules()); |
|
138 | 138 | global $beanList, $current_language; |
139 | - foreach($relatedModules as $relModule) |
|
139 | + foreach ($relatedModules as $relModule) |
|
140 | 140 | { |
141 | - if(isset($beanList[$relModule])) |
|
141 | + if (isset($beanList[$relModule])) |
|
142 | 142 | { |
143 | - $field_name_exceptions[] = strtoupper($beanList[$relModule]) . '_ID'; |
|
143 | + $field_name_exceptions[] = strtoupper($beanList[$relModule]).'_ID'; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if(empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') { |
|
147 | + if (empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') { |
|
148 | 148 | $moduleName = $_REQUEST['view_module']; |
149 | 149 | $objectName = BeanFactory::getObjectName($moduleName); |
150 | 150 | $module = BeanFactory::getBean($moduleName); |
151 | 151 | |
152 | - VardefManager::loadVardef($moduleName, $objectName,true); |
|
152 | + VardefManager::loadVardef($moduleName, $objectName, true); |
|
153 | 153 | global $dictionary; |
154 | 154 | |
155 | 155 | // Fix for issue #1177 - when trying to add or edit fields in a module an error message is shown: |
156 | 156 | // "Warning: Creating default object from empty value" |
157 | - if(!isset($module->mbvardefs) || is_null($module->mbvardefs)) { |
|
157 | + if (!isset($module->mbvardefs) || is_null($module->mbvardefs)) { |
|
158 | 158 | $module->mbvardefs = new stdClass(); |
159 | 159 | } |
160 | - $module->mbvardefs->vardefs = $dictionary[$objectName]; |
|
160 | + $module->mbvardefs->vardefs = $dictionary[$objectName]; |
|
161 | 161 | |
162 | 162 | $module->name = $moduleName; |
163 | - if(!$ac){ |
|
163 | + if (!$ac) { |
|
164 | 164 | $ac = new AjaxCompose(); |
165 | 165 | } |
166 | - $vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name]))? $module->mbvardefs->vardefs['fields'][$field_name]: array(); |
|
167 | - if($isClone){ |
|
166 | + $vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name])) ? $module->mbvardefs->vardefs['fields'][$field_name] : array(); |
|
167 | + if ($isClone) { |
|
168 | 168 | unset($vardef['name']); |
169 | 169 | } |
170 | 170 | |
171 | - if(empty($vardef['name'])){ |
|
172 | - if(!empty($_REQUEST['type'])) |
|
171 | + if (empty($vardef['name'])) { |
|
172 | + if (!empty($_REQUEST['type'])) |
|
173 | 173 | $vardef['type'] = $_REQUEST['type']; |
174 | 174 | $fv->ss->assign('hideLevel', 0); |
175 | - }elseif(isset($vardef['custom_module'])){ |
|
175 | + }elseif (isset($vardef['custom_module'])) { |
|
176 | 176 | $fv->ss->assign('hideLevel', 2); |
177 | - }else{ |
|
177 | + } else { |
|
178 | 178 | $action = 'saveSugarField'; // tyoung - for OOB fields we currently only support modifying the label |
179 | 179 | $fv->ss->assign('hideLevel', 3); |
180 | 180 | } |
181 | - if($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime'){ |
|
181 | + if ($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime') { |
|
182 | 182 | $vardef['type'] = 'datetimecombo'; |
183 | 183 | } |
184 | 184 | |
185 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
186 | - $tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ; |
|
185 | + require_once ('modules/DynamicFields/FieldCases.php'); |
|
186 | + $tf = get_widget(empty($vardef ['type']) ? "" : $vardef ['type']); |
|
187 | 187 | $tf->module = $module; |
188 | 188 | $tf->populateFromRow($vardef); |
189 | 189 | $vardef = array_merge($vardef, $tf->get_field_def()); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | //Check if autoincrement fields are allowed |
195 | 195 | $allowAutoInc = true; |
196 | 196 | $enumFields = array(); |
197 | - foreach($module->field_defs as $field => $def) |
|
197 | + foreach ($module->field_defs as $field => $def) |
|
198 | 198 | { |
199 | 199 | if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) { |
200 | 200 | $allowAutoInc = false; |
@@ -202,56 +202,56 @@ discard block |
||
202 | 202 | } |
203 | 203 | if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) |
204 | 204 | { |
205 | - if(!empty($def['studio']) && $def['studio'] == "false") continue; //bug51866 |
|
205 | + if (!empty($def['studio']) && $def['studio'] == "false") continue; //bug51866 |
|
206 | 206 | $enumFields[$field] = translate($def['vname'], $moduleName); |
207 | 207 | if (substr($enumFields[$field], -1) == ":") |
208 | 208 | $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1); |
209 | 209 | } |
210 | 210 | } |
211 | - $fv->ss->assign( 'allowAutoInc', $allowAutoInc); |
|
211 | + $fv->ss->assign('allowAutoInc', $allowAutoInc); |
|
212 | 212 | |
213 | - $GLOBALS['log']->warn('view.modulefield: hidelevel '.$fv->ss->get_template_vars('hideLevel')." ".print_r($vardef,true)); |
|
214 | - if(!empty($vardef['vname'])){ |
|
213 | + $GLOBALS['log']->warn('view.modulefield: hidelevel '.$fv->ss->get_template_vars('hideLevel')." ".print_r($vardef, true)); |
|
214 | + if (!empty($vardef['vname'])) { |
|
215 | 215 | $fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8')); |
216 | 216 | } |
217 | 217 | $fv->ss->assign('module', $module); |
218 | - if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
218 | + if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
219 | 219 | $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
220 | 220 | |
221 | - $edit_or_add = 'editField' ; |
|
221 | + $edit_or_add = 'editField'; |
|
222 | 222 | |
223 | 223 | } else |
224 | 224 | { |
225 | 225 | require_once('modules/ModuleBuilder/MB/ModuleBuilder.php'); |
226 | 226 | $mb = new ModuleBuilder(); |
227 | 227 | $moduleName = $_REQUEST['view_module']; |
228 | - $module =& $mb->getPackageModule($_REQUEST['view_package'], $moduleName); |
|
229 | - $package =& $mb->packages[$_REQUEST['view_package']]; |
|
228 | + $module = & $mb->getPackageModule($_REQUEST['view_package'], $moduleName); |
|
229 | + $package = & $mb->packages[$_REQUEST['view_package']]; |
|
230 | 230 | $module->getVardefs(); |
231 | - if(!$ac){ |
|
231 | + if (!$ac) { |
|
232 | 232 | $ac = new AjaxCompose(); |
233 | 233 | } |
234 | - $vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name]))? $module->mbvardefs->vardefs['fields'][$field_name]: array(); |
|
234 | + $vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name])) ? $module->mbvardefs->vardefs['fields'][$field_name] : array(); |
|
235 | 235 | |
236 | - if($isClone){ |
|
236 | + if ($isClone) { |
|
237 | 237 | unset($vardef['name']); |
238 | 238 | } |
239 | 239 | |
240 | - if(empty($vardef['name'])){ |
|
241 | - if(!empty($_REQUEST['type']))$vardef['type'] = $_REQUEST['type']; |
|
240 | + if (empty($vardef['name'])) { |
|
241 | + if (!empty($_REQUEST['type']))$vardef['type'] = $_REQUEST['type']; |
|
242 | 242 | $fv->ss->assign('hideLevel', 0); |
243 | - }else{ |
|
244 | - if(!empty($module->mbvardefs->vardef['fields'][$vardef['name']])){ |
|
243 | + } else { |
|
244 | + if (!empty($module->mbvardefs->vardef['fields'][$vardef['name']])) { |
|
245 | 245 | $fv->ss->assign('hideLevel', 1); |
246 | - }elseif(isset($vardef['custom_module'])){ |
|
246 | + }elseif (isset($vardef['custom_module'])) { |
|
247 | 247 | $fv->ss->assign('hideLevel', 2); |
248 | - }else{ |
|
248 | + } else { |
|
249 | 249 | $fv->ss->assign('hideLevel', 3); // tyoung bug 17350 - effectively mark template derived fields as readonly |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
254 | - $tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ; |
|
253 | + require_once ('modules/DynamicFields/FieldCases.php'); |
|
254 | + $tf = get_widget(empty($vardef ['type']) ? "" : $vardef ['type']); |
|
255 | 255 | $tf->module = $module; |
256 | 256 | $tf->populateFromRow($vardef); |
257 | 257 | $vardef = array_merge($vardef, $tf->get_field_def()); |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | |
261 | 261 | $fv->ss->assign('module', $module); |
262 | 262 | $fv->ss->assign('package', $package); |
263 | - $fv->ss->assign('MB','1'); |
|
263 | + $fv->ss->assign('MB', '1'); |
|
264 | 264 | |
265 | - if(isset($vardef['vname'])) |
|
266 | - $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8')); |
|
267 | - if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
265 | + if (isset($vardef['vname'])) |
|
266 | + $fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us', $vardef['vname']), ENT_QUOTES, 'UTF-8')); |
|
267 | + if (empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent')) |
|
268 | 268 | $field_types['parent'] = $GLOBALS['mod_strings']['parent']; |
269 | 269 | |
270 | 270 | $enumFields = array(); |
271 | 271 | if (!empty($module->mbvardefs->vardefs['fields'])) |
272 | 272 | { |
273 | - foreach($module->mbvardefs->vardefs['fields'] as $field => $def) |
|
273 | + foreach ($module->mbvardefs->vardefs['fields'] as $field => $def) |
|
274 | 274 | { |
275 | 275 | if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) |
276 | 276 | { |
277 | 277 | $enumFields[$field] = isset($module->mblanguage->strings[$current_language][$def['vname']]) ? |
278 | 278 | $this->mbModule->mblanguage->strings[$current_language][$def['vname']] : translate($field); |
279 | 279 | if (substr($enumFields[$field], -1) == ":") |
280 | - $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) -1); |
|
280 | + $enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $edit_or_add = 'mbeditField'; |
286 | 286 | } |
287 | 287 | |
288 | - if($_REQUEST['action'] == 'RefreshField'){ |
|
288 | + if ($_REQUEST['action'] == 'RefreshField') { |
|
289 | 289 | require_once('modules/DynamicFields/FieldCases.php'); |
290 | 290 | $field = get_widget($_POST['type']); |
291 | 291 | $field->populateFromPost(); |
@@ -294,52 +294,52 @@ discard block |
||
294 | 294 | $fv->ss->assign('lbl_value', htmlentities($_REQUEST['labelValue'], ENT_QUOTES, 'UTF-8')); |
295 | 295 | } |
296 | 296 | |
297 | - foreach(array("formula", "default", "comments", "help", "visiblityGrid") as $toEscape) |
|
297 | + foreach (array("formula", "default", "comments", "help", "visiblityGrid") as $toEscape) |
|
298 | 298 | { |
299 | 299 | if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) { |
300 | 300 | $vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8'); |
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - if((!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true) |
|
304 | + if ((!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true) |
|
305 | 305 | || (strcmp($field_name, "name") == 0) || (isset($vardef['type']) && $vardef['type'] == 'name')) // bug #35767, do not allow cloning of name field |
306 | 306 | { |
307 | 307 | $fv->ss->assign('no_duplicate', true); |
308 | 308 | } |
309 | 309 | |
310 | - $fv->ss->assign('action',$action); |
|
310 | + $fv->ss->assign('action', $action); |
|
311 | 311 | $fv->ss->assign('isClone', ($isClone ? 1 : 0)); |
312 | 312 | $fv->ss->assign("module_dd_fields", $enumFields); |
313 | 313 | $json = getJSONobj(); |
314 | 314 | |
315 | 315 | $fv->ss->assign('field_name_exceptions', $json->encode($field_name_exceptions)); |
316 | 316 | ksort($field_types); |
317 | - $fv->ss->assign('field_types',$field_types); |
|
317 | + $fv->ss->assign('field_types', $field_types); |
|
318 | 318 | |
319 | 319 | |
320 | 320 | $fv->ss->assign('importable_options', $GLOBALS['app_list_strings']['custom_fields_importable_dom']); |
321 | 321 | $fv->ss->assign('duplicate_merge_options', $GLOBALS['app_list_strings']['custom_fields_merge_dup_dom']); |
322 | 322 | |
323 | - $triggers = array () ; |
|
324 | - $existing_field_names = array () ; |
|
325 | - foreach ( $module->mbvardefs->vardefs['fields'] as $field ) |
|
323 | + $triggers = array(); |
|
324 | + $existing_field_names = array(); |
|
325 | + foreach ($module->mbvardefs->vardefs['fields'] as $field) |
|
326 | 326 | { |
327 | - if ($field [ 'type' ] == 'enum' || $field [ 'type'] == 'multienum' ) |
|
327 | + if ($field ['type'] == 'enum' || $field ['type'] == 'multienum') |
|
328 | 328 | { |
329 | - $triggers [] = $field [ 'name' ] ; |
|
329 | + $triggers [] = $field ['name']; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | if (!isset($field['source']) || $field['source'] != 'non-db') { |
333 | - if(preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) |
|
333 | + if (preg_match('/^(.*?)(_c)?$/', $field['name'], $matches)) |
|
334 | 334 | { |
335 | 335 | $existing_field_names [] = strtoupper($matches[1]); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - $fv->ss->assign('triggers',$triggers); |
|
340 | + $fv->ss->assign('triggers', $triggers); |
|
341 | 341 | $fv->ss->assign('existing_field_names', $json->encode($existing_field_names)); |
342 | - $fv->ss->assign('mod_strings',$GLOBALS['mod_strings']); |
|
342 | + $fv->ss->assign('mod_strings', $GLOBALS['mod_strings']); |
|
343 | 343 | |
344 | 344 | // jchi #24880 |
345 | 345 | // end |
@@ -348,21 +348,21 @@ discard block |
||
348 | 348 | $layout = $fv->getLayout($vardef); |
349 | 349 | |
350 | 350 | $fv->ss->assign('fieldLayout', $layout); |
351 | - if(empty($vardef['type'])) |
|
351 | + if (empty($vardef['type'])) |
|
352 | 352 | { |
353 | 353 | $vardef['type'] = 'varchar'; |
354 | 354 | } |
355 | 355 | |
356 | 356 | $fv->ss->assign('vardef', $vardef); |
357 | 357 | |
358 | - if(empty($_REQUEST['field'])){ |
|
358 | + if (empty($_REQUEST['field'])) { |
|
359 | 359 | $edit_or_add = 'addField'; |
360 | 360 | } |
361 | 361 | |
362 | 362 | $fv->ss->assign('help_group', $edit_or_add); |
363 | 363 | |
364 | 364 | // Fix for case 2183 - the form in the field.tpl needs to know whether it is an update |
365 | - if($field_name == '') { |
|
365 | + if ($field_name == '') { |
|
366 | 366 | $is_update = false; |
367 | 367 | } else { |
368 | 368 | $is_update = true; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $fv->ss->assign('is_update', $is_update); |
371 | 371 | |
372 | 372 | $body = $this->fetchTemplate($fv, 'modules/ModuleBuilder/tpls/MBModule/field.tpl'); |
373 | - $ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR','ModuleBuilder'), $body ); |
|
373 | + $ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR', 'ModuleBuilder'), $body); |
|
374 | 374 | return $ac; |
375 | 375 | } |
376 | 376 |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | |
43 | 43 | class Viewdeletepackage extends SugarView |
44 | 44 | { |
45 | - /** |
|
46 | - * @see SugarView::_getModuleTitleParams() |
|
47 | - */ |
|
48 | - protected function _getModuleTitleParams($browserTitle = false) |
|
49 | - { |
|
50 | - global $mod_strings; |
|
45 | + /** |
|
46 | + * @see SugarView::_getModuleTitleParams() |
|
47 | + */ |
|
48 | + protected function _getModuleTitleParams($browserTitle = false) |
|
49 | + { |
|
50 | + global $mod_strings; |
|
51 | 51 | |
52 | - return array( |
|
53 | - translate('LBL_MODULE_NAME','Administration'), |
|
54 | - ModuleBuilderController::getModuleTitle(), |
|
55 | - ); |
|
52 | + return array( |
|
53 | + translate('LBL_MODULE_NAME','Administration'), |
|
54 | + ModuleBuilderController::getModuleTitle(), |
|
55 | + ); |
|
56 | 56 | } |
57 | 57 | |
58 | - function display() |
|
58 | + function display() |
|
59 | 59 | { |
60 | 60 | global $mod_strings; |
61 | 61 | |
@@ -63,5 +63,5 @@ discard block |
||
63 | 63 | $ajax->addSection('center', $mod_strings['LBL_PACKAGE_DELETED'], |
64 | 64 | str_replace('[[package]]',$_REQUEST['package'],$mod_strings['LBL_PACKAGE_WAS_DELETED'])); |
65 | 65 | echo $ajax->getJavascript(); |
66 | - } |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | global $mod_strings; |
51 | 51 | |
52 | 52 | return array( |
53 | - translate('LBL_MODULE_NAME','Administration'), |
|
53 | + translate('LBL_MODULE_NAME', 'Administration'), |
|
54 | 54 | ModuleBuilderController::getModuleTitle(), |
55 | 55 | ); |
56 | 56 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $ajax = new AjaxCompose(); |
63 | 63 | $ajax->addSection('center', $mod_strings['LBL_PACKAGE_DELETED'], |
64 | - str_replace('[[package]]',$_REQUEST['package'],$mod_strings['LBL_PACKAGE_WAS_DELETED'])); |
|
64 | + str_replace('[[package]]', $_REQUEST['package'], $mod_strings['LBL_PACKAGE_WAS_DELETED'])); |
|
65 | 65 | echo $ajax->getJavascript(); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -40,51 +40,51 @@ |
||
40 | 40 | require_once('modules/ModuleBuilder/MB/AjaxCompose.php'); |
41 | 41 | class ViewHome extends SugarView |
42 | 42 | { |
43 | - /** |
|
44 | - * @see SugarView::_getModuleTitleParams() |
|
45 | - */ |
|
46 | - protected function _getModuleTitleParams($browserTitle = false) |
|
47 | - { |
|
48 | - global $mod_strings; |
|
43 | + /** |
|
44 | + * @see SugarView::_getModuleTitleParams() |
|
45 | + */ |
|
46 | + protected function _getModuleTitleParams($browserTitle = false) |
|
47 | + { |
|
48 | + global $mod_strings; |
|
49 | 49 | |
50 | - return array( |
|
51 | - translate('LBL_MODULE_NAME','Administration'), |
|
52 | - ModuleBuilderController::getModuleTitle(), |
|
53 | - ); |
|
50 | + return array( |
|
51 | + translate('LBL_MODULE_NAME','Administration'), |
|
52 | + ModuleBuilderController::getModuleTitle(), |
|
53 | + ); |
|
54 | 54 | } |
55 | 55 | |
56 | - function display() |
|
57 | - { |
|
58 | - global $current_user; |
|
59 | - global $mod_strings; |
|
60 | - $smarty = new Sugar_Smarty(); |
|
61 | - $smarty->assign('title' , $mod_strings['LBL_DEVELOPER_TOOLS']); |
|
62 | - $smarty->assign('question', $mod_strings['LBL_QUESTION_EDITOR']); |
|
63 | - $smarty->assign('defaultHelp', 'mainHelp'); |
|
64 | - $this->generateHomeButtons(); |
|
65 | - $smarty->assign('buttons', $this->buttons); |
|
66 | - $assistant=array('group'=>'main', 'key'=>'welcome'); |
|
67 | - $smarty->assign('assistant',$assistant); |
|
68 | - //initialize Assistant's display property. |
|
69 | - $userPref = $current_user->getPreference('mb_assist', 'Assistant'); |
|
70 | - if(!$userPref) $userPref="na"; |
|
71 | - $smarty->assign('userPref',$userPref); |
|
72 | - $ajax = new AjaxCompose(); |
|
73 | - $ajax->addSection('center', $mod_strings['LBL_HOME'],$smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); |
|
74 | - echo $ajax->getJavascript(); |
|
75 | - } |
|
56 | + function display() |
|
57 | + { |
|
58 | + global $current_user; |
|
59 | + global $mod_strings; |
|
60 | + $smarty = new Sugar_Smarty(); |
|
61 | + $smarty->assign('title' , $mod_strings['LBL_DEVELOPER_TOOLS']); |
|
62 | + $smarty->assign('question', $mod_strings['LBL_QUESTION_EDITOR']); |
|
63 | + $smarty->assign('defaultHelp', 'mainHelp'); |
|
64 | + $this->generateHomeButtons(); |
|
65 | + $smarty->assign('buttons', $this->buttons); |
|
66 | + $assistant=array('group'=>'main', 'key'=>'welcome'); |
|
67 | + $smarty->assign('assistant',$assistant); |
|
68 | + //initialize Assistant's display property. |
|
69 | + $userPref = $current_user->getPreference('mb_assist', 'Assistant'); |
|
70 | + if(!$userPref) $userPref="na"; |
|
71 | + $smarty->assign('userPref',$userPref); |
|
72 | + $ajax = new AjaxCompose(); |
|
73 | + $ajax->addSection('center', $mod_strings['LBL_HOME'],$smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); |
|
74 | + echo $ajax->getJavascript(); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - function generateHomeButtons() |
|
79 | - { |
|
80 | - global $current_user; |
|
78 | + function generateHomeButtons() |
|
79 | + { |
|
80 | + global $current_user; |
|
81 | 81 | if(displayStudioForCurrentUser() == true) { |
82 | - //$this->buttons['Application'] = array ('action' => '', 'imageTitle' => 'Application', 'size' => '128', 'help'=>'appBtn'); |
|
83 | - $this->buttons[$GLOBALS['mod_strings']['LBL_STUDIO']] = array ('action' => 'javascript:ModuleBuilder.main("studio")', 'imageTitle' => 'Studio', 'size' => '128', 'help'=>'studioBtn'); |
|
82 | + //$this->buttons['Application'] = array ('action' => '', 'imageTitle' => 'Application', 'size' => '128', 'help'=>'appBtn'); |
|
83 | + $this->buttons[$GLOBALS['mod_strings']['LBL_STUDIO']] = array ('action' => 'javascript:ModuleBuilder.main("studio")', 'imageTitle' => 'Studio', 'size' => '128', 'help'=>'studioBtn'); |
|
84 | 84 | } |
85 | 85 | if(is_admin($current_user)) { |
86 | - $this->buttons[$GLOBALS['mod_strings']['LBL_MODULEBUILDER']] = array ('action' => 'javascript:ModuleBuilder.main("mb")', 'imageTitle' => 'ModuleBuilder', 'size' => '128', 'help'=>'mbBtn'); |
|
86 | + $this->buttons[$GLOBALS['mod_strings']['LBL_MODULEBUILDER']] = array ('action' => 'javascript:ModuleBuilder.main("mb")', 'imageTitle' => 'ModuleBuilder', 'size' => '128', 'help'=>'mbBtn'); |
|
87 | 87 | } |
88 | - $this->buttons[$GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR']] = array ('action' => 'javascript:ModuleBuilder.main("dropdowns")', 'imageTitle' => $GLOBALS['mod_strings']['LBL_HOME_EDIT_DROPDOWNS'], 'imageName' => 'DropDownEditor', 'size' => '128', 'help'=>'dropDownEditorBtn'); |
|
89 | - } |
|
88 | + $this->buttons[$GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR']] = array ('action' => 'javascript:ModuleBuilder.main("dropdowns")', 'imageTitle' => $GLOBALS['mod_strings']['LBL_HOME_EDIT_DROPDOWNS'], 'imageName' => 'DropDownEditor', 'size' => '128', 'help'=>'dropDownEditorBtn'); |
|
89 | + } |
|
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | global $mod_strings; |
49 | 49 | |
50 | 50 | return array( |
51 | - translate('LBL_MODULE_NAME','Administration'), |
|
51 | + translate('LBL_MODULE_NAME', 'Administration'), |
|
52 | 52 | ModuleBuilderController::getModuleTitle(), |
53 | 53 | ); |
54 | 54 | } |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | global $current_user; |
59 | 59 | global $mod_strings; |
60 | 60 | $smarty = new Sugar_Smarty(); |
61 | - $smarty->assign('title' , $mod_strings['LBL_DEVELOPER_TOOLS']); |
|
61 | + $smarty->assign('title', $mod_strings['LBL_DEVELOPER_TOOLS']); |
|
62 | 62 | $smarty->assign('question', $mod_strings['LBL_QUESTION_EDITOR']); |
63 | 63 | $smarty->assign('defaultHelp', 'mainHelp'); |
64 | 64 | $this->generateHomeButtons(); |
65 | 65 | $smarty->assign('buttons', $this->buttons); |
66 | - $assistant=array('group'=>'main', 'key'=>'welcome'); |
|
67 | - $smarty->assign('assistant',$assistant); |
|
66 | + $assistant = array('group'=>'main', 'key'=>'welcome'); |
|
67 | + $smarty->assign('assistant', $assistant); |
|
68 | 68 | //initialize Assistant's display property. |
69 | 69 | $userPref = $current_user->getPreference('mb_assist', 'Assistant'); |
70 | - if(!$userPref) $userPref="na"; |
|
71 | - $smarty->assign('userPref',$userPref); |
|
70 | + if (!$userPref) $userPref = "na"; |
|
71 | + $smarty->assign('userPref', $userPref); |
|
72 | 72 | $ajax = new AjaxCompose(); |
73 | - $ajax->addSection('center', $mod_strings['LBL_HOME'],$smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); |
|
73 | + $ajax->addSection('center', $mod_strings['LBL_HOME'], $smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); |
|
74 | 74 | echo $ajax->getJavascript(); |
75 | 75 | } |
76 | 76 | |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | function generateHomeButtons() |
79 | 79 | { |
80 | 80 | global $current_user; |
81 | - if(displayStudioForCurrentUser() == true) { |
|
81 | + if (displayStudioForCurrentUser() == true) { |
|
82 | 82 | //$this->buttons['Application'] = array ('action' => '', 'imageTitle' => 'Application', 'size' => '128', 'help'=>'appBtn'); |
83 | - $this->buttons[$GLOBALS['mod_strings']['LBL_STUDIO']] = array ('action' => 'javascript:ModuleBuilder.main("studio")', 'imageTitle' => 'Studio', 'size' => '128', 'help'=>'studioBtn'); |
|
83 | + $this->buttons[$GLOBALS['mod_strings']['LBL_STUDIO']] = array('action' => 'javascript:ModuleBuilder.main("studio")', 'imageTitle' => 'Studio', 'size' => '128', 'help'=>'studioBtn'); |
|
84 | 84 | } |
85 | - if(is_admin($current_user)) { |
|
86 | - $this->buttons[$GLOBALS['mod_strings']['LBL_MODULEBUILDER']] = array ('action' => 'javascript:ModuleBuilder.main("mb")', 'imageTitle' => 'ModuleBuilder', 'size' => '128', 'help'=>'mbBtn'); |
|
85 | + if (is_admin($current_user)) { |
|
86 | + $this->buttons[$GLOBALS['mod_strings']['LBL_MODULEBUILDER']] = array('action' => 'javascript:ModuleBuilder.main("mb")', 'imageTitle' => 'ModuleBuilder', 'size' => '128', 'help'=>'mbBtn'); |
|
87 | 87 | } |
88 | - $this->buttons[$GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR']] = array ('action' => 'javascript:ModuleBuilder.main("dropdowns")', 'imageTitle' => $GLOBALS['mod_strings']['LBL_HOME_EDIT_DROPDOWNS'], 'imageName' => 'DropDownEditor', 'size' => '128', 'help'=>'dropDownEditorBtn'); |
|
88 | + $this->buttons[$GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR']] = array('action' => 'javascript:ModuleBuilder.main("dropdowns")', 'imageTitle' => $GLOBALS['mod_strings']['LBL_HOME_EDIT_DROPDOWNS'], 'imageName' => 'DropDownEditor', 'size' => '128', 'help'=>'dropDownEditorBtn'); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -67,7 +67,9 @@ |
||
67 | 67 | $smarty->assign('assistant',$assistant); |
68 | 68 | //initialize Assistant's display property. |
69 | 69 | $userPref = $current_user->getPreference('mb_assist', 'Assistant'); |
70 | - if(!$userPref) $userPref="na"; |
|
70 | + if(!$userPref) { |
|
71 | + $userPref="na"; |
|
72 | + } |
|
71 | 73 | $smarty->assign('userPref',$userPref); |
72 | 74 | $ajax = new AjaxCompose(); |
73 | 75 | $ajax->addSection('center', $mod_strings['LBL_HOME'],$smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | 3 | die ( 'Not A Valid Entry Point' ) ; |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -60,8 +61,9 @@ discard block |
||
60 | 61 | $bean_name = get_valid_bean_name($this->module); |
61 | 62 | $dictionary = array($bean_name => array("fields" => array($field => array()))); |
62 | 63 | include("$this->base_path/sugarfield_$field.php"); |
63 | - if (!empty($dictionary[$bean_name]) && isset($dictionary[$bean_name]["fields"][$field])) |
|
64 | - $this->custom_def = $dictionary[$bean_name]["fields"][$field]; |
|
64 | + if (!empty($dictionary[$bean_name]) && isset($dictionary[$bean_name]["fields"][$field])) { |
|
65 | + $this->custom_def = $dictionary[$bean_name]["fields"][$field]; |
|
66 | + } |
|
65 | 67 | } |
66 | 68 | } |
67 | 69 | |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | { |
72 | 74 | $dictionary = array(); |
73 | 75 | include("modules/{$this->module}/vardefs.php"); |
74 | - if (!empty($dictionary[$beanList[$this->module]]) && isset($dictionary[$beanList[$this->module]]["fields"][$field])) |
|
75 | - $this->base_def = $dictionary[$beanList[$this->module]]["fields"][$field]; |
|
76 | + if (!empty($dictionary[$beanList[$this->module]]) && isset($dictionary[$beanList[$this->module]]["fields"][$field])) { |
|
77 | + $this->base_def = $dictionary[$beanList[$this->module]]["fields"][$field]; |
|
78 | + } |
|
76 | 79 | } |
77 | 80 | } |
78 | 81 | |
@@ -86,13 +89,15 @@ discard block |
||
86 | 89 | global $dictionary, $beanList; |
87 | 90 | |
88 | 91 | |
89 | - if (empty($beanList[$this->module])) |
|
90 | - return false; |
|
92 | + if (empty($beanList[$this->module])) { |
|
93 | + return false; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $bean_name = get_valid_bean_name($this->module); |
93 | 97 | |
94 | - if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) |
|
95 | - return false; |
|
98 | + if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) { |
|
99 | + return false; |
|
100 | + } |
|
96 | 101 | |
97 | 102 | $currdef = $dictionary[$bean_name]["fields"][$field->name]; |
98 | 103 | |
@@ -120,8 +125,9 @@ discard block |
||
120 | 125 | |
121 | 126 | if ($property == "action" || $property == "label_value" || $property == "label" |
122 | 127 | || ((substr($property, 0,3) == 'ext' && strlen($property) == 4)) |
123 | - ) |
|
124 | - continue; |
|
128 | + ) { |
|
129 | + continue; |
|
130 | + } |
|
125 | 131 | |
126 | 132 | // Bug 37043 - Avoid writing out vardef defintions that are the default value. |
127 | 133 | if (isset($newDef[$property]) && |
@@ -134,26 +140,29 @@ discard block |
||
134 | 140 | } |
135 | 141 | |
136 | 142 | //Remove any orphaned entries |
137 | - if (isset($this->custom_def[$property]) && !isset($newDef[$property])) |
|
138 | - unset($this->custom_def[$property]); |
|
143 | + if (isset($this->custom_def[$property]) && !isset($newDef[$property])) { |
|
144 | + unset($this->custom_def[$property]); |
|
145 | + } |
|
139 | 146 | |
140 | 147 | //Handle overrides of out of the box definitions with empty |
141 | 148 | if (!empty($this->base_def[$property]) && !isset($newDef[$property])) |
142 | 149 | { |
143 | 150 | //Switch on type of the property to find what the correct 'empty' is. |
144 | - if(is_string($this->base_def[$property])) |
|
145 | - $this->custom_def[$property] = ""; |
|
146 | - else if(is_array($this->base_def[$property])) |
|
147 | - $this->custom_def[$property] = array(); |
|
148 | - else if(is_bool($this->base_def[$property])) |
|
149 | - $this->custom_def[$property] = false; |
|
150 | - else |
|
151 | - $this->custom_def[$property] = null; |
|
151 | + if(is_string($this->base_def[$property])) { |
|
152 | + $this->custom_def[$property] = ""; |
|
153 | + } else if(is_array($this->base_def[$property])) { |
|
154 | + $this->custom_def[$property] = array(); |
|
155 | + } else if(is_bool($this->base_def[$property])) { |
|
156 | + $this->custom_def[$property] = false; |
|
157 | + } else { |
|
158 | + $this->custom_def[$property] = null; |
|
159 | + } |
|
152 | 160 | } |
153 | 161 | } |
154 | 162 | |
155 | - if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) |
|
156 | - unset($this->custom_def["duplicate_merge_dom_value"]); |
|
163 | + if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) { |
|
164 | + unset($this->custom_def["duplicate_merge_dom_value"]); |
|
165 | + } |
|
157 | 166 | |
158 | 167 | $this->writeVardefExtension($bean_name, $field, $this->custom_def); |
159 | 168 | } |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | |
45 | 45 | class StandardField extends DynamicField |
46 | 46 | { |
47 | - var $custom_def = array(); |
|
48 | - var $base_def = array(); |
|
49 | - var $baseField; |
|
47 | + var $custom_def = array(); |
|
48 | + var $base_def = array(); |
|
49 | + var $baseField; |
|
50 | 50 | |
51 | 51 | protected function loadCustomDef($field){ |
52 | - global $beanList; |
|
53 | - if (!empty($beanList[$this->module]) && is_file("custom/Extension/modules/{$this->module}/Ext/Vardefs/sugarfield_$field.php")) |
|
54 | - { |
|
52 | + global $beanList; |
|
53 | + if (!empty($beanList[$this->module]) && is_file("custom/Extension/modules/{$this->module}/Ext/Vardefs/sugarfield_$field.php")) |
|
54 | + { |
|
55 | 55 | $bean_name = get_valid_bean_name($this->module); |
56 | 56 | $dictionary = array($bean_name => array("fields" => array($field => array()))); |
57 | 57 | include("$this->base_path/sugarfield_$field.php"); |
58 | 58 | if (!empty($dictionary[$bean_name]) && isset($dictionary[$bean_name]["fields"][$field])) |
59 | 59 | $this->custom_def = $dictionary[$bean_name]["fields"][$field]; |
60 | - } |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | protected function loadBaseDef($field){ |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | $this->baseField = get_widget ( $field->type) ; |
114 | 114 | foreach ($field->vardef_map as $property => $fmd_col){ |
115 | 115 | |
116 | - if ($property == "action" || $property == "label_value" || $property == "label" |
|
117 | - || ((substr($property, 0,3) == 'ext' && strlen($property) == 4)) |
|
116 | + if ($property == "action" || $property == "label_value" || $property == "label" |
|
117 | + || ((substr($property, 0,3) == 'ext' && strlen($property) == 4)) |
|
118 | 118 | ) |
119 | - continue; |
|
119 | + continue; |
|
120 | 120 | |
121 | 121 | // Bug 37043 - Avoid writing out vardef defintions that are the default value. |
122 | 122 | if (isset($newDef[$property]) && |
123 | - ((!isset($currdef[$property]) && !$this->isDefaultValue($property,$newDef[$property], $this->baseField)) |
|
124 | - || (isset($currdef[$property]) && $currdef[$property] != $newDef[$property]) |
|
125 | - ) |
|
123 | + ((!isset($currdef[$property]) && !$this->isDefaultValue($property,$newDef[$property], $this->baseField)) |
|
124 | + || (isset($currdef[$property]) && $currdef[$property] != $newDef[$property]) |
|
125 | + ) |
|
126 | 126 | ){ |
127 | - $this->custom_def[$property] = |
|
127 | + $this->custom_def[$property] = |
|
128 | 128 | is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property]; |
129 | 129 | } |
130 | 130 | |
131 | 131 | //Remove any orphaned entries |
132 | 132 | if (isset($this->custom_def[$property]) && !isset($newDef[$property])) |
133 | - unset($this->custom_def[$property]); |
|
133 | + unset($this->custom_def[$property]); |
|
134 | 134 | |
135 | 135 | //Handle overrides of out of the box definitions with empty |
136 | 136 | if (!empty($this->base_def[$property]) && !isset($newDef[$property])) |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) |
151 | - unset($this->custom_def["duplicate_merge_dom_value"]); |
|
151 | + unset($this->custom_def["duplicate_merge_dom_value"]); |
|
152 | 152 | |
153 | 153 | $this->writeVardefExtension($bean_name, $field, $this->custom_def); |
154 | 154 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | - die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | + die ('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ********************************************************************************/ |
41 | 41 | |
42 | 42 | |
43 | -require_once ('modules/DynamicFields/DynamicField.php') ; |
|
43 | +require_once ('modules/DynamicFields/DynamicField.php'); |
|
44 | 44 | |
45 | 45 | class StandardField extends DynamicField |
46 | 46 | { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | var $base_def = array(); |
49 | 49 | var $baseField; |
50 | 50 | |
51 | - protected function loadCustomDef($field){ |
|
51 | + protected function loadCustomDef($field) { |
|
52 | 52 | global $beanList; |
53 | 53 | if (!empty($beanList[$this->module]) && is_file("custom/Extension/modules/{$this->module}/Ext/Vardefs/sugarfield_$field.php")) |
54 | 54 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - protected function loadBaseDef($field){ |
|
63 | + protected function loadBaseDef($field) { |
|
64 | 64 | global $beanList; |
65 | 65 | if (!empty($beanList[$this->module]) && is_file("modules/{$this->module}/vardefs.php")) |
66 | 66 | { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param Field Object $field |
78 | 78 | * @return boolean |
79 | 79 | */ |
80 | - function addFieldObject(&$field){ |
|
80 | + function addFieldObject(&$field) { |
|
81 | 81 | global $dictionary, $beanList; |
82 | 82 | |
83 | 83 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | |
94 | 94 | // set $field->unified_search=true if field supports unified search |
95 | 95 | // regarding #51427 |
96 | - if($field->supports_unified_search) |
|
96 | + if ($field->supports_unified_search) |
|
97 | 97 | { |
98 | - if(isset($dictionary[$bean_name]['unified_search_default_enabled']) && isset($dictionary[$bean_name]['unified_search']) |
|
98 | + if (isset($dictionary[$bean_name]['unified_search_default_enabled']) && isset($dictionary[$bean_name]['unified_search']) |
|
99 | 99 | && $dictionary[$bean_name]['unified_search_default_enabled'] && $dictionary[$bean_name]['unified_search']) |
100 | 100 | { |
101 | 101 | $currdef['unified_search'] = $field->unified_search = isset($currdef['unified_search']) |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | $this->loadBaseDef($field->name); |
110 | 110 | $newDef = $field->get_field_def(); |
111 | 111 | |
112 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
113 | - $this->baseField = get_widget ( $field->type) ; |
|
114 | - foreach ($field->vardef_map as $property => $fmd_col){ |
|
112 | + require_once ('modules/DynamicFields/FieldCases.php'); |
|
113 | + $this->baseField = get_widget($field->type); |
|
114 | + foreach ($field->vardef_map as $property => $fmd_col) { |
|
115 | 115 | |
116 | 116 | if ($property == "action" || $property == "label_value" || $property == "label" |
117 | - || ((substr($property, 0,3) == 'ext' && strlen($property) == 4)) |
|
117 | + || ((substr($property, 0, 3) == 'ext' && strlen($property) == 4)) |
|
118 | 118 | ) |
119 | 119 | continue; |
120 | 120 | |
121 | 121 | // Bug 37043 - Avoid writing out vardef defintions that are the default value. |
122 | 122 | if (isset($newDef[$property]) && |
123 | - ((!isset($currdef[$property]) && !$this->isDefaultValue($property,$newDef[$property], $this->baseField)) |
|
123 | + ((!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField)) |
|
124 | 124 | || (isset($currdef[$property]) && $currdef[$property] != $newDef[$property]) |
125 | 125 | ) |
126 | - ){ |
|
126 | + ) { |
|
127 | 127 | $this->custom_def[$property] = |
128 | 128 | is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property]; |
129 | 129 | } |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | if (!empty($this->base_def[$property]) && !isset($newDef[$property])) |
137 | 137 | { |
138 | 138 | //Switch on type of the property to find what the correct 'empty' is. |
139 | - if(is_string($this->base_def[$property])) |
|
139 | + if (is_string($this->base_def[$property])) |
|
140 | 140 | $this->custom_def[$property] = ""; |
141 | - else if(is_array($this->base_def[$property])) |
|
141 | + else if (is_array($this->base_def[$property])) |
|
142 | 142 | $this->custom_def[$property] = array(); |
143 | - else if(is_bool($this->base_def[$property])) |
|
143 | + else if (is_bool($this->base_def[$property])) |
|
144 | 144 | $this->custom_def[$property] = false; |
145 | 145 | else |
146 | 146 | $this->custom_def[$property] = null; |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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-One Relationship |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * Constructor |
72 | 72 | * @param array $definition Parameters passed in as array with keys defined in parent::keys |
73 | 73 | */ |
74 | - function __construct ($definition) |
|
74 | + function __construct($definition) |
|
75 | 75 | { |
76 | - parent::__construct ( $definition ) ; |
|
76 | + parent::__construct($definition); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /* |
@@ -83,55 +83,55 @@ discard block |
||
83 | 83 | /* |
84 | 84 | * @return array An array of relationship metadata definitions |
85 | 85 | */ |
86 | - function buildRelationshipMetaData () |
|
86 | + function buildRelationshipMetaData() |
|
87 | 87 | { |
88 | - return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_ONETOONE ) ) ; |
|
88 | + return array($this->lhs_module => $this->getRelationshipMetaData(MB_ONETOONE)); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /* Build a set of Link Field definitions for this relationship |
92 | 92 | * @return array An array of field definitions, ready for the vardefs, keyed by module |
93 | 93 | */ |
94 | - function buildVardefs ( ) |
|
94 | + function buildVardefs( ) |
|
95 | 95 | { |
96 | - $vardefs = array ( ) ; |
|
97 | - $vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name , false, |
|
98 | - 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' , |
|
99 | - $this->relationship_only ? false : $this->getIDName( $this->lhs_module ) |
|
100 | - ) ; |
|
101 | - $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, false, |
|
102 | - 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' , |
|
103 | - $this->relationship_only ? false : $this->getIDName( $this->rhs_module ) |
|
104 | - ) ; |
|
96 | + $vardefs = array( ); |
|
97 | + $vardefs [$this->rhs_module] [] = $this->getLinkFieldDefinition($this->lhs_module, $this->relationship_name, false, |
|
98 | + 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE', |
|
99 | + $this->relationship_only ? false : $this->getIDName($this->lhs_module) |
|
100 | + ); |
|
101 | + $vardefs [$this->lhs_module] [] = $this->getLinkFieldDefinition($this->rhs_module, $this->relationship_name, false, |
|
102 | + 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE', |
|
103 | + $this->relationship_only ? false : $this->getIDName($this->rhs_module) |
|
104 | + ); |
|
105 | 105 | |
106 | 106 | if (!$this->relationship_only) |
107 | 107 | { |
108 | - $vardefs [ $this->lhs_module ] [] = $this->getRelateFieldDefinition ( $this->rhs_module, $this->relationship_name, $this->getRightModuleSystemLabel() ) ; |
|
109 | - $vardefs [ $this->rhs_module ] [] = $this->getRelateFieldDefinition ( $this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel() ) ; |
|
110 | - $vardefs [ $this->lhs_module ] [] = $this->getLink2FieldDefinition ( $this->rhs_module, $this->relationship_name , false, |
|
111 | - 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ) ; |
|
112 | - $vardefs [ $this->rhs_module ] [] = $this->getLink2FieldDefinition ( $this->lhs_module, $this->relationship_name , false, |
|
113 | - 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ) ; |
|
108 | + $vardefs [$this->lhs_module] [] = $this->getRelateFieldDefinition($this->rhs_module, $this->relationship_name, $this->getRightModuleSystemLabel()); |
|
109 | + $vardefs [$this->rhs_module] [] = $this->getRelateFieldDefinition($this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel()); |
|
110 | + $vardefs [$this->lhs_module] [] = $this->getLink2FieldDefinition($this->rhs_module, $this->relationship_name, false, |
|
111 | + 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE'); |
|
112 | + $vardefs [$this->rhs_module] [] = $this->getLink2FieldDefinition($this->lhs_module, $this->relationship_name, false, |
|
113 | + 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE'); |
|
114 | 114 | } |
115 | 115 | |
116 | - return $vardefs ; |
|
116 | + return $vardefs; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /* |
120 | 120 | * Define what fields to add to which modules layouts |
121 | 121 | * @return array An array of module => fieldname |
122 | 122 | */ |
123 | - function buildFieldsToLayouts () |
|
123 | + function buildFieldsToLayouts() |
|
124 | 124 | { |
125 | 125 | if ($this->relationship_only) |
126 | - return array () ; |
|
126 | + return array(); |
|
127 | 127 | |
128 | 128 | if ($this->lhs_module == $this->rhs_module) // don't add in two fields on recursive relationships |
129 | - return array ( $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") ); |
|
129 | + return array($this->lhs_module => $this->getValidDBName($this->relationship_name."_name")); |
|
130 | 130 | else |
131 | - return array ( |
|
132 | - $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") , |
|
133 | - $this->rhs_module => $this->getValidDBName($this->relationship_name . "_name") |
|
134 | - ) ; |
|
131 | + return array( |
|
132 | + $this->lhs_module => $this->getValidDBName($this->relationship_name."_name"), |
|
133 | + $this->rhs_module => $this->getValidDBName($this->relationship_name."_name") |
|
134 | + ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -122,16 +124,19 @@ discard block |
||
122 | 124 | */ |
123 | 125 | function buildFieldsToLayouts () |
124 | 126 | { |
125 | - if ($this->relationship_only) |
|
126 | - return array () ; |
|
127 | + if ($this->relationship_only) { |
|
128 | + return array () ; |
|
129 | + } |
|
127 | 130 | |
128 | - if ($this->lhs_module == $this->rhs_module) // don't add in two fields on recursive relationships |
|
131 | + if ($this->lhs_module == $this->rhs_module) { |
|
132 | + // don't add in two fields on recursive relationships |
|
129 | 133 | return array ( $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") ); |
130 | - else |
|
131 | - return array ( |
|
134 | + } else { |
|
135 | + return array ( |
|
132 | 136 | $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") , |
133 | 137 | $this->rhs_module => $this->getValidDBName($this->relationship_name . "_name") |
134 | 138 | ) ; |
139 | + } |
|
135 | 140 | } |
136 | 141 | |
137 | 142 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public static $definitionKeys = array ( |
60 | 60 | // atttributes of this relationship - here in the definition so they are preserved across saves and loads |
61 | 61 | 'for_activities', |
62 | - 'is_custom', |
|
62 | + 'is_custom', |
|
63 | 63 | 'from_studio', |
64 | 64 | 'readonly' , // a readonly relationship cannot be Built by subclasses of AbstractRelationships |
65 | 65 | 'deleted' , // a deleted relationship will not be built, and if it had been built previously the built relationship will be removed |
@@ -221,48 +221,48 @@ discard block |
||
221 | 221 | $labelDefinitions = array ( ) ; |
222 | 222 | if (!$this->relationship_only) |
223 | 223 | { |
224 | - if(!$this->is_custom && $update && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
225 | - include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
|
226 | - if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
227 | - $rightSysLabel = $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
|
228 | - } |
|
229 | - $layout_defs = array(); |
|
230 | - } |
|
231 | - if(!$this->is_custom && $update && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
232 | - include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
|
233 | - if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
234 | - $leftSysLabel = $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
|
235 | - } |
|
236 | - $layout_defs = array(); |
|
237 | - } |
|
238 | - $labelDefinitions [] = array ( |
|
239 | - 'module' => $this->rhs_module , |
|
240 | - 'system_label' => isset($rightSysLabel)?$rightSysLabel : 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' , |
|
241 | - 'display_label' => ($update && !empty($_REQUEST [ 'lhs_label' ] ))?$_REQUEST [ 'lhs_label' ] :(empty($this->lhs_label) ? translate ( $this->lhs_module ) : $this->lhs_label), |
|
242 | - ) ; |
|
224 | + if(!$this->is_custom && $update && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
225 | + include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
|
226 | + if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
227 | + $rightSysLabel = $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
|
228 | + } |
|
229 | + $layout_defs = array(); |
|
230 | + } |
|
231 | + if(!$this->is_custom && $update && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
232 | + include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
|
233 | + if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
234 | + $leftSysLabel = $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
|
235 | + } |
|
236 | + $layout_defs = array(); |
|
237 | + } |
|
238 | + $labelDefinitions [] = array ( |
|
239 | + 'module' => $this->rhs_module , |
|
240 | + 'system_label' => isset($rightSysLabel)?$rightSysLabel : 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' , |
|
241 | + 'display_label' => ($update && !empty($_REQUEST [ 'lhs_label' ] ))?$_REQUEST [ 'lhs_label' ] :(empty($this->lhs_label) ? translate ( $this->lhs_module ) : $this->lhs_label), |
|
242 | + ) ; |
|
243 | 243 | $labelDefinitions [] = array ( |
244 | - 'module' => $this->lhs_module , |
|
245 | - 'system_label' => isset($leftSysLabel)?$leftSysLabel :'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' , |
|
246 | - 'display_label' => ($update && !empty($_REQUEST [ 'rhs_label' ] ))?$_REQUEST [ 'rhs_label' ] :(empty($this->rhs_label) ? translate ( $this->rhs_module ) : $this->rhs_label), |
|
244 | + 'module' => $this->lhs_module , |
|
245 | + 'system_label' => isset($leftSysLabel)?$leftSysLabel :'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' , |
|
246 | + 'display_label' => ($update && !empty($_REQUEST [ 'rhs_label' ] ))?$_REQUEST [ 'rhs_label' ] :(empty($this->rhs_label) ? translate ( $this->rhs_module ) : $this->rhs_label), |
|
247 | 247 | ) ; |
248 | 248 | } |
249 | 249 | return $labelDefinitions ; |
250 | 250 | } |
251 | 251 | |
252 | - function getLeftModuleSystemLabel() |
|
252 | + function getLeftModuleSystemLabel() |
|
253 | 253 | { |
254 | - if($this->lhs_module == $this->rhs_module){ |
|
255 | - return $this->lhs_module.'_L'; |
|
256 | - } |
|
257 | - return $this->lhs_module; |
|
254 | + if($this->lhs_module == $this->rhs_module){ |
|
255 | + return $this->lhs_module.'_L'; |
|
256 | + } |
|
257 | + return $this->lhs_module; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | function getRightModuleSystemLabel() |
261 | 261 | { |
262 | - if($this->lhs_module == $this->rhs_module){ |
|
263 | - return $this->rhs_module.'_R'; |
|
264 | - } |
|
265 | - return $this->rhs_module; |
|
262 | + if($this->lhs_module == $this->rhs_module){ |
|
263 | + return $this->rhs_module.'_R'; |
|
264 | + } |
|
265 | + return $this->rhs_module; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -298,24 +298,24 @@ discard block |
||
298 | 298 | protected function getSubpanelDefinition ($relationshipName , $sourceModule , $subpanelName, $titleKeyName = '', $source = "") |
299 | 299 | { |
300 | 300 | if (empty($source)) |
301 | - $source = $this->getValidDBName($relationshipName); |
|
302 | - $subpanelDefinition = array ( ) ; |
|
301 | + $source = $this->getValidDBName($relationshipName); |
|
302 | + $subpanelDefinition = array ( ) ; |
|
303 | 303 | $subpanelDefinition [ 'order' ] = 100 ; |
304 | 304 | $subpanelDefinition [ 'module' ] = $sourceModule ; |
305 | 305 | $subpanelDefinition [ 'subpanel_name' ] = $subpanelName ; |
306 | 306 | // following two lines are required for the subpanel pagination code in ListView.php->processUnionBeans() to correctly determine the relevant field for sorting |
307 | 307 | $subpanelDefinition [ 'sort_order' ] = 'asc' ; |
308 | 308 | $subpanelDefinition [ 'sort_by' ] = 'id' ; |
309 | - if(!empty($titleKeyName)){ |
|
310 | - $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
311 | - }else{ |
|
312 | - $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
313 | - } |
|
309 | + if(!empty($titleKeyName)){ |
|
310 | + $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
311 | + }else{ |
|
312 | + $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
313 | + } |
|
314 | 314 | $subpanelDefinition [ 'get_subpanel_data' ] = $source ; |
315 | 315 | $subpanelDefinition [ 'top_buttons' ] = array( |
316 | - array('widget_class' => "SubPanelTopButtonQuickCreate"), |
|
317 | - array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect') |
|
318 | - ); |
|
316 | + array('widget_class' => "SubPanelTopButtonQuickCreate"), |
|
317 | + array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect') |
|
318 | + ); |
|
319 | 319 | |
320 | 320 | return array ( $subpanelDefinition ); |
321 | 321 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $vardef [ 'module' ] = $sourceModule ; |
340 | 340 | $vardef [ 'bean_name' ] = BeanFactory::getObjectName($sourceModule) ; |
341 | 341 | if ($right_side) |
342 | - $vardef [ 'side' ] = 'right' ; |
|
342 | + $vardef [ 'side' ] = 'right' ; |
|
343 | 343 | if (!empty($vname)) |
344 | 344 | $vardef [ 'vname' ] = $vname; |
345 | 345 | if (!empty($id_name)) |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | $vardef [ 'type' ] = 'link' ; |
365 | 365 | $vardef [ 'relationship' ] = $relationshipName ; |
366 | 366 | $vardef [ 'source' ] = 'non-db' ; |
367 | - $vardef ['reportable'] = false; |
|
367 | + $vardef ['reportable'] = false; |
|
368 | 368 | if ($right_side) |
369 | - $vardef [ 'side' ] = 'right' ; |
|
369 | + $vardef [ 'side' ] = 'right' ; |
|
370 | 370 | else |
371 | - $vardef [ 'side' ] = 'left' ; |
|
371 | + $vardef [ 'side' ] = 'left' ; |
|
372 | 372 | if (!empty($vname)) |
373 | 373 | $vardef [ 'vname' ] = $vname; |
374 | 374 | |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | $vardef [ 'type' ] = 'relate' ; |
390 | 390 | |
391 | 391 | $vardef [ 'source' ] = 'non-db' ; |
392 | - if(!empty($vnameLabel)){ |
|
393 | - $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $vnameLabel ) . '_TITLE' ; |
|
394 | - }else{ |
|
395 | - $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
396 | - } |
|
392 | + if(!empty($vnameLabel)){ |
|
393 | + $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $vnameLabel ) . '_TITLE' ; |
|
394 | + }else{ |
|
395 | + $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
396 | + } |
|
397 | 397 | |
398 | 398 | $vardef [ 'save' ] = true; // the magic value to tell SugarBean to save this relate field even though it is not listed in the $relationship_fields array |
399 | 399 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | if (in_array( 'file' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
422 | 422 | $vardef [ 'rname' ] = 'document_name' ; |
423 | 423 | }elseif(in_array ( 'person' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
424 | - $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
424 | + $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | else |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | require_once ( $GLOBALS ['beanFiles'] [ $object ] ); |
451 | 451 | $bean = new $object(); |
452 | 452 | if ( isset ( $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
453 | - if(in_array ( 'file' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
454 | - $vardef [ 'rname' ] = 'document_name' ; |
|
455 | - }elseif(in_array ( 'person' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
456 | - $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
457 | - } |
|
453 | + if(in_array ( 'file' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
454 | + $vardef [ 'rname' ] = 'document_name' ; |
|
455 | + }elseif(in_array ( 'person' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
456 | + $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
457 | + } |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | function getJoinKeyLHS() |
635 | 635 | { |
636 | 636 | if (!isset($this->joinKeyLHS)) |
637 | - $this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ; |
|
637 | + $this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ; |
|
638 | 638 | |
639 | 639 | return $this->joinKeyLHS; |
640 | 640 | } |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | function getJoinKeyRHS() |
643 | 643 | { |
644 | 644 | if (!isset($this->joinKeyRHS)) |
645 | - $this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ; |
|
645 | + $this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ; |
|
646 | 646 | |
647 | 647 | return $this->joinKeyRHS; |
648 | 648 | } |
@@ -674,32 +674,32 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | public function getTitleKey($left=false){ |
677 | - if(!$this->is_custom && !$left && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
678 | - include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
|
679 | - if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
680 | - return $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
|
681 | - } |
|
682 | - }else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
683 | - include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
|
684 | - if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
685 | - return $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
|
686 | - } |
|
687 | - } |
|
677 | + if(!$this->is_custom && !$left && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
678 | + include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
|
679 | + if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
680 | + return $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
|
681 | + } |
|
682 | + }else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
683 | + include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
|
684 | + if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
685 | + return $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
|
686 | + } |
|
687 | + } |
|
688 | 688 | |
689 | - if($left){ |
|
690 | - $titleKeyName = $this->getRightModuleSystemLabel(); |
|
691 | - $sourceModule = $this->rhs_module; |
|
692 | - }else{ |
|
693 | - $titleKeyName = $this->getLeftModuleSystemLabel(); |
|
694 | - $sourceModule = $this->lhs_module; |
|
695 | - } |
|
689 | + if($left){ |
|
690 | + $titleKeyName = $this->getRightModuleSystemLabel(); |
|
691 | + $sourceModule = $this->rhs_module; |
|
692 | + }else{ |
|
693 | + $titleKeyName = $this->getLeftModuleSystemLabel(); |
|
694 | + $sourceModule = $this->lhs_module; |
|
695 | + } |
|
696 | 696 | |
697 | - if(!empty($titleKeyName)){ |
|
698 | - $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
699 | - }else{ |
|
700 | - $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
701 | - } |
|
697 | + if(!empty($titleKeyName)){ |
|
698 | + $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
699 | + }else{ |
|
700 | + $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
701 | + } |
|
702 | 702 | |
703 | - return $title_key; |
|
704 | - } |
|
703 | + return $title_key; |
|
704 | + } |
|
705 | 705 | } |
706 | 706 | \ No newline at end of file |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -107,9 +109,10 @@ discard block |
||
107 | 109 | function __construct ($definition) |
108 | 110 | { |
109 | 111 | // set any undefined attributes to the default value |
110 | - foreach ( array ( 'readonly' , 'deleted' , 'relationship_only', 'for_activities', 'is_custom', 'from_studio' ) as $key ) |
|
111 | - if (! isset ( $definition [ $key ] )) |
|
112 | + foreach ( array ( 'readonly' , 'deleted' , 'relationship_only', 'for_activities', 'is_custom', 'from_studio' ) as $key ) { |
|
113 | + if (! isset ( $definition [ $key ] )) |
|
112 | 114 | $definition [ $key ] = false ; |
115 | + } |
|
113 | 116 | |
114 | 117 | foreach ( self::$definitionKeys as $key ) |
115 | 118 | { |
@@ -297,8 +300,9 @@ discard block |
||
297 | 300 | */ |
298 | 301 | protected function getSubpanelDefinition ($relationshipName , $sourceModule , $subpanelName, $titleKeyName = '', $source = "") |
299 | 302 | { |
300 | - if (empty($source)) |
|
301 | - $source = $this->getValidDBName($relationshipName); |
|
303 | + if (empty($source)) { |
|
304 | + $source = $this->getValidDBName($relationshipName); |
|
305 | + } |
|
302 | 306 | $subpanelDefinition = array ( ) ; |
303 | 307 | $subpanelDefinition [ 'order' ] = 100 ; |
304 | 308 | $subpanelDefinition [ 'module' ] = $sourceModule ; |
@@ -308,7 +312,7 @@ discard block |
||
308 | 312 | $subpanelDefinition [ 'sort_by' ] = 'id' ; |
309 | 313 | if(!empty($titleKeyName)){ |
310 | 314 | $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
311 | - }else{ |
|
315 | + } else{ |
|
312 | 316 | $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
313 | 317 | } |
314 | 318 | $subpanelDefinition [ 'get_subpanel_data' ] = $source ; |
@@ -338,12 +342,15 @@ discard block |
||
338 | 342 | $vardef [ 'source' ] = 'non-db' ; |
339 | 343 | $vardef [ 'module' ] = $sourceModule ; |
340 | 344 | $vardef [ 'bean_name' ] = BeanFactory::getObjectName($sourceModule) ; |
341 | - if ($right_side) |
|
342 | - $vardef [ 'side' ] = 'right' ; |
|
343 | - if (!empty($vname)) |
|
344 | - $vardef [ 'vname' ] = $vname; |
|
345 | - if (!empty($id_name)) |
|
346 | - $vardef['id_name'] = $id_name; |
|
345 | + if ($right_side) { |
|
346 | + $vardef [ 'side' ] = 'right' ; |
|
347 | + } |
|
348 | + if (!empty($vname)) { |
|
349 | + $vardef [ 'vname' ] = $vname; |
|
350 | + } |
|
351 | + if (!empty($id_name)) { |
|
352 | + $vardef['id_name'] = $id_name; |
|
353 | + } |
|
347 | 354 | |
348 | 355 | return $vardef ; |
349 | 356 | } |
@@ -365,12 +372,14 @@ discard block |
||
365 | 372 | $vardef [ 'relationship' ] = $relationshipName ; |
366 | 373 | $vardef [ 'source' ] = 'non-db' ; |
367 | 374 | $vardef ['reportable'] = false; |
368 | - if ($right_side) |
|
369 | - $vardef [ 'side' ] = 'right' ; |
|
370 | - else |
|
371 | - $vardef [ 'side' ] = 'left' ; |
|
372 | - if (!empty($vname)) |
|
373 | - $vardef [ 'vname' ] = $vname; |
|
375 | + if ($right_side) { |
|
376 | + $vardef [ 'side' ] = 'right' ; |
|
377 | + } else { |
|
378 | + $vardef [ 'side' ] = 'left' ; |
|
379 | + } |
|
380 | + if (!empty($vname)) { |
|
381 | + $vardef [ 'vname' ] = $vname; |
|
382 | + } |
|
374 | 383 | |
375 | 384 | return $vardef ; |
376 | 385 | } |
@@ -391,7 +400,7 @@ discard block |
||
391 | 400 | $vardef [ 'source' ] = 'non-db' ; |
392 | 401 | if(!empty($vnameLabel)){ |
393 | 402 | $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $vnameLabel ) . '_TITLE' ; |
394 | - }else{ |
|
403 | + } else{ |
|
395 | 404 | $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
396 | 405 | } |
397 | 406 | |
@@ -420,11 +429,10 @@ discard block |
||
420 | 429 | $module = $mb->getPackageModule ( $parsedModuleName['packageName'] , $parsedModuleName['moduleName'] ) ; |
421 | 430 | if (in_array( 'file' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
422 | 431 | $vardef [ 'rname' ] = 'document_name' ; |
423 | - }elseif(in_array ( 'person' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
|
432 | + } elseif(in_array ( 'person' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
|
424 | 433 | $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
425 | 434 | } |
426 | - } |
|
427 | - else |
|
435 | + } else |
|
428 | 436 | { |
429 | 437 | switch ( strtolower( $sourceModule ) ) |
430 | 438 | { |
@@ -452,7 +460,7 @@ discard block |
||
452 | 460 | if ( isset ( $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
453 | 461 | if(in_array ( 'file' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
454 | 462 | $vardef [ 'rname' ] = 'document_name' ; |
455 | - }elseif(in_array ( 'person' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
463 | + } elseif(in_array ( 'person' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
456 | 464 | $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
457 | 465 | } |
458 | 466 | } |
@@ -513,8 +521,9 @@ discard block |
||
513 | 521 | // but as we need to display the true cardinality in Studio and ModuleBuilder we also record the actual relationship type |
514 | 522 | // this property is only used by Studio/MB |
515 | 523 | $properties [ 'true_relationship_type' ] = $relationshipType ; |
516 | - if ($this->from_studio) |
|
517 | - $properties [ 'from_studio' ] = true; |
|
524 | + if ($this->from_studio) { |
|
525 | + $properties [ 'from_studio' ] = true; |
|
526 | + } |
|
518 | 527 | |
519 | 528 | $rel_properties [ 'join_table' ] = $this->getValidDBName ( $relationshipName."_c" ) ; |
520 | 529 | // a and b are in case the module relates to itself |
@@ -525,8 +534,9 @@ discard block |
||
525 | 534 | // set the extended properties if they exist = for now, many-to-many definitions do not have to contain a role_column even if role_column_value is set; we'll just create a likely name if missing |
526 | 535 | if (isset ( $this->definition [ 'relationship_role_column_value' ] )) |
527 | 536 | { |
528 | - if (! isset ( $this->definition [ 'relationship_role_column' ] )) |
|
529 | - $this->definition [ 'relationship_role_column' ] = 'relationship_role_column' ; |
|
537 | + if (! isset ( $this->definition [ 'relationship_role_column' ] )) { |
|
538 | + $this->definition [ 'relationship_role_column' ] = 'relationship_role_column' ; |
|
539 | + } |
|
530 | 540 | $rel_properties [ 'relationship_role_column' ] = $this->definition [ 'relationship_role_column' ] ; |
531 | 541 | $rel_properties [ 'relationship_role_column_value' ] = $this->definition [ 'relationship_role_column_value' ] ; |
532 | 542 | } |
@@ -575,8 +585,10 @@ discard block |
||
575 | 585 | $alternateKeys = array ( $rel_properties [ 'join_key_lhs' ] , $rel_properties [ 'join_key_rhs' ] ) ; |
576 | 586 | } |
577 | 587 | |
578 | - if (count($alternateKeys)>0) |
|
579 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_alt' , 'type' => 'alternate_key' , 'fields' => $alternateKeys ) ; // type must be set to alternate_key for Link.php to correctly update an existing record rather than inserting a copy - it uses the fields in this array as the keys to check if a duplicate record already exists |
|
588 | + if (count($alternateKeys)>0) { |
|
589 | + $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_alt' , 'type' => 'alternate_key' , 'fields' => $alternateKeys ) ; |
|
590 | + } |
|
591 | + // type must be set to alternate_key for Link.php to correctly update an existing record rather than inserting a copy - it uses the fields in this array as the keys to check if a duplicate record already exists |
|
580 | 592 | |
581 | 593 | return $properties ; |
582 | 594 | } |
@@ -623,8 +635,9 @@ discard block |
||
623 | 635 | $canonicalTypes = array ( ) ; |
624 | 636 | foreach ( array ( MB_ONETOONE , MB_ONETOMANY , MB_MANYTOMANY , MB_MANYTOONE) as $canonicalType ) |
625 | 637 | { |
626 | - if ($type == preg_replace ( '/[^\w]+/i', '', strtolower ( $canonicalType ) )) |
|
627 | - return $canonicalType ; |
|
638 | + if ($type == preg_replace ( '/[^\w]+/i', '', strtolower ( $canonicalType ) )) { |
|
639 | + return $canonicalType ; |
|
640 | + } |
|
628 | 641 | } |
629 | 642 | // ok, we give up... |
630 | 643 | return MB_MANYTOMANY ; |
@@ -633,16 +646,18 @@ discard block |
||
633 | 646 | |
634 | 647 | function getJoinKeyLHS() |
635 | 648 | { |
636 | - if (!isset($this->joinKeyLHS)) |
|
637 | - $this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ; |
|
649 | + if (!isset($this->joinKeyLHS)) { |
|
650 | + $this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ; |
|
651 | + } |
|
638 | 652 | |
639 | 653 | return $this->joinKeyLHS; |
640 | 654 | } |
641 | 655 | |
642 | 656 | function getJoinKeyRHS() |
643 | 657 | { |
644 | - if (!isset($this->joinKeyRHS)) |
|
645 | - $this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ; |
|
658 | + if (!isset($this->joinKeyRHS)) { |
|
659 | + $this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ; |
|
660 | + } |
|
646 | 661 | |
647 | 662 | return $this->joinKeyRHS; |
648 | 663 | } |
@@ -679,7 +694,7 @@ discard block |
||
679 | 694 | if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
680 | 695 | return $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
681 | 696 | } |
682 | - }else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
697 | + } else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
683 | 698 | include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
684 | 699 | if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
685 | 700 | return $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
@@ -689,14 +704,14 @@ discard block |
||
689 | 704 | if($left){ |
690 | 705 | $titleKeyName = $this->getRightModuleSystemLabel(); |
691 | 706 | $sourceModule = $this->rhs_module; |
692 | - }else{ |
|
707 | + } else{ |
|
693 | 708 | $titleKeyName = $this->getLeftModuleSystemLabel(); |
694 | 709 | $sourceModule = $this->lhs_module; |
695 | 710 | } |
696 | 711 | |
697 | 712 | if(!empty($titleKeyName)){ |
698 | 713 | $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
699 | - }else{ |
|
714 | + } else{ |
|
700 | 715 | $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $sourceModule ) . '_TITLE' ; |
701 | 716 | } |
702 | 717 |
@@ -1,5 +1,5 @@ discard block |
||
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. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | class AbstractRelationship |
48 | 48 | { |
49 | 49 | |
50 | - protected $definition ; // enough information to rebuild this relationship |
|
50 | + protected $definition; // enough information to rebuild this relationship |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /* |
@@ -56,35 +56,35 @@ discard block |
||
56 | 56 | * The base set of keys are those used in the Relationships table |
57 | 57 | * Defined as Public as MBRelationship uses these to read the _POST data |
58 | 58 | */ |
59 | - public static $definitionKeys = array ( |
|
59 | + public static $definitionKeys = array( |
|
60 | 60 | // atttributes of this relationship - here in the definition so they are preserved across saves and loads |
61 | 61 | 'for_activities', |
62 | 62 | 'is_custom', |
63 | 63 | 'from_studio', |
64 | - 'readonly' , // a readonly relationship cannot be Built by subclasses of AbstractRelationships |
|
65 | - 'deleted' , // a deleted relationship will not be built, and if it had been built previously the built relationship will be removed |
|
66 | - 'relationship_only' , // means that we won't build any UI components for this relationship - required while the Subpanel code is restricted to one subpanel only from any module, and probably useful afterwards also for developers to build relationships for new code - it's a feature! |
|
64 | + 'readonly', // a readonly relationship cannot be Built by subclasses of AbstractRelationships |
|
65 | + 'deleted', // a deleted relationship will not be built, and if it had been built previously the built relationship will be removed |
|
66 | + 'relationship_only', // means that we won't build any UI components for this relationship - required while the Subpanel code is restricted to one subpanel only from any module, and probably useful afterwards also for developers to build relationships for new code - it's a feature! |
|
67 | 67 | // keys not found in Relationships table |
68 | - 'label' , // optional |
|
68 | + 'label', // optional |
|
69 | 69 | 'rhs_label', // optional |
70 | 70 | 'lhs_label', // optional |
71 | - 'lhs_subpanel' , // subpanel FROM the lhs_module to display on the rhs_module detail view |
|
72 | - 'rhs_subpanel' , // subpanel FROM the rhs_module to display on the lhs_module detail view |
|
71 | + 'lhs_subpanel', // subpanel FROM the lhs_module to display on the rhs_module detail view |
|
72 | + 'rhs_subpanel', // subpanel FROM the rhs_module to display on the lhs_module detail view |
|
73 | 73 | // keys from Relationships table |
74 | - 'relationship_name' , |
|
75 | - 'lhs_module' , |
|
76 | - 'lhs_table' , |
|
77 | - 'lhs_key' , |
|
78 | - 'rhs_module' , |
|
79 | - 'rhs_table' , |
|
80 | - 'rhs_key' , |
|
81 | - 'join_table' , |
|
82 | - 'join_key_lhs' , |
|
83 | - 'join_key_rhs' , |
|
84 | - 'relationship_type' , |
|
85 | - 'relationship_role_column' , |
|
86 | - 'relationship_role_column_value' , |
|
87 | - 'reverse' ) ; |
|
74 | + 'relationship_name', |
|
75 | + 'lhs_module', |
|
76 | + 'lhs_table', |
|
77 | + 'lhs_key', |
|
78 | + 'rhs_module', |
|
79 | + 'rhs_table', |
|
80 | + 'rhs_key', |
|
81 | + 'join_table', |
|
82 | + 'join_key_lhs', |
|
83 | + 'join_key_rhs', |
|
84 | + 'relationship_type', |
|
85 | + 'relationship_role_column', |
|
86 | + 'relationship_role_column_value', |
|
87 | + 'reverse' ); |
|
88 | 88 | |
89 | 89 | /* |
90 | 90 | * Relationship_role_column and relationship_role_column_value: |
@@ -104,65 +104,65 @@ discard block |
||
104 | 104 | * Constructor |
105 | 105 | * @param string $definition Definition array for this relationship. Parameters are given in self::keys |
106 | 106 | */ |
107 | - function __construct ($definition) |
|
107 | + function __construct($definition) |
|
108 | 108 | { |
109 | 109 | // set any undefined attributes to the default value |
110 | - foreach ( array ( 'readonly' , 'deleted' , 'relationship_only', 'for_activities', 'is_custom', 'from_studio' ) as $key ) |
|
111 | - if (! isset ( $definition [ $key ] )) |
|
112 | - $definition [ $key ] = false ; |
|
110 | + foreach (array('readonly', 'deleted', 'relationship_only', 'for_activities', 'is_custom', 'from_studio') as $key) |
|
111 | + if (!isset ($definition [$key])) |
|
112 | + $definition [$key] = false; |
|
113 | 113 | |
114 | - foreach ( self::$definitionKeys as $key ) |
|
114 | + foreach (self::$definitionKeys as $key) |
|
115 | 115 | { |
116 | - $this->$key = isset ( $definition [ $key ] ) ? $definition [ $key ] : '' ; |
|
116 | + $this->$key = isset ($definition [$key]) ? $definition [$key] : ''; |
|
117 | 117 | } |
118 | - $this->definition = $definition ; |
|
118 | + $this->definition = $definition; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /* |
122 | 122 | * Get the unique name of this relationship |
123 | 123 | * @return string The unique name (actually just that given to the constructor) |
124 | 124 | */ |
125 | - public function getName () |
|
125 | + public function getName() |
|
126 | 126 | { |
127 | - return isset ( $this->definition [ 'relationship_name' ] ) ? $this->definition [ 'relationship_name' ] : null ; |
|
127 | + return isset ($this->definition ['relationship_name']) ? $this->definition ['relationship_name'] : null; |
|
128 | 128 | } |
129 | 129 | |
130 | - public function setName ($relationshipName) |
|
130 | + public function setName($relationshipName) |
|
131 | 131 | { |
132 | - $this->relationship_name = $this->definition [ 'relationship_name' ] = $relationshipName ; |
|
132 | + $this->relationship_name = $this->definition ['relationship_name'] = $relationshipName; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /* |
136 | 136 | * Is this relationship readonly or not? |
137 | 137 | * @return boolean True if cannot be changed; false otherwise |
138 | 138 | */ |
139 | - public function readonly () |
|
139 | + public function readonly() |
|
140 | 140 | { |
141 | - return $this->definition [ 'readonly' ] ; |
|
141 | + return $this->definition ['readonly']; |
|
142 | 142 | } |
143 | 143 | |
144 | - public function setReadonly ($set = true) |
|
144 | + public function setReadonly($set = true) |
|
145 | 145 | { |
146 | - $this->readonly = $this->definition [ 'readonly' ] = $set ; |
|
146 | + $this->readonly = $this->definition ['readonly'] = $set; |
|
147 | 147 | } |
148 | 148 | |
149 | - public function setFromStudio () |
|
149 | + public function setFromStudio() |
|
150 | 150 | { |
151 | - $this->from_studio = $this->definition [ 'from_studio' ] = true ; |
|
151 | + $this->from_studio = $this->definition ['from_studio'] = true; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /* |
155 | 155 | * Has this relationship been deleted? A deleted relationship does not get built, and is no longer visible in the list of relationships |
156 | 156 | * @return boolean True if it has been deleted; false otherwise |
157 | 157 | */ |
158 | - public function deleted () |
|
158 | + public function deleted() |
|
159 | 159 | { |
160 | - return $this->definition [ 'deleted' ] ; |
|
160 | + return $this->definition ['deleted']; |
|
161 | 161 | } |
162 | 162 | |
163 | - public function delete () |
|
163 | + public function delete() |
|
164 | 164 | { |
165 | - $this->deleted = $this->definition [ 'deleted' ] = true ; |
|
165 | + $this->deleted = $this->definition ['deleted'] = true; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | public function getFromStudio() |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | return $this->rhs_module; |
181 | 181 | } |
182 | 182 | |
183 | - public function getType () |
|
183 | + public function getType() |
|
184 | 184 | { |
185 | - return $this->relationship_type ; |
|
185 | + return $this->relationship_type; |
|
186 | 186 | } |
187 | 187 | |
188 | - public function relationship_only () |
|
188 | + public function relationship_only() |
|
189 | 189 | { |
190 | - return $this->definition [ 'relationship_only' ] ; |
|
190 | + return $this->definition ['relationship_only']; |
|
191 | 191 | } |
192 | 192 | |
193 | - public function setRelationship_only () |
|
193 | + public function setRelationship_only() |
|
194 | 194 | { |
195 | - $this->relationship_only = $this->definition [ 'relationship_only' ] = true ; |
|
195 | + $this->relationship_only = $this->definition ['relationship_only'] = true; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /* |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * `relationship_name`, `lhs_module`, `lhs_table`, `lhs_key`, `rhs_module`, `rhs_table`,`rhs_key`, `join_table`, `join_key_lhs`, `join_key_rhs`, `relationship_type`, `relationship_role_column`, `relationship_role_column_value`, `reverse`, |
204 | 204 | * @return array Set of parameters to pass to an AbstractRelationship constructor - must contain at least ['relationship_type']='OneToOne' or 'OneToMany' or 'ManyToMany' |
205 | 205 | */ |
206 | - function getDefinition () |
|
206 | + function getDefinition() |
|
207 | 207 | { |
208 | - return $this->definition ; |
|
208 | + return $this->definition; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /* |
@@ -216,42 +216,42 @@ discard block |
||
216 | 216 | * Define the labels to be added to the module for the new relationships |
217 | 217 | * @return array An array of system value => display value |
218 | 218 | */ |
219 | - function buildLabels ($update=false) |
|
219 | + function buildLabels($update = false) |
|
220 | 220 | { |
221 | - $labelDefinitions = array ( ) ; |
|
221 | + $labelDefinitions = array( ); |
|
222 | 222 | if (!$this->relationship_only) |
223 | 223 | { |
224 | - if(!$this->is_custom && $update && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
224 | + if (!$this->is_custom && $update && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")) { |
|
225 | 225 | include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
226 | - if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
226 | + if (isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])) { |
|
227 | 227 | $rightSysLabel = $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
228 | 228 | } |
229 | 229 | $layout_defs = array(); |
230 | 230 | } |
231 | - if(!$this->is_custom && $update && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
231 | + if (!$this->is_custom && $update && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")) { |
|
232 | 232 | include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
233 | - if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
233 | + if (isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])) { |
|
234 | 234 | $leftSysLabel = $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
235 | 235 | } |
236 | 236 | $layout_defs = array(); |
237 | 237 | } |
238 | - $labelDefinitions [] = array ( |
|
239 | - 'module' => $this->rhs_module , |
|
240 | - 'system_label' => isset($rightSysLabel)?$rightSysLabel : 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' , |
|
241 | - 'display_label' => ($update && !empty($_REQUEST [ 'lhs_label' ] ))?$_REQUEST [ 'lhs_label' ] :(empty($this->lhs_label) ? translate ( $this->lhs_module ) : $this->lhs_label), |
|
242 | - ) ; |
|
243 | - $labelDefinitions [] = array ( |
|
244 | - 'module' => $this->lhs_module , |
|
245 | - 'system_label' => isset($leftSysLabel)?$leftSysLabel :'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' , |
|
246 | - 'display_label' => ($update && !empty($_REQUEST [ 'rhs_label' ] ))?$_REQUEST [ 'rhs_label' ] :(empty($this->rhs_label) ? translate ( $this->rhs_module ) : $this->rhs_label), |
|
247 | - ) ; |
|
238 | + $labelDefinitions [] = array( |
|
239 | + 'module' => $this->rhs_module, |
|
240 | + 'system_label' => isset($rightSysLabel) ? $rightSysLabel : 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getLeftModuleSystemLabel()).'_TITLE', |
|
241 | + 'display_label' => ($update && !empty($_REQUEST ['lhs_label'])) ? $_REQUEST ['lhs_label'] : (empty($this->lhs_label) ? translate ($this->lhs_module) : $this->lhs_label), |
|
242 | + ); |
|
243 | + $labelDefinitions [] = array( |
|
244 | + 'module' => $this->lhs_module, |
|
245 | + 'system_label' => isset($leftSysLabel) ? $leftSysLabel : 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$this->getRightModuleSystemLabel()).'_TITLE', |
|
246 | + 'display_label' => ($update && !empty($_REQUEST ['rhs_label'])) ? $_REQUEST ['rhs_label'] : (empty($this->rhs_label) ? translate ($this->rhs_module) : $this->rhs_label), |
|
247 | + ); |
|
248 | 248 | } |
249 | - return $labelDefinitions ; |
|
249 | + return $labelDefinitions; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | function getLeftModuleSystemLabel() |
253 | 253 | { |
254 | - if($this->lhs_module == $this->rhs_module){ |
|
254 | + if ($this->lhs_module == $this->rhs_module) { |
|
255 | 255 | return $this->lhs_module.'_L'; |
256 | 256 | } |
257 | 257 | return $this->lhs_module; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | function getRightModuleSystemLabel() |
261 | 261 | { |
262 | - if($this->lhs_module == $this->rhs_module){ |
|
262 | + if ($this->lhs_module == $this->rhs_module) { |
|
263 | 263 | return $this->rhs_module.'_R'; |
264 | 264 | } |
265 | 265 | return $this->rhs_module; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | public function getLabels() { |
273 | 273 | $labels = array(); |
274 | 274 | $labelDefinitions = $this->buildLabels(); |
275 | - foreach($labelDefinitions as $def){ |
|
275 | + foreach ($labelDefinitions as $def) { |
|
276 | 276 | $labels[$def['module']][$def['system_label']] = $def['display_label']; |
277 | 277 | } |
278 | 278 | |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $subpanelName Name of the subpanel provided by the sourceModule |
296 | 296 | * @param string $titleKeyName Name of the subpanel title , if none, we will use the module name as the subpanel title. |
297 | 297 | */ |
298 | - protected function getSubpanelDefinition ($relationshipName , $sourceModule , $subpanelName, $titleKeyName = '', $source = "") |
|
298 | + protected function getSubpanelDefinition($relationshipName, $sourceModule, $subpanelName, $titleKeyName = '', $source = "") |
|
299 | 299 | { |
300 | 300 | if (empty($source)) |
301 | 301 | $source = $this->getValidDBName($relationshipName); |
302 | - $subpanelDefinition = array ( ) ; |
|
303 | - $subpanelDefinition [ 'order' ] = 100 ; |
|
304 | - $subpanelDefinition [ 'module' ] = $sourceModule ; |
|
305 | - $subpanelDefinition [ 'subpanel_name' ] = $subpanelName ; |
|
302 | + $subpanelDefinition = array( ); |
|
303 | + $subpanelDefinition ['order'] = 100; |
|
304 | + $subpanelDefinition ['module'] = $sourceModule; |
|
305 | + $subpanelDefinition ['subpanel_name'] = $subpanelName; |
|
306 | 306 | // following two lines are required for the subpanel pagination code in ListView.php->processUnionBeans() to correctly determine the relevant field for sorting |
307 | - $subpanelDefinition [ 'sort_order' ] = 'asc' ; |
|
308 | - $subpanelDefinition [ 'sort_by' ] = 'id' ; |
|
309 | - if(!empty($titleKeyName)){ |
|
310 | - $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
311 | - }else{ |
|
312 | - $subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
307 | + $subpanelDefinition ['sort_order'] = 'asc'; |
|
308 | + $subpanelDefinition ['sort_by'] = 'id'; |
|
309 | + if (!empty($titleKeyName)) { |
|
310 | + $subpanelDefinition ['title_key'] = 'LBL_'.strtoupper($relationshipName.'_FROM_'.$titleKeyName).'_TITLE'; |
|
311 | + } else { |
|
312 | + $subpanelDefinition ['title_key'] = 'LBL_'.strtoupper($relationshipName.'_FROM_'.$sourceModule).'_TITLE'; |
|
313 | 313 | } |
314 | - $subpanelDefinition [ 'get_subpanel_data' ] = $source ; |
|
315 | - $subpanelDefinition [ 'top_buttons' ] = array( |
|
314 | + $subpanelDefinition ['get_subpanel_data'] = $source; |
|
315 | + $subpanelDefinition ['top_buttons'] = array( |
|
316 | 316 | array('widget_class' => "SubPanelTopButtonQuickCreate"), |
317 | 317 | array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect') |
318 | 318 | ); |
319 | 319 | |
320 | - return array ( $subpanelDefinition ); |
|
320 | + return array($subpanelDefinition); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -328,24 +328,24 @@ discard block |
||
328 | 328 | * @param string $sourceModule Name of the source module for this field |
329 | 329 | * @param string $relationshipName Name of the relationship |
330 | 330 | */ |
331 | - protected function getLinkFieldDefinition ($sourceModule , $relationshipName, $right_side = false, $vname = "", $id_name = false) |
|
331 | + protected function getLinkFieldDefinition($sourceModule, $relationshipName, $right_side = false, $vname = "", $id_name = false) |
|
332 | 332 | { |
333 | - $vardef = array ( ) ; |
|
334 | - |
|
335 | - $vardef [ 'name' ] = $this->getValidDBName($relationshipName) ; |
|
336 | - $vardef [ 'type' ] = 'link' ; |
|
337 | - $vardef [ 'relationship' ] = $relationshipName ; |
|
338 | - $vardef [ 'source' ] = 'non-db' ; |
|
339 | - $vardef [ 'module' ] = $sourceModule ; |
|
340 | - $vardef [ 'bean_name' ] = BeanFactory::getObjectName($sourceModule) ; |
|
333 | + $vardef = array( ); |
|
334 | + |
|
335 | + $vardef ['name'] = $this->getValidDBName($relationshipName); |
|
336 | + $vardef ['type'] = 'link'; |
|
337 | + $vardef ['relationship'] = $relationshipName; |
|
338 | + $vardef ['source'] = 'non-db'; |
|
339 | + $vardef ['module'] = $sourceModule; |
|
340 | + $vardef ['bean_name'] = BeanFactory::getObjectName($sourceModule); |
|
341 | 341 | if ($right_side) |
342 | - $vardef [ 'side' ] = 'right' ; |
|
342 | + $vardef ['side'] = 'right'; |
|
343 | 343 | if (!empty($vname)) |
344 | - $vardef [ 'vname' ] = $vname; |
|
344 | + $vardef ['vname'] = $vname; |
|
345 | 345 | if (!empty($id_name)) |
346 | 346 | $vardef['id_name'] = $id_name; |
347 | 347 | |
348 | - return $vardef ; |
|
348 | + return $vardef; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /* |
@@ -356,23 +356,23 @@ discard block |
||
356 | 356 | * @param string $sourceModule Name of the source module for this field |
357 | 357 | * @param string $relationshipName Name of the relationship |
358 | 358 | */ |
359 | - protected function getLink2FieldDefinition ($sourceModule , $relationshipName, $right_side = false, $vname = "") |
|
359 | + protected function getLink2FieldDefinition($sourceModule, $relationshipName, $right_side = false, $vname = "") |
|
360 | 360 | { |
361 | - $vardef = array ( ) ; |
|
361 | + $vardef = array( ); |
|
362 | 362 | |
363 | - $vardef [ 'name' ] = $this->getIDName( $sourceModule ) ; // must match the id_name field value in the relate field definition |
|
364 | - $vardef [ 'type' ] = 'link' ; |
|
365 | - $vardef [ 'relationship' ] = $relationshipName ; |
|
366 | - $vardef [ 'source' ] = 'non-db' ; |
|
363 | + $vardef ['name'] = $this->getIDName($sourceModule); // must match the id_name field value in the relate field definition |
|
364 | + $vardef ['type'] = 'link'; |
|
365 | + $vardef ['relationship'] = $relationshipName; |
|
366 | + $vardef ['source'] = 'non-db'; |
|
367 | 367 | $vardef ['reportable'] = false; |
368 | 368 | if ($right_side) |
369 | - $vardef [ 'side' ] = 'right' ; |
|
369 | + $vardef ['side'] = 'right'; |
|
370 | 370 | else |
371 | - $vardef [ 'side' ] = 'left' ; |
|
371 | + $vardef ['side'] = 'left'; |
|
372 | 372 | if (!empty($vname)) |
373 | - $vardef [ 'vname' ] = $vname; |
|
373 | + $vardef ['vname'] = $vname; |
|
374 | 374 | |
375 | - return $vardef ; |
|
375 | + return $vardef; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /* |
@@ -382,78 +382,78 @@ discard block |
||
382 | 382 | * @param string $relationshipName Name of the relationship |
383 | 383 | * @param string $moduleType Optional - "Types" of the module - array of SugarObject types such as "file" or "basic" |
384 | 384 | */ |
385 | - protected function getRelateFieldDefinition ($sourceModule , $relationshipName , $vnameLabel='') |
|
385 | + protected function getRelateFieldDefinition($sourceModule, $relationshipName, $vnameLabel = '') |
|
386 | 386 | { |
387 | - $vardef = array ( ) ; |
|
388 | - $vardef [ 'name' ] = $this->getValidDBName($relationshipName . "_name") ; // must end in _name for the QuickSearch code in TemplateHandler->createQuickSearchCode |
|
389 | - $vardef [ 'type' ] = 'relate' ; |
|
390 | - |
|
391 | - $vardef [ 'source' ] = 'non-db' ; |
|
392 | - if(!empty($vnameLabel)){ |
|
393 | - $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $vnameLabel ) . '_TITLE' ; |
|
394 | - }else{ |
|
395 | - $vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
387 | + $vardef = array( ); |
|
388 | + $vardef ['name'] = $this->getValidDBName($relationshipName."_name"); // must end in _name for the QuickSearch code in TemplateHandler->createQuickSearchCode |
|
389 | + $vardef ['type'] = 'relate'; |
|
390 | + |
|
391 | + $vardef ['source'] = 'non-db'; |
|
392 | + if (!empty($vnameLabel)) { |
|
393 | + $vardef ['vname'] = 'LBL_'.strtoupper($relationshipName.'_FROM_'.$vnameLabel).'_TITLE'; |
|
394 | + } else { |
|
395 | + $vardef ['vname'] = 'LBL_'.strtoupper($relationshipName.'_FROM_'.$sourceModule).'_TITLE'; |
|
396 | 396 | } |
397 | 397 | |
398 | - $vardef [ 'save' ] = true; // the magic value to tell SugarBean to save this relate field even though it is not listed in the $relationship_fields array |
|
398 | + $vardef ['save'] = true; // the magic value to tell SugarBean to save this relate field even though it is not listed in the $relationship_fields array |
|
399 | 399 | |
400 | 400 | // id_name matches the join_key_ column in the relationship table for the sourceModule - that is, the column in the relationship table containing the id of the corresponding field in the source module's table (vardef['table']) |
401 | - $vardef [ 'id_name' ] = $this->getIDName( $sourceModule ) ; |
|
401 | + $vardef ['id_name'] = $this->getIDName($sourceModule); |
|
402 | 402 | |
403 | 403 | // link cannot match id_name otherwise the $bean->$id_name value set from the POST is overwritten by the Link object created by this 'link' entry |
404 | - $vardef [ 'link' ] = $this->getValidDBName($relationshipName) ; // the name of the link field that points to the relationship - required for the save to function |
|
405 | - $vardef [ 'table' ] = $this->getTablename( $sourceModule ) ; |
|
406 | - $vardef [ 'module' ] = $sourceModule ; |
|
404 | + $vardef ['link'] = $this->getValidDBName($relationshipName); // the name of the link field that points to the relationship - required for the save to function |
|
405 | + $vardef ['table'] = $this->getTablename($sourceModule); |
|
406 | + $vardef ['module'] = $sourceModule; |
|
407 | 407 | |
408 | - require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ; |
|
409 | - $parsedModuleName = AbstractRelationships::parseDeployedModuleName( $sourceModule ) ; |
|
408 | + require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php'; |
|
409 | + $parsedModuleName = AbstractRelationships::parseDeployedModuleName($sourceModule); |
|
410 | 410 | |
411 | 411 | // now determine the appropriate 'rname' field for this relate |
412 | 412 | // the 'rname' points to the field in source module that contains the displayable name for the record |
413 | 413 | // usually this is 'name' but sometimes it is not... |
414 | 414 | |
415 | - $vardef [ 'rname' ] = 'name' ; |
|
416 | - if ( isset( $parsedModuleName['packageName'] ) ) |
|
415 | + $vardef ['rname'] = 'name'; |
|
416 | + if (isset($parsedModuleName['packageName'])) |
|
417 | 417 | { |
418 | - require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ; |
|
419 | - $mb = new ModuleBuilder ( ) ; |
|
420 | - $module = $mb->getPackageModule ( $parsedModuleName['packageName'] , $parsedModuleName['moduleName'] ) ; |
|
421 | - if (in_array( 'file' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
|
422 | - $vardef [ 'rname' ] = 'document_name' ; |
|
423 | - }elseif(in_array ( 'person' , array_keys ( $module->config [ 'templates' ] ) ) ){ |
|
424 | - $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
418 | + require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; |
|
419 | + $mb = new ModuleBuilder( ); |
|
420 | + $module = $mb->getPackageModule($parsedModuleName['packageName'], $parsedModuleName['moduleName']); |
|
421 | + if (in_array('file', array_keys($module->config ['templates']))) { |
|
422 | + $vardef ['rname'] = 'document_name'; |
|
423 | + }elseif (in_array('person', array_keys($module->config ['templates']))) { |
|
424 | + $vardef ['db_concat_fields'] = array(0 =>'first_name', 1 =>'last_name'); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | else |
428 | 428 | { |
429 | - switch ( strtolower( $sourceModule ) ) |
|
429 | + switch (strtolower($sourceModule)) |
|
430 | 430 | { |
431 | 431 | case 'prospects' : |
432 | - $vardef [ 'rname' ] = 'account_name' ; |
|
433 | - break ; |
|
432 | + $vardef ['rname'] = 'account_name'; |
|
433 | + break; |
|
434 | 434 | case 'documents' : |
435 | - $vardef [ 'rname' ] = 'document_name' ; |
|
436 | - break ; |
|
435 | + $vardef ['rname'] = 'document_name'; |
|
436 | + break; |
|
437 | 437 | case 'kbdocuments' : |
438 | - $vardef [ 'rname' ] = 'kbdocument_name' ; |
|
439 | - break ; |
|
438 | + $vardef ['rname'] = 'kbdocument_name'; |
|
439 | + break; |
|
440 | 440 | case 'leads' : |
441 | 441 | case 'contacts' : |
442 | 442 | // special handling as these modules lack a name column in the database; instead 'name' refers to a non-db field that concatenates first_name and last_name |
443 | 443 | // luckily, the relate field mechanism can handle this with an equivalent additional db_concat_fields entry |
444 | - $vardef [ 'rname' ] = 'name' ; |
|
445 | - $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
446 | - break ; |
|
444 | + $vardef ['rname'] = 'name'; |
|
445 | + $vardef ['db_concat_fields'] = array(0 =>'first_name', 1 =>'last_name'); |
|
446 | + break; |
|
447 | 447 | default : |
448 | 448 | // now see if we have any module inheriting from the 'file' template - records in file-type modules are named by the document_name field, not the usual 'name' field |
449 | - $object = $GLOBALS ['beanList'] [ $sourceModule ]; |
|
450 | - require_once ( $GLOBALS ['beanFiles'] [ $object ] ); |
|
449 | + $object = $GLOBALS ['beanList'] [$sourceModule]; |
|
450 | + require_once ($GLOBALS ['beanFiles'] [$object]); |
|
451 | 451 | $bean = new $object(); |
452 | - if ( isset ( $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
453 | - if(in_array ( 'file' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
454 | - $vardef [ 'rname' ] = 'document_name' ; |
|
455 | - }elseif(in_array ( 'person' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] )){ |
|
456 | - $vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ; |
|
452 | + if (isset ($GLOBALS ['dictionary'] [$object] ['templates'])) { |
|
453 | + if (in_array('file', $GLOBALS ['dictionary'] [$object] ['templates'])) { |
|
454 | + $vardef ['rname'] = 'document_name'; |
|
455 | + }elseif (in_array('person', $GLOBALS ['dictionary'] [$object] ['templates'])) { |
|
456 | + $vardef ['db_concat_fields'] = array(0 =>'first_name', 1 =>'last_name'); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | } |
463 | 463 | |
464 | - return $vardef ; |
|
464 | + return $vardef; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /* |
@@ -474,111 +474,111 @@ discard block |
||
474 | 474 | * @param string $relationshipType Cardinality of the relationship, for example, MB_ONETOONE or MB_ONETOMANY or MB_MANYTOMANY |
475 | 475 | * @param bool $checkExisting check if a realtionship with the given name is already depolyed in this instance. If so, we will clones its table and column names to preserve existing data. |
476 | 476 | */ |
477 | - function getRelationshipMetaData ($relationshipType, $checkExisting = true) |
|
477 | + function getRelationshipMetaData($relationshipType, $checkExisting = true) |
|
478 | 478 | { |
479 | 479 | global $dictionary; |
480 | - $relationshipName = $this->definition [ 'relationship_name' ] ; |
|
481 | - $lhs_module = $this->lhs_module ; |
|
482 | - $rhs_module = $this->rhs_module ; |
|
480 | + $relationshipName = $this->definition ['relationship_name']; |
|
481 | + $lhs_module = $this->lhs_module; |
|
482 | + $rhs_module = $this->rhs_module; |
|
483 | 483 | |
484 | - $lhs_table = $this->getTablename ( $lhs_module ) ; |
|
485 | - $rhs_table = $this->getTablename ( $rhs_module ) ; |
|
484 | + $lhs_table = $this->getTablename($lhs_module); |
|
485 | + $rhs_table = $this->getTablename($rhs_module); |
|
486 | 486 | |
487 | - $properties = array ( ) ; |
|
487 | + $properties = array( ); |
|
488 | 488 | |
489 | 489 | //bug 47903 |
490 | 490 | if ($checkExisting && !empty($dictionary[$relationshipName]) |
491 | - && !empty($dictionary[$relationshipName][ 'true_relationship_type' ]) |
|
492 | - && $dictionary[$relationshipName][ 'true_relationship_type' ] == $relationshipType |
|
491 | + && !empty($dictionary[$relationshipName]['true_relationship_type']) |
|
492 | + && $dictionary[$relationshipName]['true_relationship_type'] == $relationshipType |
|
493 | 493 | && !empty($dictionary[$relationshipName]['relationships'][$relationshipName])) |
494 | 494 | { |
495 | 495 | //bug 51336 |
496 | - $properties [ 'true_relationship_type' ] = $relationshipType ; |
|
496 | + $properties ['true_relationship_type'] = $relationshipType; |
|
497 | 497 | $rel_properties = $dictionary[$relationshipName]['relationships'][$relationshipName]; |
498 | 498 | } else |
499 | 499 | { |
500 | 500 | // first define section 1, the relationship element of the metadata entry |
501 | 501 | |
502 | - $rel_properties = array ( ) ; |
|
503 | - $rel_properties [ 'lhs_module' ] = $lhs_module ; |
|
504 | - $rel_properties [ 'lhs_table' ] = $lhs_table ; |
|
505 | - $rel_properties [ 'lhs_key' ] = 'id' ; |
|
506 | - $rel_properties [ 'rhs_module' ] = $rhs_module ; |
|
507 | - $rel_properties [ 'rhs_table' ] = $rhs_table ; |
|
508 | - $rel_properties [ 'rhs_key' ] = 'id' ; |
|
502 | + $rel_properties = array( ); |
|
503 | + $rel_properties ['lhs_module'] = $lhs_module; |
|
504 | + $rel_properties ['lhs_table'] = $lhs_table; |
|
505 | + $rel_properties ['lhs_key'] = 'id'; |
|
506 | + $rel_properties ['rhs_module'] = $rhs_module; |
|
507 | + $rel_properties ['rhs_table'] = $rhs_table; |
|
508 | + $rel_properties ['rhs_key'] = 'id'; |
|
509 | 509 | |
510 | 510 | // because the implementation of one-to-many relationships within SugarBean does not use a join table and so requires schema changes to add a foreign key for each new relationship, |
511 | 511 | // we currently implement all new relationships as many-to-many regardless of the real type and enforce cardinality through the relate fields and subpanels |
512 | - $rel_properties [ 'relationship_type' ] = MB_MANYTOMANY ; |
|
512 | + $rel_properties ['relationship_type'] = MB_MANYTOMANY; |
|
513 | 513 | // but as we need to display the true cardinality in Studio and ModuleBuilder we also record the actual relationship type |
514 | 514 | // this property is only used by Studio/MB |
515 | - $properties [ 'true_relationship_type' ] = $relationshipType ; |
|
515 | + $properties ['true_relationship_type'] = $relationshipType; |
|
516 | 516 | if ($this->from_studio) |
517 | - $properties [ 'from_studio' ] = true; |
|
517 | + $properties ['from_studio'] = true; |
|
518 | 518 | |
519 | - $rel_properties [ 'join_table' ] = $this->getValidDBName ( $relationshipName."_c" ) ; |
|
519 | + $rel_properties ['join_table'] = $this->getValidDBName($relationshipName."_c"); |
|
520 | 520 | // a and b are in case the module relates to itself |
521 | - $rel_properties [ 'join_key_lhs' ] = $this->getJoinKeyLHS() ; |
|
522 | - $rel_properties [ 'join_key_rhs' ] = $this->getJoinKeyRHS() ; |
|
521 | + $rel_properties ['join_key_lhs'] = $this->getJoinKeyLHS(); |
|
522 | + $rel_properties ['join_key_rhs'] = $this->getJoinKeyRHS(); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | // set the extended properties if they exist = for now, many-to-many definitions do not have to contain a role_column even if role_column_value is set; we'll just create a likely name if missing |
526 | - if (isset ( $this->definition [ 'relationship_role_column_value' ] )) |
|
526 | + if (isset ($this->definition ['relationship_role_column_value'])) |
|
527 | 527 | { |
528 | - if (! isset ( $this->definition [ 'relationship_role_column' ] )) |
|
529 | - $this->definition [ 'relationship_role_column' ] = 'relationship_role_column' ; |
|
530 | - $rel_properties [ 'relationship_role_column' ] = $this->definition [ 'relationship_role_column' ] ; |
|
531 | - $rel_properties [ 'relationship_role_column_value' ] = $this->definition [ 'relationship_role_column_value' ] ; |
|
528 | + if (!isset ($this->definition ['relationship_role_column'])) |
|
529 | + $this->definition ['relationship_role_column'] = 'relationship_role_column'; |
|
530 | + $rel_properties ['relationship_role_column'] = $this->definition ['relationship_role_column']; |
|
531 | + $rel_properties ['relationship_role_column_value'] = $this->definition ['relationship_role_column_value']; |
|
532 | 532 | } |
533 | 533 | |
534 | - $properties [ 'relationships' ] [ $relationshipName ] = $rel_properties ; |
|
534 | + $properties ['relationships'] [$relationshipName] = $rel_properties; |
|
535 | 535 | |
536 | 536 | // construct section 2, the name of the join table |
537 | 537 | |
538 | - $properties [ 'table' ] = $rel_properties [ 'join_table' ] ; |
|
538 | + $properties ['table'] = $rel_properties ['join_table']; |
|
539 | 539 | |
540 | 540 | // now construct section 3, the fields in the join table |
541 | 541 | |
542 | - $properties [ 'fields' ] [] = array ( 'name' => 'id' , 'type' => 'varchar' , 'len' => 36 ) ; |
|
543 | - $properties [ 'fields' ] [] = array ( 'name' => 'date_modified' , 'type' => 'datetime' ) ; |
|
544 | - $properties [ 'fields' ] [] = array ( 'name' => 'deleted' , 'type' => 'bool' , 'len' => '1' , 'default' => '0' , 'required' => true ) ; |
|
545 | - $properties [ 'fields' ] [] = array ( 'name' => $rel_properties [ 'join_key_lhs' ] , 'type' => 'varchar' , 'len' => 36 ) ; |
|
546 | - $properties [ 'fields' ] [] = array ( 'name' => $rel_properties [ 'join_key_rhs' ] , 'type' => 'varchar' , 'len' => 36 ) ; |
|
547 | - if (strtolower ( $lhs_module ) == 'documents' || strtolower ( $rhs_module ) == 'documents' ) |
|
542 | + $properties ['fields'] [] = array('name' => 'id', 'type' => 'varchar', 'len' => 36); |
|
543 | + $properties ['fields'] [] = array('name' => 'date_modified', 'type' => 'datetime'); |
|
544 | + $properties ['fields'] [] = array('name' => 'deleted', 'type' => 'bool', 'len' => '1', 'default' => '0', 'required' => true); |
|
545 | + $properties ['fields'] [] = array('name' => $rel_properties ['join_key_lhs'], 'type' => 'varchar', 'len' => 36); |
|
546 | + $properties ['fields'] [] = array('name' => $rel_properties ['join_key_rhs'], 'type' => 'varchar', 'len' => 36); |
|
547 | + if (strtolower($lhs_module) == 'documents' || strtolower($rhs_module) == 'documents') |
|
548 | 548 | { |
549 | - $properties [ 'fields' ] [] = array ( 'name' => 'document_revision_id' , 'type' => 'varchar' , 'len' => '36' ) ; |
|
549 | + $properties ['fields'] [] = array('name' => 'document_revision_id', 'type' => 'varchar', 'len' => '36'); |
|
550 | 550 | } |
551 | 551 | // if we have an extended relationship condition, then add in the corresponding relationship_role_column to the relationship (join) table |
552 | 552 | // for now this is restricted to extended relationships that can be specified by a varchar |
553 | - if (isset ( $this->definition [ 'relationship_role_column_value' ] )) |
|
553 | + if (isset ($this->definition ['relationship_role_column_value'])) |
|
554 | 554 | { |
555 | - $properties [ 'fields' ] [] = array ( 'name' => $this->definition [ 'relationship_role_column' ] , 'type' => 'varchar' ) ; |
|
555 | + $properties ['fields'] [] = array('name' => $this->definition ['relationship_role_column'], 'type' => 'varchar'); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // finally, wrap up with section 4, the indices on the join table |
559 | 559 | |
560 | - $indexBase = $this->getValidDBName ( $relationshipName ) ; |
|
561 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . 'spk' , 'type' => 'primary' , 'fields' => array ( 'id' ) ) ; |
|
560 | + $indexBase = $this->getValidDBName($relationshipName); |
|
561 | + $properties ['indices'] [] = array('name' => $indexBase.'spk', 'type' => 'primary', 'fields' => array('id')); |
|
562 | 562 | |
563 | 563 | switch ($relationshipType) |
564 | 564 | { |
565 | 565 | case MB_ONETOONE: |
566 | - $alternateKeys = array () ; |
|
567 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_ida1' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_lhs' ] ) ) ; |
|
568 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_idb2' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_rhs' ] ) ) ; |
|
566 | + $alternateKeys = array(); |
|
567 | + $properties ['indices'] [] = array('name' => $indexBase.'_ida1', 'type' => 'index', 'fields' => array($rel_properties ['join_key_lhs'])); |
|
568 | + $properties ['indices'] [] = array('name' => $indexBase.'_idb2', 'type' => 'index', 'fields' => array($rel_properties ['join_key_rhs'])); |
|
569 | 569 | break; |
570 | 570 | case MB_ONETOMANY : |
571 | - $alternateKeys = array ( $rel_properties [ 'join_key_rhs' ] ) ; |
|
572 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_ida1' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_lhs' ] ) ) ; |
|
571 | + $alternateKeys = array($rel_properties ['join_key_rhs']); |
|
572 | + $properties ['indices'] [] = array('name' => $indexBase.'_ida1', 'type' => 'index', 'fields' => array($rel_properties ['join_key_lhs'])); |
|
573 | 573 | break; |
574 | 574 | default: |
575 | - $alternateKeys = array ( $rel_properties [ 'join_key_lhs' ] , $rel_properties [ 'join_key_rhs' ] ) ; |
|
575 | + $alternateKeys = array($rel_properties ['join_key_lhs'], $rel_properties ['join_key_rhs']); |
|
576 | 576 | } |
577 | 577 | |
578 | - if (count($alternateKeys)>0) |
|
579 | - $properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_alt' , 'type' => 'alternate_key' , 'fields' => $alternateKeys ) ; // type must be set to alternate_key for Link.php to correctly update an existing record rather than inserting a copy - it uses the fields in this array as the keys to check if a duplicate record already exists |
|
578 | + if (count($alternateKeys) > 0) |
|
579 | + $properties ['indices'] [] = array('name' => $indexBase.'_alt', 'type' => 'alternate_key', 'fields' => $alternateKeys); // type must be set to alternate_key for Link.php to correctly update an existing record rather than inserting a copy - it uses the fields in this array as the keys to check if a duplicate record already exists |
|
580 | 580 | |
581 | - return $properties ; |
|
581 | + return $properties; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | * Used primarily in UndeployedRelationships to ensure that the subpanels we construct for Activities get their data from the correct relationships |
592 | 592 | * @param string $activitiesSubModuleName Name of the activities submodule, such as Tasks |
593 | 593 | */ |
594 | - function getActivitiesSubModuleRelationshipName ( $activitiesSubModuleName ) |
|
594 | + function getActivitiesSubModuleRelationshipName($activitiesSubModuleName) |
|
595 | 595 | { |
596 | - return $this->lhs_module . "_" . strtolower ( $activitiesSubModuleName ) ; |
|
596 | + return $this->lhs_module."_".strtolower($activitiesSubModuleName); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /* |
@@ -604,10 +604,10 @@ discard block |
||
604 | 604 | * @param string $ensureUnique |
605 | 605 | * @return string Valid column name trimmed to right length and with invalid characters removed |
606 | 606 | */ |
607 | - static function getValidDBName ($name, $ensureUnique = true) |
|
607 | + static function getValidDBName($name, $ensureUnique = true) |
|
608 | 608 | { |
609 | 609 | |
610 | - require_once 'modules/ModuleBuilder/parsers/constants.php' ; |
|
610 | + require_once 'modules/ModuleBuilder/parsers/constants.php'; |
|
611 | 611 | return getValidDBName($name, $ensureUnique, MB_MAXDBIDENTIFIERLENGTH); |
612 | 612 | } |
613 | 613 | |
@@ -616,25 +616,25 @@ discard block |
||
616 | 616 | * @param string $type Relationship type |
617 | 617 | * @return string Canonical type |
618 | 618 | */ |
619 | - static function parseRelationshipType ($type) |
|
619 | + static function parseRelationshipType($type) |
|
620 | 620 | { |
621 | - $type = strtolower ( $type ) ; |
|
622 | - $type = preg_replace ( '/[^\w]+/i', '', strtolower ( $type ) ) ; |
|
623 | - $canonicalTypes = array ( ) ; |
|
624 | - foreach ( array ( MB_ONETOONE , MB_ONETOMANY , MB_MANYTOMANY , MB_MANYTOONE) as $canonicalType ) |
|
621 | + $type = strtolower($type); |
|
622 | + $type = preg_replace('/[^\w]+/i', '', strtolower($type)); |
|
623 | + $canonicalTypes = array( ); |
|
624 | + foreach (array(MB_ONETOONE, MB_ONETOMANY, MB_MANYTOMANY, MB_MANYTOONE) as $canonicalType) |
|
625 | 625 | { |
626 | - if ($type == preg_replace ( '/[^\w]+/i', '', strtolower ( $canonicalType ) )) |
|
627 | - return $canonicalType ; |
|
626 | + if ($type == preg_replace('/[^\w]+/i', '', strtolower($canonicalType))) |
|
627 | + return $canonicalType; |
|
628 | 628 | } |
629 | 629 | // ok, we give up... |
630 | - return MB_MANYTOMANY ; |
|
630 | + return MB_MANYTOMANY; |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
634 | 634 | function getJoinKeyLHS() |
635 | 635 | { |
636 | 636 | if (!isset($this->joinKeyLHS)) |
637 | - $this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ; |
|
637 | + $this->joinKeyLHS = $this->getValidDBName($this->relationship_name.$this->lhs_module."_ida", true); |
|
638 | 638 | |
639 | 639 | return $this->joinKeyLHS; |
640 | 640 | } |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | function getJoinKeyRHS() |
643 | 643 | { |
644 | 644 | if (!isset($this->joinKeyRHS)) |
645 | - $this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ; |
|
645 | + $this->joinKeyRHS = $this->getValidDBName($this->relationship_name.$this->rhs_module."_idb", true); |
|
646 | 646 | |
647 | 647 | return $this->joinKeyRHS; |
648 | 648 | } |
@@ -652,9 +652,9 @@ discard block |
||
652 | 652 | * @param string $sourceModule The name of the primary module in the relationship |
653 | 653 | * @return string Name of the id field |
654 | 654 | */ |
655 | - function getIDName( $sourceModule ) |
|
655 | + function getIDName($sourceModule) |
|
656 | 656 | { |
657 | - return ($sourceModule == $this->lhs_module ) ? $this->getJoinKeyLHS() : $this->getJoinKeyRHS() ; |
|
657 | + return ($sourceModule == $this->lhs_module) ? $this->getJoinKeyLHS() : $this->getJoinKeyRHS(); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /* |
@@ -662,42 +662,42 @@ discard block |
||
662 | 662 | * @param string $moduleName Name of the module for which we are to find the table |
663 | 663 | * @return string Tablename |
664 | 664 | */ |
665 | - protected function getTablename ($moduleName) |
|
665 | + protected function getTablename($moduleName) |
|
666 | 666 | { |
667 | 667 | // Check the moduleName exists in the beanList before calling get_module_info - Activities is the main culprit here |
668 | - if (isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] )) |
|
668 | + if (isset ($GLOBALS ['beanList'] [$moduleName])) |
|
669 | 669 | { |
670 | - $module = get_module_info ( $moduleName ) ; |
|
671 | - return $module->table_name ; |
|
670 | + $module = get_module_info($moduleName); |
|
671 | + return $module->table_name; |
|
672 | 672 | } |
673 | - return strtolower ( $moduleName ) ; |
|
673 | + return strtolower($moduleName); |
|
674 | 674 | } |
675 | 675 | |
676 | - public function getTitleKey($left=false){ |
|
677 | - if(!$this->is_custom && !$left && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){ |
|
676 | + public function getTitleKey($left = false) { |
|
677 | + if (!$this->is_custom && !$left && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")) { |
|
678 | 678 | include("modules/{$this->rhs_module}/metadata/subpaneldefs.php"); |
679 | - if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){ |
|
679 | + if (isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])) { |
|
680 | 680 | return $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key']; |
681 | 681 | } |
682 | - }else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){ |
|
682 | + } else if (!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")) { |
|
683 | 683 | include("modules/{$this->lhs_module}/metadata/subpaneldefs.php"); |
684 | - if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){ |
|
684 | + if (isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])) { |
|
685 | 685 | return $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key']; |
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
689 | - if($left){ |
|
689 | + if ($left) { |
|
690 | 690 | $titleKeyName = $this->getRightModuleSystemLabel(); |
691 | 691 | $sourceModule = $this->rhs_module; |
692 | - }else{ |
|
692 | + } else { |
|
693 | 693 | $titleKeyName = $this->getLeftModuleSystemLabel(); |
694 | 694 | $sourceModule = $this->lhs_module; |
695 | 695 | } |
696 | 696 | |
697 | - if(!empty($titleKeyName)){ |
|
698 | - $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $titleKeyName ) . '_TITLE' ; |
|
699 | - }else{ |
|
700 | - $title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $sourceModule ) . '_TITLE' ; |
|
697 | + if (!empty($titleKeyName)) { |
|
698 | + $title_key = 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$titleKeyName).'_TITLE'; |
|
699 | + } else { |
|
700 | + $title_key = 'LBL_'.strtoupper($this->relationship_name.'_FROM_'.$sourceModule).'_TITLE'; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | return $title_key; |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | // have different actual relationship names other than <relationshipName> |
67 | 67 | // e.g $dictionary[ 'quotes_accounts' ] has two relationships: quotes_billto_accounts, quotes_shipto_accounts |
68 | 68 | protected $specialCaseBaseNames = array( 'quotes_accounts', |
69 | - 'quotes_contacts', |
|
70 | - 'emails_beans', |
|
71 | - 'linked_documents', |
|
72 | - 'project_relation', |
|
73 | - 'prospect_lists_prospects', |
|
74 | - 'queues_beans', |
|
75 | - 'queues_queue', |
|
76 | - 'tracker_sessions' |
|
77 | - ); |
|
69 | + 'quotes_contacts', |
|
70 | + 'emails_beans', |
|
71 | + 'linked_documents', |
|
72 | + 'project_relation', |
|
73 | + 'prospect_lists_prospects', |
|
74 | + 'queues_beans', |
|
75 | + 'queues_queue', |
|
76 | + 'tracker_sessions' |
|
77 | + ); |
|
78 | 78 | /* |
79 | 79 | * Find all deployed modules that can participate in a relationship |
80 | 80 | * Return a list of modules with associated subpanels |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | protected function build ($basepath , $installDefPrefix , $relationships ) |
334 | 334 | { |
335 | 335 | global $sugar_config; |
336 | - // keep the relationships data separate from any other build data by ading /relationships to the basepath |
|
336 | + // keep the relationships data separate from any other build data by ading /relationships to the basepath |
|
337 | 337 | $basepath .= '/relationships' ; |
338 | 338 | |
339 | 339 | $installDefs = array ( ) ; |
@@ -393,34 +393,34 @@ discard block |
||
393 | 393 | { |
394 | 394 | global $sugar_config; |
395 | 395 | |
396 | - mkdir_recursive ( "$basepath/language" ) ; |
|
396 | + mkdir_recursive ( "$basepath/language" ) ; |
|
397 | 397 | |
398 | - $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ; |
|
398 | + $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ; |
|
399 | 399 | $installDefs = array ( ) ; |
400 | 400 | foreach ( $labelDefinitions as $definition ) |
401 | 401 | { |
402 | - $mod_strings = array(); |
|
403 | - $app_list_strings = array(); |
|
402 | + $mod_strings = array(); |
|
403 | + $app_list_strings = array(); |
|
404 | 404 | |
405 | - $out = $headerString; |
|
405 | + $out = $headerString; |
|
406 | 406 | |
407 | - $filename = "{$basepath}/language/{$definition['module']}.php" ; |
|
407 | + $filename = "{$basepath}/language/{$definition['module']}.php" ; |
|
408 | 408 | |
409 | - if (file_exists ( $filename )) |
|
410 | - include ($filename); |
|
409 | + if (file_exists ( $filename )) |
|
410 | + include ($filename); |
|
411 | 411 | |
412 | 412 | |
413 | 413 | //Check for app strings |
414 | 414 | $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveLabels(): saving the following to {$filename}" |
415 | - . print_r ( $definition, true ) ) ; |
|
415 | + . print_r ( $definition, true ) ) ; |
|
416 | 416 | if ($definition['module'] == 'application') { |
417 | - $app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
418 | - foreach ($app_list_strings as $key => $val) |
|
419 | - $out .= override_value_to_string_recursive2('app_list_strings', $key, $val); |
|
417 | + $app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
418 | + foreach ($app_list_strings as $key => $val) |
|
419 | + $out .= override_value_to_string_recursive2('app_list_strings', $key, $val); |
|
420 | 420 | } else { |
421 | - $mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
422 | - foreach ($mod_strings as $key => $val) |
|
423 | - $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
|
421 | + $mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
422 | + foreach ($mod_strings as $key => $val) |
|
423 | + $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $fh = fopen ( $filename, 'w' ) ; |
@@ -430,17 +430,17 @@ discard block |
||
430 | 430 | |
431 | 431 | foreach($sugar_config['languages'] as $lk => $lv) |
432 | 432 | { |
433 | - $installDefs [ $definition [ 'module' ] . "_$lk" ] = array ( |
|
434 | - 'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" , |
|
435 | - 'to_module' => $definition [ 'module' ] , |
|
436 | - 'language' => $lk |
|
437 | - ) ; |
|
433 | + $installDefs [ $definition [ 'module' ] . "_$lk" ] = array ( |
|
434 | + 'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" , |
|
435 | + 'to_module' => $definition [ 'module' ] , |
|
436 | + 'language' => $lk |
|
437 | + ) ; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /* do not use the following write_array_to_file method to write the label file - |
441 | 441 | * module installer appends each of the label files together (as it does for all files) |
442 | 442 | * into a combined label file and so the last $mod_strings is the only one received by the application */ |
443 | - // write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ; |
|
443 | + // write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | return $installDefs ; |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | $relName = $moduleName; |
535 | 535 | foreach ( $definitions as $definition ) |
536 | 536 | { |
537 | - if (!empty($definition['relationship'])) |
|
538 | - { |
|
539 | - $relName = $definition['relationship']; |
|
540 | - break; |
|
541 | - } |
|
537 | + if (!empty($definition['relationship'])) |
|
538 | + { |
|
539 | + $relName = $definition['relationship']; |
|
540 | + break; |
|
541 | + } |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | $filename = "$basepath/vardefs/{$relName}_{$moduleName}.php" ; |
@@ -547,14 +547,14 @@ discard block |
||
547 | 547 | foreach ( $definitions as $definition ) |
548 | 548 | { |
549 | 549 | $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): saving the following to {$filename}" . print_r ( $definition, true ) ) ; |
550 | - $out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = ' |
|
551 | - . var_export_helper($definition) . ";\n"; |
|
550 | + $out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = ' |
|
551 | + . var_export_helper($definition) . ";\n"; |
|
552 | 552 | } |
553 | 553 | file_put_contents($filename, $out); |
554 | 554 | |
555 | 555 | $installDefs [ $moduleName ] = array ( |
556 | - 'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" , |
|
557 | - 'to_module' => $moduleName |
|
556 | + 'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" , |
|
557 | + 'to_module' => $moduleName |
|
558 | 558 | ) ; |
559 | 559 | } |
560 | 560 |
@@ -1,6 +1,6 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - return $installDefs ; |
|
376 | + return $installDefs; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /* |
@@ -389,52 +389,52 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | 3 | die ( 'Not A Valid Entry Point' ) ; |
4 | +} |
|
4 | 5 | |
5 | 6 | /********************************************************************************* |
6 | 7 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -97,8 +98,9 @@ discard block |
||
97 | 98 | while ( list( $moduleName , $module ) = each($browser->modules) ) |
98 | 99 | { |
99 | 100 | // do not include the submodules of Activities as already have the parent... |
100 | - if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities )) |
|
101 | - continue ; |
|
101 | + if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities )) { |
|
102 | + continue ; |
|
103 | + } |
|
102 | 104 | $providedSubpanels = $module->getProvidedSubpanels(); |
103 | 105 | if ( $providedSubpanels !== false ) { |
104 | 106 | $relatableModules [ $module->module ] = $providedSubpanels; |
@@ -111,8 +113,9 @@ discard block |
||
111 | 113 | |
112 | 114 | static function validSubpanel ($filename) |
113 | 115 | { |
114 | - if (! file_exists ( $filename )) |
|
115 | - return false ; |
|
116 | + if (! file_exists ( $filename )) { |
|
117 | + return false ; |
|
118 | + } |
|
116 | 119 | |
117 | 120 | include $filename ; |
118 | 121 | return (isset ( $subpanel_layout ) && (isset ( $subpanel_layout [ 'top_buttons' ] ) && isset ( $subpanel_layout [ 'list_fields' ] ))) ; |
@@ -127,8 +130,9 @@ discard block |
||
127 | 130 | $list = array ( ) ; |
128 | 131 | foreach ( $this->relationships as $name => $relationship ) |
129 | 132 | { |
130 | - if (! $relationship->deleted ()) |
|
131 | - $list [ $name ] = $name ; |
|
133 | + if (! $relationship->deleted ()) { |
|
134 | + $list [ $name ] = $name ; |
|
135 | + } |
|
132 | 136 | } |
133 | 137 | return $list ; |
134 | 138 | } |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | if ($relationship = $this->get ( $_REQUEST [ 'relationship_name' ] )) |
173 | 177 | { |
174 | 178 | unset( $definition[ 'relationship_name' ] ) ; // in case the related modules have changed; this name is probably no longer appropriate |
175 | - if (! $relationship->readonly ()) |
|
176 | - $this->delete ( $_REQUEST [ 'relationship_name' ] ) ; |
|
179 | + if (! $relationship->readonly ()) { |
|
180 | + $this->delete ( $_REQUEST [ 'relationship_name' ] ) ; |
|
181 | + } |
|
177 | 182 | } |
178 | 183 | } |
179 | 184 | |
@@ -298,8 +303,7 @@ discard block |
||
298 | 303 | { |
299 | 304 | $name = $basename . '_1' ; |
300 | 305 | $suffix = 2 ; |
301 | - } |
|
302 | - else |
|
306 | + } else |
|
303 | 307 | { |
304 | 308 | $name = $basename ; |
305 | 309 | $suffix = 1 ; |
@@ -351,9 +355,11 @@ discard block |
||
351 | 355 | { |
352 | 356 | $metadata = $relationship->$buildMethod () ; |
353 | 357 | |
354 | - if (count ( $metadata ) > 0) // don't clutter up the filesystem with empty files... |
|
358 | + if (count ( $metadata ) > 0) { |
|
359 | + // don't clutter up the filesystem with empty files... |
|
355 | 360 | { |
356 | 361 | $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": BUILD is running METHOD $saveMethod" ) ; |
362 | + } |
|
357 | 363 | $installDef = $this->$saveMethod ( $basepath, $installDefPrefix, $name, $metadata ) ; |
358 | 364 | |
359 | 365 | // some save methods (e.g., saveRelateFieldDefinition) handle the installDefs internally and so return null |
@@ -406,8 +412,9 @@ discard block |
||
406 | 412 | |
407 | 413 | $filename = "{$basepath}/language/{$definition['module']}.php" ; |
408 | 414 | |
409 | - if (file_exists ( $filename )) |
|
410 | - include ($filename); |
|
415 | + if (file_exists ( $filename )) { |
|
416 | + include ($filename); |
|
417 | + } |
|
411 | 418 | |
412 | 419 | |
413 | 420 | //Check for app strings |
@@ -415,12 +422,14 @@ discard block |
||
415 | 422 | . print_r ( $definition, true ) ) ; |
416 | 423 | if ($definition['module'] == 'application') { |
417 | 424 | $app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
418 | - foreach ($app_list_strings as $key => $val) |
|
419 | - $out .= override_value_to_string_recursive2('app_list_strings', $key, $val); |
|
425 | + foreach ($app_list_strings as $key => $val) { |
|
426 | + $out .= override_value_to_string_recursive2('app_list_strings', $key, $val); |
|
427 | + } |
|
420 | 428 | } else { |
421 | 429 | $mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
422 | - foreach ($mod_strings as $key => $val) |
|
423 | - $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
|
430 | + foreach ($mod_strings as $key => $val) { |
|
431 | + $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
|
432 | + } |
|
424 | 433 | } |
425 | 434 | |
426 | 435 | $fh = fopen ( $filename, 'w' ) ; |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | } |
285 | 285 | $module->setAppListStrings ( 'en_us', $appStrings ) ; |
286 | 286 | $module->save () ; |
287 | - //Bug42170================================ |
|
288 | - } |
|
287 | + //Bug42170================================ |
|
288 | + } |
|
289 | 289 | |
290 | 290 | // use an installDefPrefix of <basepath>/SugarModules for compatibility with the rest of ModuleBuilder |
291 | 291 | $this->installDefs = parent::build ( $basepath, "<basepath>/SugarModules", $relationships ) ; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $fieldsToAdd [$deployedModuleName] = $fieldName; |
419 | 419 | } |
420 | 420 | } |
421 | - } |
|
421 | + } |
|
422 | 422 | } |
423 | 423 | return array(array('additional_fields' => $fieldsToAdd)); |
424 | 424 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | 3 | die ( 'Not A Valid Entry Point' ) ; |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -270,8 +271,7 @@ discard block |
||
270 | 271 | $module->setAppListStrings ( 'en_us', $appStrings ) ; |
271 | 272 | $module->save () ; |
272 | 273 | |
273 | - } |
|
274 | - else |
|
274 | + } else |
|
275 | 275 | { |
276 | 276 | //Bug42170================================ |
277 | 277 | $appStrings = $module->getAppListStrings () ; |
@@ -333,8 +333,9 @@ discard block |
||
333 | 333 | $appStrings = $module->getAppListStrings () ; |
334 | 334 | foreach(getTypeDisplayList() as $key) |
335 | 335 | { |
336 | - if (isset($appStrings[$key][ $module->key_name ])) |
|
337 | - unset($appStrings[$key][ $module->key_name ]); |
|
336 | + if (isset($appStrings[$key][ $module->key_name ])) { |
|
337 | + unset($appStrings[$key][ $module->key_name ]); |
|
338 | + } |
|
338 | 339 | } |
339 | 340 | $module->setAppListStrings ( 'en_us', $appStrings ) ; |
340 | 341 | $module->save () ; |
@@ -351,8 +352,9 @@ discard block |
||
351 | 352 | { |
352 | 353 | |
353 | 354 | // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this... |
354 | - if ($relationship->getType () == MB_MANYTOMANY) |
|
355 | - return false ; |
|
355 | + if ($relationship->getType () == MB_MANYTOMANY) { |
|
356 | + return false ; |
|
357 | + } |
|
356 | 358 | |
357 | 359 | $successful = true ; |
358 | 360 | $layoutAdditions = $relationship->buildFieldsToLayouts () ; |
@@ -371,8 +373,7 @@ discard block |
||
371 | 373 | if (($actionAdd) ? $parser->addField ( array ( 'name' => $fieldName ) ) : $parser->removeField ( $fieldName )) |
372 | 374 | { |
373 | 375 | $parser->handleSave ( false ) ; |
374 | - } |
|
375 | - else |
|
376 | + } else |
|
376 | 377 | { |
377 | 378 | $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": couldn't " . (($actionAdd) ? "add" : "remove") . " $fieldName on $view layout for undeployed module $deployedModuleName" ) ; |
378 | 379 | $successful = false ; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | - die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | + die ('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | ********************************************************************************/ |
41 | 41 | |
42 | 42 | |
43 | -require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ; |
|
44 | -require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php' ; |
|
45 | -require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ; |
|
43 | +require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php'; |
|
44 | +require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php'; |
|
45 | +require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php'; |
|
46 | 46 | |
47 | 47 | class UndeployedRelationships extends AbstractRelationships implements RelationshipsInterface |
48 | 48 | { |
49 | 49 | |
50 | - protected $basepath ; // Base directory for the lhs_module |
|
51 | - protected $packageName ; |
|
52 | - private $activitiesToAdd ; // if we need to add in the composite Activities and History subpanels to the module during the build |
|
50 | + protected $basepath; // Base directory for the lhs_module |
|
51 | + protected $packageName; |
|
52 | + private $activitiesToAdd; // if we need to add in the composite Activities and History subpanels to the module during the build |
|
53 | 53 | |
54 | 54 | |
55 | 55 | /* |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | * Automatically loads in any saved relationships |
58 | 58 | * @param string $path The pathname of the base module directory |
59 | 59 | */ |
60 | - function __construct ($path) |
|
60 | + function __construct($path) |
|
61 | 61 | { |
62 | - $this->basepath = $path ; |
|
62 | + $this->basepath = $path; |
|
63 | 63 | // pull the module and package names out of the path |
64 | - $this->moduleName = basename ( $path, "/" ) ; // just in case there are any trailing / |
|
65 | - $this->packageName = basename ( dirname ( dirname ( $path ) ) ) ; // simpler than explode :) |
|
66 | - require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ; |
|
67 | - $mb = new ModuleBuilder ( ) ; |
|
68 | - $this->packageKey = $mb->getPackageKey ( $this->packageName ) ; |
|
64 | + $this->moduleName = basename($path, "/"); // just in case there are any trailing / |
|
65 | + $this->packageName = basename(dirname(dirname($path))); // simpler than explode :) |
|
66 | + require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; |
|
67 | + $mb = new ModuleBuilder( ); |
|
68 | + $this->packageKey = $mb->getPackageKey($this->packageName); |
|
69 | 69 | |
70 | - $this->load () ; |
|
70 | + $this->load(); |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | * Find all modules, deployed and undeployed, that can participate in a relationship |
76 | 76 | * @return array Array of [$module][$subpanel] |
77 | 77 | */ |
78 | - static function findRelatableModules ($includeActivitiesSubmodules = true) |
|
78 | + static function findRelatableModules($includeActivitiesSubmodules = true) |
|
79 | 79 | { |
80 | 80 | // first find all deployed modules that we might participate in a relationship |
81 | - $relatableModules = parent::findRelatableModules ($includeActivitiesSubmodules ) ; |
|
81 | + $relatableModules = parent::findRelatableModules($includeActivitiesSubmodules); |
|
82 | 82 | |
83 | 83 | // now add in the undeployed modules - those in custom/modulebuilder |
84 | 84 | // note that if a module exists in both deployed and undeployed forms, the subpanels from the undeployed form are used... |
85 | 85 | |
86 | - require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ; |
|
87 | - $mb = new ModuleBuilder ( ) ; |
|
88 | - $mb->getPackages () ; |
|
89 | - foreach ( $mb->getPackageList () as $packageName ) |
|
86 | + require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; |
|
87 | + $mb = new ModuleBuilder( ); |
|
88 | + $mb->getPackages(); |
|
89 | + foreach ($mb->getPackageList() as $packageName) |
|
90 | 90 | { |
91 | - $package = $mb->packages [ $packageName ] ; |
|
92 | - foreach ( $package->modules as $module ) |
|
91 | + $package = $mb->packages [$packageName]; |
|
92 | + foreach ($package->modules as $module) |
|
93 | 93 | { |
94 | - $relatableModules [ $package->key . "_" . $module->name ] = $module->getProvidedSubpanels () ; |
|
94 | + $relatableModules [$package->key."_".$module->name] = $module->getProvidedSubpanels(); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - return $relatableModules ; |
|
98 | + return $relatableModules; |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * that the admin may move them around or otherwise edit them before the module is deployed |
106 | 106 | * @param AbstractRelationship $relationship The relationship to add |
107 | 107 | */ |
108 | - function add ($relationship) |
|
108 | + function add($relationship) |
|
109 | 109 | { |
110 | - parent::add ( $relationship ) ; |
|
111 | - $this->addFieldsToUndeployedLayouts ( $relationship ) ; // must come after parent::add as we need the relationship_name in the relationships getFieldsToLayouts() which is called by addFieldsToUndeployedLayouts() |
|
110 | + parent::add($relationship); |
|
111 | + $this->addFieldsToUndeployedLayouts($relationship); // must come after parent::add as we need the relationship_name in the relationships getFieldsToLayouts() which is called by addFieldsToUndeployedLayouts() |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /* |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | * In future, if we need to actually track deleted relationships then just call $relationship->delete() instead |
117 | 117 | * @param string $relationshipName The unique name for this relationship, as returned by $relationship->getName() |
118 | 118 | */ |
119 | - function delete ($relationshipName) |
|
119 | + function delete($relationshipName) |
|
120 | 120 | { |
121 | - if ($relationship = $this->get ( $relationshipName )) |
|
121 | + if ($relationship = $this->get($relationshipName)) |
|
122 | 122 | { |
123 | - $this->removeFieldsFromUndeployedLayouts ( $relationship ) ; |
|
124 | - unset ( $this->relationships [ $relationshipName ] ) ; |
|
123 | + $this->removeFieldsFromUndeployedLayouts($relationship); |
|
124 | + unset ($this->relationships [$relationshipName]); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | 128 | /* |
129 | 129 | * Load the saved relationship definitions for this module |
130 | 130 | */ |
131 | - function load () |
|
131 | + function load() |
|
132 | 132 | { |
133 | - $this->relationships = parent::_load ( $this->basepath ) ; |
|
133 | + $this->relationships = parent::_load($this->basepath); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /* |
137 | 137 | * Save this modules relationship definitions out to a working file |
138 | 138 | */ |
139 | - function save () |
|
139 | + function save() |
|
140 | 140 | { |
141 | - parent::_save ( $this->relationships, $this->basepath ) ; |
|
141 | + parent::_save($this->relationships, $this->basepath); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /* |
@@ -146,24 +146,24 @@ discard block |
||
146 | 146 | * @param array definition The 5.0 relationship definition |
147 | 147 | * @return array The definition updated to 5.1 format |
148 | 148 | */ |
149 | - protected function _updateRelationshipDefinition ($definition) |
|
149 | + protected function _updateRelationshipDefinition($definition) |
|
150 | 150 | { |
151 | - if (isset ( $definition [ 'relate' ] )) |
|
151 | + if (isset ($definition ['relate'])) |
|
152 | 152 | { |
153 | - $newDefinition = array ( ) ; |
|
154 | - foreach ( array ( 'relate' => 'rhs_module' , 'rsub' => 'rhs_subpanel' , 'msub' => 'lhs_subpanel' , 'label' => 'label' ) as $oldParameter => $newParameter ) |
|
153 | + $newDefinition = array( ); |
|
154 | + foreach (array('relate' => 'rhs_module', 'rsub' => 'rhs_subpanel', 'msub' => 'lhs_subpanel', 'label' => 'label') as $oldParameter => $newParameter) |
|
155 | 155 | { |
156 | - if (isset ( $definition [ $oldParameter ] )) |
|
156 | + if (isset ($definition [$oldParameter])) |
|
157 | 157 | { |
158 | - $definition [ $newParameter ] = $definition [ $oldParameter ] ; |
|
159 | - unset ( $definition [ $oldParameter ] ) ; |
|
158 | + $definition [$newParameter] = $definition [$oldParameter]; |
|
159 | + unset ($definition [$oldParameter]); |
|
160 | 160 | } |
161 | 161 | } |
162 | - $definition [ 'lhs_module' ] = "{$this->packageKey}_{$this->moduleName}" ; |
|
162 | + $definition ['lhs_module'] = "{$this->packageKey}_{$this->moduleName}"; |
|
163 | 163 | // finally update the relationship name |
164 | - unset ( $definition [ 'name' ] ) ; // clear the oldstyle name |
|
164 | + unset ($definition ['name']); // clear the oldstyle name |
|
165 | 165 | } |
166 | - return $definition ; |
|
166 | + return $definition; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /* |
@@ -171,30 +171,30 @@ discard block |
||
171 | 171 | * The set of all relevant relationships for undeployed modules is the superset of that for deployed modules and all of the relationships known to ModuleBuilder |
172 | 172 | * @return array Set of all relevant relationships |
173 | 173 | */ |
174 | - protected function getAllRelationships () |
|
174 | + protected function getAllRelationships() |
|
175 | 175 | { |
176 | 176 | // start with the set of relationships known to this module plus those already deployed |
177 | - $allRelationships = array_merge ( $this->relationships, parent::getDeployedRelationships () ) ; |
|
177 | + $allRelationships = array_merge($this->relationships, parent::getDeployedRelationships()); |
|
178 | 178 | |
179 | 179 | // add in the relationships known to ModuleBuilder |
180 | - require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ; |
|
181 | - $mb = new ModuleBuilder ( ) ; |
|
182 | - $mb->getPackages () ; |
|
183 | - foreach ( $mb->getPackageList () as $packageName ) |
|
180 | + require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; |
|
181 | + $mb = new ModuleBuilder( ); |
|
182 | + $mb->getPackages(); |
|
183 | + foreach ($mb->getPackageList() as $packageName) |
|
184 | 184 | { |
185 | - $package = $mb->packages [ $packageName ] ; |
|
186 | - foreach ( $package->modules as $module ) |
|
185 | + $package = $mb->packages [$packageName]; |
|
186 | + foreach ($package->modules as $module) |
|
187 | 187 | { |
188 | 188 | |
189 | - foreach ( $module->relationships->getRelationshipList () as $relationshipName ) |
|
189 | + foreach ($module->relationships->getRelationshipList() as $relationshipName) |
|
190 | 190 | { |
191 | - $relationship = $module->relationships->get ( $relationshipName ) ; |
|
192 | - $allRelationships [ $relationship->getName () ] = $relationship->getDefinition () ; |
|
191 | + $relationship = $module->relationships->get($relationshipName); |
|
192 | + $allRelationships [$relationship->getName()] = $relationship->getDefinition(); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - return $allRelationships ; |
|
197 | + return $allRelationships; |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | * This function is called from the view when constructing a new relationship |
205 | 205 | * @param AbstractRelationship $relationship The relationship to be enforced |
206 | 206 | */ |
207 | - public function enforceRelationshipOnly ($relationship) |
|
207 | + public function enforceRelationshipOnly($relationship) |
|
208 | 208 | { |
209 | 209 | // if we already have a relationship between this lhs_module and this rhs_module then set RelationshipOnly flag |
210 | - foreach ( $this->relationships as $rel ) |
|
210 | + foreach ($this->relationships as $rel) |
|
211 | 211 | { |
212 | 212 | if ($rel->lhs_module == $relationship->lhs_module && $rel->rhs_module == $relationship->rhs_module) |
213 | 213 | { |
214 | - $rel->setRelationship_only () ; |
|
215 | - break ; |
|
214 | + $rel->setRelationship_only(); |
|
215 | + break; |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * Translate the set of relationship objects into files that the Module Loader can work with |
226 | 226 | * @param $basepath string Pathname of the directory to contain the build |
227 | 227 | */ |
228 | - function build ($basepath = null, $installDefPrefix = null, $relationships = null) |
|
228 | + function build($basepath = null, $installDefPrefix = null, $relationships = null) |
|
229 | 229 | { |
230 | 230 | |
231 | 231 | // first expand out any reference to Activities to its submodules |
@@ -233,62 +233,62 @@ discard block |
||
233 | 233 | // as the relationship name, that must be unique |
234 | 234 | // the only special case is the subpanel for Activities, which is a composite, and is applied only once for all the submodules - this is handled in saveSubpanelDefinitions() for Undeployed modules |
235 | 235 | |
236 | - $relationships = array ( ) ; |
|
237 | - $this->activitiesToAdd = false ; |
|
238 | - foreach ( $this->relationships as $relationshipName => $relationship ) |
|
236 | + $relationships = array( ); |
|
237 | + $this->activitiesToAdd = false; |
|
238 | + foreach ($this->relationships as $relationshipName => $relationship) |
|
239 | 239 | { |
240 | - $definition = $relationship->getDefinition () ; |
|
240 | + $definition = $relationship->getDefinition(); |
|
241 | 241 | // activities will always appear on the rhs only - lhs will be always be this module in MB |
242 | - if (strtolower ( $definition [ 'rhs_module' ] ) == 'activities') |
|
242 | + if (strtolower($definition ['rhs_module']) == 'activities') |
|
243 | 243 | { |
244 | - $this->activitiesToAdd = true ; |
|
245 | - $relationshipName = $definition [ 'relationship_name' ] ; |
|
246 | - foreach ( self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName ) |
|
244 | + $this->activitiesToAdd = true; |
|
245 | + $relationshipName = $definition ['relationship_name']; |
|
246 | + foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName) |
|
247 | 247 | { |
248 | - $definition [ 'rhs_module' ] = $activitiesSubModuleName ; |
|
249 | - $definition [ 'for_activities' ] = true ; |
|
250 | - $definition [ 'relationship_name' ] = $relationshipName . '_' . $activitiesSubModuleLower ; |
|
251 | - $relationships [ $definition [ 'relationship_name' ] ] = RelationshipFactory::newRelationship ( $definition ) ; |
|
248 | + $definition ['rhs_module'] = $activitiesSubModuleName; |
|
249 | + $definition ['for_activities'] = true; |
|
250 | + $definition ['relationship_name'] = $relationshipName.'_'.$activitiesSubModuleLower; |
|
251 | + $relationships [$definition ['relationship_name']] = RelationshipFactory::newRelationship($definition); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } else |
255 | 255 | { |
256 | - $relationships [ $definition [ 'relationship_name' ] ] = $relationship ; |
|
256 | + $relationships [$definition ['relationship_name']] = $relationship; |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ; |
|
261 | - $mb = new ModuleBuilder ( ) ; |
|
262 | - $module = $mb->getPackageModule ( $this->packageName, $this->moduleName ) ; |
|
260 | + require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; |
|
261 | + $mb = new ModuleBuilder( ); |
|
262 | + $module = $mb->getPackageModule($this->packageName, $this->moduleName); |
|
263 | 263 | if ($this->activitiesToAdd) |
264 | 264 | { |
265 | - $appStrings = $module->getAppListStrings () ; |
|
266 | - foreach(getTypeDisplayList() as $typeDisplay) |
|
265 | + $appStrings = $module->getAppListStrings(); |
|
266 | + foreach (getTypeDisplayList() as $typeDisplay) |
|
267 | 267 | { |
268 | - $appStrings[$typeDisplay][$module->key_name] = $module->getlabel ( 'en_us', 'LBL_MODULE_TITLE' ) ; |
|
268 | + $appStrings[$typeDisplay][$module->key_name] = $module->getlabel('en_us', 'LBL_MODULE_TITLE'); |
|
269 | 269 | } |
270 | - $module->setAppListStrings ( 'en_us', $appStrings ) ; |
|
271 | - $module->save () ; |
|
270 | + $module->setAppListStrings('en_us', $appStrings); |
|
271 | + $module->save(); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | else |
275 | 275 | { |
276 | 276 | //Bug42170================================ |
277 | - $appStrings = $module->getAppListStrings () ; |
|
278 | - foreach(getTypeDisplayList() as $typeDisplay) |
|
277 | + $appStrings = $module->getAppListStrings(); |
|
278 | + foreach (getTypeDisplayList() as $typeDisplay) |
|
279 | 279 | { |
280 | - if(isset($appStrings[$typeDisplay][$module->key_name])) |
|
280 | + if (isset($appStrings[$typeDisplay][$module->key_name])) |
|
281 | 281 | { |
282 | 282 | unset($appStrings[$typeDisplay][$module->key_name]); |
283 | 283 | } |
284 | 284 | } |
285 | - $module->setAppListStrings ( 'en_us', $appStrings ) ; |
|
286 | - $module->save () ; |
|
285 | + $module->setAppListStrings('en_us', $appStrings); |
|
286 | + $module->save(); |
|
287 | 287 | //Bug42170================================ |
288 | 288 | } |
289 | 289 | |
290 | 290 | // use an installDefPrefix of <basepath>/SugarModules for compatibility with the rest of ModuleBuilder |
291 | - $this->installDefs = parent::build ( $basepath, "<basepath>/SugarModules", $relationships ) ; |
|
291 | + $this->installDefs = parent::build($basepath, "<basepath>/SugarModules", $relationships); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /* |
@@ -296,28 +296,28 @@ discard block |
||
296 | 296 | * Required by MBModule |
297 | 297 | * @param reference installDef Reference to the set of installDefs to which this relationship's installDefs should be added |
298 | 298 | */ |
299 | - function addInstallDefs (&$installDef) |
|
299 | + function addInstallDefs(&$installDef) |
|
300 | 300 | { |
301 | - foreach ( $this->installDefs as $name => $def ) |
|
301 | + foreach ($this->installDefs as $name => $def) |
|
302 | 302 | { |
303 | - if (! empty ( $def )) |
|
303 | + if (!empty ($def)) |
|
304 | 304 | { |
305 | - foreach ( $def as $val ) |
|
305 | + foreach ($def as $val) |
|
306 | 306 | { |
307 | - $installDef [ $name ] [] = $val ; |
|
307 | + $installDef [$name] [] = $val; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - private function addFieldsToUndeployedLayouts ($relationship) |
|
313 | + private function addFieldsToUndeployedLayouts($relationship) |
|
314 | 314 | { |
315 | - return $this->updateUndeployedLayout ( $relationship, true ) ; |
|
315 | + return $this->updateUndeployedLayout($relationship, true); |
|
316 | 316 | } |
317 | 317 | |
318 | - private function removeFieldsFromUndeployedLayouts ($relationship) |
|
318 | + private function removeFieldsFromUndeployedLayouts($relationship) |
|
319 | 319 | { |
320 | - return $this->updateUndeployedLayout ( $relationship, false ) ; |
|
320 | + return $this->updateUndeployedLayout($relationship, false); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -326,18 +326,18 @@ discard block |
||
326 | 326 | */ |
327 | 327 | private function removeAppLangStrings($relationship) { |
328 | 328 | $def = $relationship->getDefinition(); |
329 | - if (strtolower ( $def [ 'rhs_module' ] ) == 'activities' && !empty($_REQUEST [ 'view_package' ]) && !empty($_REQUEST [ 'view_module' ] )) |
|
329 | + if (strtolower($def ['rhs_module']) == 'activities' && !empty($_REQUEST ['view_package']) && !empty($_REQUEST ['view_module'])) |
|
330 | 330 | { |
331 | - $mb = new ModuleBuilder ( ) ; |
|
332 | - $module = $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ; |
|
333 | - $appStrings = $module->getAppListStrings () ; |
|
334 | - foreach(getTypeDisplayList() as $key) |
|
331 | + $mb = new ModuleBuilder( ); |
|
332 | + $module = $mb->getPackageModule($_REQUEST ['view_package'], $_REQUEST ['view_module']); |
|
333 | + $appStrings = $module->getAppListStrings(); |
|
334 | + foreach (getTypeDisplayList() as $key) |
|
335 | 335 | { |
336 | - if (isset($appStrings[$key][ $module->key_name ])) |
|
337 | - unset($appStrings[$key][ $module->key_name ]); |
|
336 | + if (isset($appStrings[$key][$module->key_name])) |
|
337 | + unset($appStrings[$key][$module->key_name]); |
|
338 | 338 | } |
339 | - $module->setAppListStrings ( 'en_us', $appStrings ) ; |
|
340 | - $module->save () ; |
|
339 | + $module->setAppListStrings('en_us', $appStrings); |
|
340 | + $module->save(); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -347,41 +347,41 @@ discard block |
||
347 | 347 | * @param boolean $actionAdd True if we are to add; false if to remove |
348 | 348 | * return null |
349 | 349 | */ |
350 | - private function updateUndeployedLayout ($relationship , $actionAdd = true) |
|
350 | + private function updateUndeployedLayout($relationship, $actionAdd = true) |
|
351 | 351 | { |
352 | 352 | |
353 | 353 | // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this... |
354 | - if ($relationship->getType () == MB_MANYTOMANY) |
|
355 | - return false ; |
|
354 | + if ($relationship->getType() == MB_MANYTOMANY) |
|
355 | + return false; |
|
356 | 356 | |
357 | - $successful = true ; |
|
358 | - $layoutAdditions = $relationship->buildFieldsToLayouts () ; |
|
357 | + $successful = true; |
|
358 | + $layoutAdditions = $relationship->buildFieldsToLayouts(); |
|
359 | 359 | |
360 | - require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ; |
|
361 | - foreach ( $layoutAdditions as $deployedModuleName => $fieldName ) |
|
360 | + require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php'; |
|
361 | + foreach ($layoutAdditions as $deployedModuleName => $fieldName) |
|
362 | 362 | { |
363 | - foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view ) |
|
363 | + foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view) |
|
364 | 364 | { |
365 | - $parsedName = AbstractRelationships::parseDeployedModuleName ( $deployedModuleName ) ; |
|
366 | - if (isset ( $parsedName [ 'packageName' ] )) |
|
365 | + $parsedName = AbstractRelationships::parseDeployedModuleName($deployedModuleName); |
|
366 | + if (isset ($parsedName ['packageName'])) |
|
367 | 367 | { |
368 | - $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": " . (($actionAdd) ? "adding" : "removing") . " $fieldName on $view layout for undeployed module {$parsedName [ 'moduleName' ]} in package {$parsedName [ 'packageName' ]}" ) ; |
|
369 | - $parser = new GridLayoutMetaDataParser ( $view, $parsedName [ 'moduleName' ], $parsedName [ 'packageName' ] ) ; |
|
368 | + $GLOBALS ['log']->debug(get_class($this).": ".(($actionAdd) ? "adding" : "removing")." $fieldName on $view layout for undeployed module {$parsedName ['moduleName']} in package {$parsedName ['packageName']}"); |
|
369 | + $parser = new GridLayoutMetaDataParser($view, $parsedName ['moduleName'], $parsedName ['packageName']); |
|
370 | 370 | |
371 | - if (($actionAdd) ? $parser->addField ( array ( 'name' => $fieldName ) ) : $parser->removeField ( $fieldName )) |
|
371 | + if (($actionAdd) ? $parser->addField(array('name' => $fieldName)) : $parser->removeField($fieldName)) |
|
372 | 372 | { |
373 | - $parser->handleSave ( false ) ; |
|
373 | + $parser->handleSave(false); |
|
374 | 374 | } |
375 | 375 | else |
376 | 376 | { |
377 | - $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": couldn't " . (($actionAdd) ? "add" : "remove") . " $fieldName on $view layout for undeployed module $deployedModuleName" ) ; |
|
378 | - $successful = false ; |
|
377 | + $GLOBALS ['log']->debug(get_class($this).": couldn't ".(($actionAdd) ? "add" : "remove")." $fieldName on $view layout for undeployed module $deployedModuleName"); |
|
378 | + $successful = false; |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return $successful ; |
|
384 | + return $successful; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /* |
@@ -392,29 +392,29 @@ discard block |
||
392 | 392 | * @param array $layoutAdditions An array of module => fieldname |
393 | 393 | * return null |
394 | 394 | */ |
395 | - protected function saveFieldsToLayouts ($basepath , $dummy , $relationshipName , $layoutAdditions) |
|
395 | + protected function saveFieldsToLayouts($basepath, $dummy, $relationshipName, $layoutAdditions) |
|
396 | 396 | { |
397 | - require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ; |
|
397 | + require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php'; |
|
398 | 398 | |
399 | 399 | // these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. In either case, we don't want to attempt to add a relate field to them |
400 | 400 | // would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here |
401 | - $invalidModules = array ( 'emails' , 'kbdocuments' ) ; |
|
401 | + $invalidModules = array('emails', 'kbdocuments'); |
|
402 | 402 | |
403 | 403 | $fieldsToAdd = array(); |
404 | - foreach ( $layoutAdditions as $deployedModuleName => $fieldName ) |
|
404 | + foreach ($layoutAdditions as $deployedModuleName => $fieldName) |
|
405 | 405 | { |
406 | - if ( ! in_array( strtolower ( $deployedModuleName ) , $invalidModules ) ) { |
|
407 | - foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view ) |
|
406 | + if (!in_array(strtolower($deployedModuleName), $invalidModules)) { |
|
407 | + foreach (array(MB_EDITVIEW, MB_DETAILVIEW) as $view) |
|
408 | 408 | { |
409 | - $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ; |
|
410 | - $parsedName = self::parseDeployedModuleName ( $deployedModuleName ) ; |
|
411 | - if (! isset ( $parsedName [ 'packageName' ] )) |
|
409 | + $GLOBALS ['log']->debug(get_class($this).": adding $fieldName to $view layout for module $deployedModuleName"); |
|
410 | + $parsedName = self::parseDeployedModuleName($deployedModuleName); |
|
411 | + if (!isset ($parsedName ['packageName'])) |
|
412 | 412 | { |
413 | - $fieldsToAdd [$parsedName [ 'moduleName' ]] = $fieldName; |
|
413 | + $fieldsToAdd [$parsedName ['moduleName']] = $fieldName; |
|
414 | 414 | } |
415 | 415 | //Bug 22348: We should add in the field for custom modules not in this package, if they have been deployed. |
416 | - else if ($parsedName [ 'packageName' ] != $this->packageName |
|
417 | - && isset ( $GLOBALS [ 'beanList' ] [ $deployedModuleName ])){ |
|
416 | + else if ($parsedName ['packageName'] != $this->packageName |
|
417 | + && isset ($GLOBALS ['beanList'] [$deployedModuleName])) { |
|
418 | 418 | $fieldsToAdd [$deployedModuleName] = $fieldName; |
419 | 419 | } |
420 | 420 | } |