This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /********************************************************************************* |
||
3 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
4 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
5 | |||
6 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
7 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
8 | * |
||
9 | * This program is free software; you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
11 | * Free Software Foundation with the addition of the following permission added |
||
12 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
13 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
14 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
15 | * |
||
16 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
18 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
19 | * details. |
||
20 | * |
||
21 | * You should have received a copy of the GNU Affero General Public License along with |
||
22 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
23 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
24 | * 02110-1301 USA. |
||
25 | * |
||
26 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
27 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
28 | * |
||
29 | * The interactive user interfaces in modified source and object code versions |
||
30 | * of this program must display Appropriate Legal Notices, as required under |
||
31 | * Section 5 of the GNU Affero General Public License version 3. |
||
32 | * |
||
33 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
34 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
35 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
36 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
37 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
38 | ********************************************************************************/ |
||
39 | |||
40 | require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ; |
||
41 | require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ; |
||
42 | require_once ('modules/ModuleBuilder/Module/StudioModuleFactory.php') ; |
||
43 | require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ; |
||
44 | require_once ('modules/ModuleBuilder/parsers/constants.php') ; |
||
45 | require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ; |
||
46 | |||
47 | class ViewRelationship extends SugarView |
||
48 | { |
||
49 | /** |
||
50 | * @see SugarView::_getModuleTitleParams() |
||
51 | */ |
||
52 | protected function _getModuleTitleParams($browserTitle = false) |
||
53 | { |
||
54 | global $mod_strings; |
||
55 | |||
56 | return array( |
||
57 | translate('LBL_MODULE_NAME','Administration'), |
||
58 | ModuleBuilderController::getModuleTitle(), |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | function overrideDefinitionFromPOST( |
||
63 | $definition |
||
64 | ) |
||
65 | { |
||
66 | require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ; |
||
67 | foreach ( AbstractRelationship::$definitionKeys as $key ) |
||
68 | { |
||
69 | if(!empty($_REQUEST ['ajaxLoad']) && in_array($key, array('label', 'rhs_label', 'lhs_label')) ){ |
||
70 | continue; |
||
71 | } |
||
72 | if (! empty ( $_REQUEST [ $key ] )) |
||
73 | { |
||
74 | $definition [ $key ] = $_REQUEST [ $key ] ; |
||
75 | } |
||
76 | } |
||
77 | return $definition ; |
||
78 | } |
||
79 | |||
80 | function display() |
||
81 | { |
||
82 | $selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']); |
||
83 | $this->smarty = new Sugar_Smarty ( ) ; |
||
84 | $ac = new AjaxCompose ( ) ; |
||
85 | $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (!empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio') ; |
||
86 | $this->smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ; |
||
87 | |||
88 | if (!$this->fromModuleBuilder) |
||
89 | { |
||
90 | $module = StudioModuleFactory::getStudioModule( $_REQUEST [ 'view_module' ] ) ; |
||
91 | $moduleName = $_REQUEST [ 'view_module' ] ; |
||
92 | $fields = $module->fields ; |
||
93 | require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ; |
||
94 | $relatableModules = DeployedRelationships::findRelatableModules () ; |
||
95 | $appStrings = return_app_list_strings_language( $selected_lang ) ; |
||
96 | $modStrings = return_module_language( $selected_lang, $_REQUEST [ 'view_module' ], true ) ; |
||
97 | $appStrings = $appStrings['moduleList']; |
||
98 | } else |
||
99 | { |
||
100 | $mb = new ModuleBuilder ( ) ; |
||
101 | $mb->getPackages(); |
||
102 | //display the latest module name rather than what is in or not in the loaded app_list_strings. |
||
103 | $mb->getPackage($_REQUEST ['view_package'])->loadModuleTitles(); |
||
104 | $module = $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ; |
||
105 | $moduleName = empty($module->key_name) ? $module->getModuleName() : $module->key_name; |
||
106 | $this->smarty->assign ( 'view_package', $_REQUEST [ 'view_package' ] ) ; |
||
107 | $mbvardefs = $module->getVardefs () ; |
||
108 | $fields = $mbvardefs [ 'fields' ] ; |
||
109 | require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ; |
||
110 | $relatableModules = UndeployedRelationships::findRelatableModules () ; |
||
111 | $appStrings = $module->getModStrings( $selected_lang ) ; |
||
112 | } |
||
113 | |||
114 | ksort( $relatableModules ) ; |
||
115 | $lhs_subpanels = $module->getProvidedSubpanels () ; |
||
116 | // Fix to re-add sorting of the subpanel names so that the 'default' subpanel always appears first in the list. |
||
117 | // This assumes that subpanels are usually named ForXYZ which is the case currently, and hence 'default' will be sorted first. |
||
118 | //I f this assumption is incorrect, then a better solution would be to remove 'default' from the subpanel list, then sort, and finally array_unshift it back on. |
||
119 | natcasesort($lhs_subpanels); |
||
120 | |||
121 | $cardinality = array ( MB_ONETOONE => translate ( 'LBL_ONETOONE' ) , MB_ONETOMANY => translate ( 'LBL_ONETOMANY' ) , MB_MANYTOONE=> translate ( 'LBL_MANYTOONE' ), MB_MANYTOMANY => translate ( 'LBL_MANYTOMANY' ), ) ; |
||
122 | |||
123 | if (!$this->fromModuleBuilder) |
||
124 | unset($cardinality[MB_MANYTOONE]); |
||
125 | |||
126 | $relationships = $module->getRelationships () ; |
||
127 | |||
128 | // if a description for this relationship already exists, then load it so it can be modified |
||
129 | if (! empty ( $_REQUEST [ 'relationship_name' ] )) |
||
130 | { |
||
131 | $relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] ) ; |
||
132 | $relationship->setName($_REQUEST [ 'relationship_name' ] ); |
||
133 | $definition = $relationship->getDefinition(); |
||
134 | if (!$this->fromModuleBuilder){ |
||
135 | $modStrings = return_module_language( $selected_lang, $relationship->rhs_module, true ) ; |
||
136 | $definition['lhs_label'] = isset($modStrings[$relationship->getTitleKey()])?$modStrings[$relationship->getTitleKey()] : $relationship->lhs_module; |
||
137 | $modStrings = return_module_language( $selected_lang, $relationship->lhs_module, true ) ; |
||
138 | $definition['rhs_label'] = isset($modStrings[$relationship->getTitleKey(true)])?$modStrings[$relationship->getTitleKey(true)] : $relationship->rhs_module ; |
||
139 | }else{ |
||
140 | #30624 |
||
141 | if(!empty($_REQUEST['rhs_module'])){ |
||
142 | $definition['rhs_label'] = $_REQUEST['rhs_module']; |
||
143 | } |
||
144 | } |
||
145 | } else |
||
146 | { |
||
147 | $definition = array ( ) ; |
||
148 | $firstModuleDefinition = each ( $relatableModules ) ; |
||
149 | $definition [ 'rhs_module' ] = $firstModuleDefinition [ 'key' ] ; |
||
150 | $definition [ 'lhs_module' ] = $moduleName ; |
||
151 | $definition [ 'lhs_label' ] = translate($moduleName); |
||
152 | $definition [ 'relationship_type' ] = MB_MANYTOMANY ; |
||
153 | } |
||
154 | // load the relationship from post - required as we can call view.relationship.php from Ajax when changing the rhs_module for example |
||
155 | $definition = $this->overrideDefinitionFromPOST ( $definition ) ; |
||
156 | |||
157 | if (empty($definition ['rhs_label'])) |
||
158 | { |
||
159 | $definition ['rhs_label'] = translate($definition [ 'rhs_module' ]); |
||
160 | } |
||
161 | if (empty($definition ['lhs_label'])) |
||
162 | { |
||
163 | $definition ['lhs_label'] = translate($definition [ 'lhs_module' ]); |
||
164 | } |
||
165 | $relationship = RelationshipFactory::newRelationship ( $definition ) ; |
||
166 | |||
167 | $rhs_subpanels = $relatableModules [ $relationship->rhs_module ] ; |
||
168 | // Fix to re-add sorting of the subpanel names so that the 'default' subpanel always appears first in the list. This assumes that subpanels are usually named ForXYZ which is the case currently, and hence 'default' will be sorted first. If this assumption is incorrect, then a better solution would be to remove 'default' from the subpanel list, then sort, and finally array_unshift it back on. |
||
169 | natcasesort($rhs_subpanels); |
||
170 | |||
171 | if (empty ( $_REQUEST [ 'relationship_name' ] )) |
||
172 | { |
||
173 | // tidy up the options for the view based on the modules participating in the relationship and the cardinality |
||
174 | // some modules (e.g., Knowledge Base/KBDocuments) lack subpanels. That means they can't be the lhs of a 1-many or many-many, or the rhs of a many-many for example |
||
175 | |||
176 | // fix up the available cardinality options |
||
177 | $relationship_type = $relationship->getType () ; |
||
178 | if (count ( $lhs_subpanels ) == 0 || count ( $rhs_subpanels ) == 0) |
||
179 | { |
||
180 | unset ( $cardinality [ MB_MANYTOMANY ] ) ; |
||
181 | } |
||
182 | if (count ( $rhs_subpanels ) == 0) |
||
183 | { |
||
184 | unset ( $cardinality [ MB_ONETOMANY ] ) ; |
||
185 | } |
||
186 | |||
187 | if (isset ($definition['rhs_module']) && $definition['rhs_module'] == 'Activities') { |
||
188 | $cardinality = array( MB_ONETOMANY => translate ( 'LBL_ONETOMANY' )); |
||
189 | } |
||
190 | //Bug 23139, Campaigns module current cannot display custom subpanels, so we need to ban it from any |
||
191 | //relationships that would require a new subpanel to be shown in Campaigns. |
||
192 | if (isset ($definition['lhs_module']) && $definition['lhs_module'] == 'Campaigns') { |
||
193 | unset ( $cardinality [ MB_MANYTOMANY ] ) ; |
||
194 | unset ( $cardinality [ MB_ONETOMANY ] ) ; |
||
195 | } |
||
196 | if (isset ($definition['rhs_module']) && $definition['rhs_module'] == 'Campaigns' && isset($cardinality [ MB_MANYTOMANY ])) { |
||
197 | unset ( $cardinality [ MB_MANYTOMANY ] ) ; |
||
198 | unset ( $cardinality [ MB_MANYTOONE ] ); |
||
199 | } |
||
200 | if (! isset($cardinality[$relationship->getType()])) |
||
201 | { |
||
202 | end ($cardinality) ; |
||
203 | $definition [ 'relationship_type' ] = key ( $cardinality ) ; |
||
204 | $relationship = RelationshipFactory::newRelationship ( $definition ) ; |
||
205 | } |
||
206 | |||
207 | $this->smarty->assign ( 'is_new', true ) ; |
||
208 | } else { |
||
209 | $this->smarty->assign ( 'is_new', false ) ; |
||
210 | } |
||
211 | |||
212 | //Remove Activities if one-to-many is not availible |
||
213 | if (!isset($cardinality [ MB_ONETOMANY ]) && isset ($relatableModules['Activities'])) { |
||
214 | unset ($relatableModules['Activities']); |
||
215 | } |
||
216 | |||
217 | |||
218 | // now enforce the relationship_only requirement - that is, only construct the underlying relationship and link fields, and not the UI, if the subpanel code will have troubles displaying the UI |
||
219 | $relationships->enforceRelationshipOnly ( $relationship ) ; |
||
220 | $this->smarty->assign ( 'view_module', $_REQUEST['view_module'] ) ; |
||
221 | $this->smarty->assign ( 'rel', $relationship->getDefinition () ) ; |
||
222 | $this->smarty->assign ( 'mod_strings', $GLOBALS [ 'mod_strings' ] ) ; |
||
223 | $this->smarty->assign ( 'module_key', $relationship->lhs_module ) ; |
||
224 | $this->smarty->assign ( 'cardinality', array_keys ( $cardinality ) ) ; |
||
225 | $this->smarty->assign ( 'translated_cardinality', $cardinality ) ; |
||
226 | $this->smarty->assign ( 'selected_cardinality', translate ( $relationship->getType () ) ) ; |
||
227 | |||
228 | $relatable = array ( ) ; |
||
229 | foreach ( $relatableModules as $name => $dummy ) |
||
230 | { |
||
231 | $relatable [ $name ] = translate ( $name ) ; |
||
232 | } |
||
233 | unset($relatable [ 'KBDocuments' ] ) ; |
||
234 | natcasesort ( $relatable ) ; |
||
235 | $this->smarty->assign ( 'relatable', array_keys ( $relatable ) ) ; |
||
236 | $this->smarty->assign ( 'translated_relatable', $relatable ) ; |
||
237 | $this->smarty->assign ( 'rhspanels', $rhs_subpanels ) ; |
||
238 | $this->smarty->assign ( 'lhspanels', $lhs_subpanels ) ; |
||
239 | $this->smarty->assign('selected_lang', $selected_lang); |
||
240 | $this->smarty->assign('available_languages',get_languages()); |
||
241 | |||
242 | switch ( $relationship->relationship_type) |
||
243 | { |
||
244 | case MB_ONETOONE : |
||
0 ignored issues
–
show
|
|||
245 | break ; |
||
246 | |||
247 | case MB_ONETOMANY : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
248 | if (empty ( $relationship->relationship_column_name )) |
||
249 | { |
||
250 | $validRoleColumnFields = array ( ) ; |
||
251 | foreach ( $fields as $field ) |
||
252 | { |
||
253 | $validRoleColumnFields [] = $field ; |
||
254 | } |
||
255 | $this->smarty->assign ( 'relationship_role_column_enum', $validRoleColumnFields ) ; |
||
256 | } |
||
257 | if (! empty ( $relationship->relationship_role_column_value )) |
||
258 | $this->smarty->assign ( 'relationship_role_column_value', $relationship->relationship_role_column_value ) ; |
||
259 | break ; |
||
260 | case MB_MANYTOMANY : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
261 | if (! empty ( $relationship->relationship_role_column_value )) |
||
262 | $this->smarty->assign ( 'relationship_role_column_value', $relationship->relationship_role_column_value ) ; |
||
263 | break ; |
||
264 | } |
||
265 | |||
266 | //see if we use the new system |
||
267 | if (isset ( $_REQUEST [ 'json' ] ) && $_REQUEST [ 'json' ] == 'false') |
||
268 | { |
||
269 | echo $this->smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationship.tpl' ) ; |
||
270 | } else |
||
271 | { |
||
272 | $ac->addSection ( 'east', $module->name . ' ' . $GLOBALS [ 'mod_strings' ] [ 'LBL_RELATIONSHIPS' ], $this->smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationship.tpl' ) ) ; |
||
273 | echo $ac->getJavascript () ; |
||
274 | } |
||
275 | } |
||
276 | } |
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.