adamjakab /
SuiteCRM
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 | /********************************************************************************* |
||
| 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
| 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
| 6 | |||
| 7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
| 8 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
| 9 | * |
||
| 10 | * This program is free software; you can redistribute it and/or modify it under |
||
| 11 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
| 12 | * Free Software Foundation with the addition of the following permission added |
||
| 13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
| 14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
| 15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
| 16 | * |
||
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
| 20 | * details. |
||
| 21 | * |
||
| 22 | * You should have received a copy of the GNU Affero General Public License along with |
||
| 23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
| 24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
| 25 | * 02110-1301 USA. |
||
| 26 | * |
||
| 27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
| 28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
| 29 | * |
||
| 30 | * The interactive user interfaces in modified source and object code versions |
||
| 31 | * of this program must display Appropriate Legal Notices, as required under |
||
| 32 | * Section 5 of the GNU Affero General Public License version 3. |
||
| 33 | * |
||
| 34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
| 35 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
| 36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
| 37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
| 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
| 39 | ********************************************************************************/ |
||
| 40 | |||
| 41 | |||
| 42 | 1 | require_once('include/DetailView/DetailView2.php'); |
|
| 43 | |||
| 44 | class ViewMetadata extends SugarView{ |
||
| 45 | var $type ='detail'; |
||
| 46 | var $dv; |
||
| 47 | |||
| 48 | |||
| 49 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 50 | 2 | function displayCheckBoxes($name,$values, $selected =array(), $attr=''){ |
|
| 51 | 2 | echo "<div $attr style='overflow:auto;float:left;width:200px;height:200px' >"; |
|
| 52 | 2 | foreach($values as $value){ |
|
| 53 | 2 | $checked = in_array($value, $selected)? " checked=checked ": " "; |
|
| 54 | 2 | echo "<div style='padding:2px'><input type='checkbox' name='$name' value='$value' $checked> $value</div>"; |
|
| 55 | } |
||
| 56 | 2 | echo "</div>"; |
|
| 57 | 2 | } |
|
| 58 | |||
|
0 ignored issues
–
show
|
|||
| 59 | 2 | function displaySelect($name,$values, $selected ='', $attr=''){ |
|
| 60 | 2 | echo "<select name='$name' $attr>"; |
|
| 61 | 2 | foreach($values as $value){ |
|
| 62 | 2 | $checked = $value == $selected? " selected=selected ": " "; |
|
| 63 | 2 | echo "<option value='$value' $checked> $value</option>"; |
|
| 64 | } |
||
| 65 | 2 | echo "</select>"; |
|
| 66 | 2 | } |
|
| 67 | |||
|
0 ignored issues
–
show
|
|||
| 68 | |||
|
0 ignored issues
–
show
|
|||
| 69 | |||
|
0 ignored issues
–
show
|
|||
| 70 | 2 | function displayTextBoxes($values, $attr=''){ |
|
| 71 | 2 | echo "<div $attr style='overflow:auto;float:left;width:400px;height:200px' >"; |
|
| 72 | 2 | foreach($values as $value){ |
|
| 73 | 2 | $postvalue = !empty($_POST[$value])? $_POST[$value]: ''; |
|
| 74 | 2 | echo "<div style='padding:2px;width:150px;float:left'>$value</div> <input type='text' name='$value' value='$postvalue'> "; |
|
| 75 | } |
||
| 76 | 2 | echo "</div>"; |
|
| 77 | 2 | } |
|
| 78 | |||
|
0 ignored issues
–
show
|
|||
| 79 | |||
|
0 ignored issues
–
show
|
|||
| 80 | |||
|
0 ignored issues
–
show
|
|||
| 81 | 1 | function printValue($value, $depth=0){ |
|
| 82 | 1 | echo "<pre>"; |
|
| 83 | 1 | print_r($value); |
|
| 84 | 1 | echo "</pre>"; |
|
| 85 | |||
| 86 | 1 | } |
|
| 87 | |||
|
0 ignored issues
–
show
|
|||
| 88 | 1 | function display(){ |
|
| 89 | 1 | $do = !empty($_REQUEST['do'])?$_REQUEST['do']:''; |
|
| 90 | 1 | echo "<form method='post'>"; |
|
| 91 | 1 | echo "<div><h2>I want to learn about "; |
|
| 92 | |||
| 93 | 1 | $this->displaySelect('do', array('Nothing', 'Modules','Fields', 'Field Attributes', 'Relationships'), $do, 'onchange="toggleLearn(this.value)"'); |
|
| 94 | 1 | echo "<input type='submit' value='Learn' class='button'></h2></div>"; |
|
| 95 | 1 | $modules = !empty($_REQUEST['modules'])?$_REQUEST['modules']:array(); |
|
| 96 | 1 | if(empty($modules) && !empty($_REQUEST['module']) && $_REQUEST['module'] != 'Home'){ |
|
| 97 | $modules = array( $_REQUEST['module']); |
||
| 98 | } |
||
| 99 | 1 | $this->displayCheckBoxes('modules[]', VardefBrowser::getModules(), $modules, ' id="_modules" '); |
|
| 100 | 1 | $attributes = !empty($_REQUEST['attributes'])?$_REQUEST['attributes']:array(); |
|
| 101 | 1 | $allAttributes = array_keys(VardefBrowser::findFieldAttributes()); |
|
| 102 | 1 | sort($allAttributes); |
|
| 103 | 1 | $this->displayCheckBoxes('attributes[]', $allAttributes, $attributes, ' id="_attributes" '); |
|
| 104 | 1 | $this->displayTextBoxes($allAttributes, ' id="_fields" '); |
|
| 105 | 1 | echo "</form>"; |
|
| 106 | echo <<<EOQ |
||
| 107 | <script> |
||
| 108 | function toggleLearn(value){ |
||
| 109 | document.getElementById('_modules').style.display = 'None'; |
||
| 110 | document.getElementById('_attributes').style.display = 'None'; |
||
| 111 | document.getElementById('_fields').style.display = 'None'; |
||
| 112 | if(value == 'Modules' || value == 'Relationships'){ |
||
| 113 | document.getElementById('_modules').style.display = ''; |
||
| 114 | } |
||
| 115 | if(value == 'Fields'){ |
||
| 116 | document.getElementById('_modules').style.display = ''; |
||
| 117 | document.getElementById('_fields').style.display = ''; |
||
| 118 | } |
||
| 119 | if(value == 'Field Attributes'){ |
||
| 120 | document.getElementById('_modules').style.display = ''; |
||
| 121 | document.getElementById('_attributes').style.display = ''; |
||
| 122 | } |
||
| 123 | } |
||
| 124 | 1 | toggleLearn('$do'); |
|
| 125 | |||
| 126 | </script> |
||
| 127 | |||
| 128 | EOQ; |
||
| 129 | 1 | echo "<div width='100%'></div><div><div style='float:left'>"; |
|
| 130 | switch ($do){ |
||
| 131 | 1 | case 'Modules': |
|
| 132 | $this->printValue(VardefBrowser::findVardefs( $modules)); |
||
| 133 | break; |
||
| 134 | 1 | case 'Field Attributes': |
|
| 135 | $this->printValue(VardefBrowser::findFieldAttributes($attributes, $modules)); |
||
| 136 | break; |
||
| 137 | 1 | case 'Fields': |
|
| 138 | $searchFor = array(); |
||
| 139 | foreach($allAttributes as $at){ |
||
| 140 | if(!empty($_POST[$at])){ |
||
| 141 | $searchFor[$at] = $_POST[$at]; |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | $this->printValue(VardefBrowser::findFieldsWithAttributes($searchFor, $modules)); |
||
| 146 | break; |
||
| 147 | default: |
||
| 148 | echo <<<EOQ |
||
| 149 | <div style='border:1px solid;width:100%;text-align:center;-moz-border-radius: 5px;border-radius: 5px;'> |
||
| 150 | <h2 style='text-decoration: line-through'>All you ever wanted to know about Vardefs in 30 minutes</h2> |
||
| 151 | <h2 style='text-decoration: line-through'>All you ever wanted to know about Vardef Fields and Relationships in 30 minutes</h1> |
||
| 152 | <h2 style='text-decoration: line-through'>All you ever wanted to know about Vardef Fields in 30 minutes</h2> |
||
| 153 | <h2 >Something about Vardefs in 30 minutes</h2> |
||
| 154 | </div> |
||
| 155 | |||
| 156 | <div style='border:1px solid;width:100%;-moz-border-radius: 5px;border-radius: 5px;'> |
||
| 157 | <h4>What you need to know</h4> |
||
| 158 | <pre> |
||
| 159 | Vardefs are where we define information about the fields for a module. |
||
| 160 | |||
| 161 | It also specifies 75% of the information on relationships. |
||
| 162 | |||
| 163 | There are also special attributes that can enable additional functionality for a module. |
||
| 164 | |||
| 165 | It's broken down into: |
||
| 166 | <b>fields:</b> The fields of a module (most of these are stored in the database) |
||
| 167 | |||
| 168 | <b>indices:</b> The indicies on the database |
||
| 169 | |||
| 170 | <b>relationships:</b> The relationships for this module |
||
| 171 | |||
| 172 | <b>templates:</b> the functionality/fields this module inherits from SugarObjects(located in include/SugarObjects). |
||
| 173 | In a vardef these are specified by the third argument in VardefManager::createVardef |
||
| 174 | For Example - <b>VardefManager::createVardef('Contacts','Contact', array('default', 'assignable','team_security','person'));</b> |
||
| 175 | would add the fields for team security to contacts and make it an object that can be assigned to users. |
||
| 176 | The 'person' value would indicate that that Contacts subclasses Person and gains all the fields/attributes that 'Person' |
||
| 177 | would get. Since person extends basic it would also gain all the fields/attributes of basic as well. |
||
| 178 | |||
| 179 | |||
| 180 | The SugarObjects that a module can extend are <b>'basic', 'company', 'file', 'issue', 'person'</b>. |
||
| 181 | These are the same objects you can build off of in ModuleBuilder. |
||
| 182 | Adding a new SugarObject to include/SugarObjects/templates is the way |
||
| 183 | to add modules to ModuleBuilder |
||
| 184 | |||
| 185 | Besides extending base objects, a module can also implement functionality defined in SugarObjects. |
||
| 186 | You can currenty implement <b>'assignable' and 'team_security'</b>. |
||
| 187 | |||
| 188 | |||
| 189 | <b>attributes:</b> |
||
| 190 | <b>[table] (string) (required)</b> The database table where this module stores it's data - any custom fields will be stored in a new table |
||
| 191 | with '_cstm' appended to the table name. The field id_c in the custom table will be the same value as id in the primary table |
||
| 192 | allowing us to join the two tables together. |
||
| 193 | |||
| 194 | <b>[comment] (string) (optional)</b> is a description of the module |
||
| 195 | |||
| 196 | <b>[unified_search] (bool)(optional)</b> is global search (the search in the upper right corner on the screen) available for this module |
||
| 197 | |||
| 198 | <b>[unified_search_default_enabled] (bool)(optional)</b> is this module available by default in global search |
||
| 199 | |||
| 200 | <b>[optimistic_locking] (bool) (optional)</b> optimistic locking is the concept that on save if the record modifiy time (date_modified) |
||
| 201 | is newer than the the modify time of the record when it was loaded to edit (this time is stored in the session). |
||
| 202 | |||
| 203 | <b>[favorites] (bool) (optional)</b> should favorites be enabled for this module. Favorites are indicated by the stars next to a record |
||
| 204 | on lists and deail views. It makes it easier for users to indicate what is important to them right now. It also allows them to filter |
||
| 205 | by favorites. |
||
| 206 | |||
| 207 | <b>[duplicate_merge] (bool) (optional)</b> is systematic merging allowed between records of this module or not. This option is available from |
||
| 208 | the menu on list views. A user needs to select 2 records on the list view using the checkboxes, and then they can select merge from the actions |
||
| 209 | menu. |
||
| 210 | |||
| 211 | <b>[audited] (bool) (optional)</b> auditing allows for the tracking of any changes to specified fields. In order to enable auditing you need to enable |
||
| 212 | it at both the module level and the field level. It will create an audit table for the module with the '_audit' appended to the table name. |
||
| 213 | |||
| 214 | <b>[custom_fields] (bool) (automatic) </b> if the module has custom fields this will be set to true |
||
| 215 | |||
| 216 | |||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | |||
| 221 | |||
| 222 | |||
| 223 | |||
| 224 | |||
| 225 | |||
| 226 | </pre> |
||
| 227 | </div> |
||
| 228 | |||
| 229 | <div> |
||
| 230 | |||
| 231 | </div> |
||
| 232 | |||
| 233 | EOQ; |
||
| 234 | |||
| 235 | |||
| 236 | } |
||
| 237 | 1 | echo "</div><div style='float:right'>Help Text</div></div>"; |
|
| 238 | |||
| 239 | |||
| 240 | //$this->printValue(VardefBrowser::findFieldsWithAttributes(array('type'=>'id'), $modules)); |
||
| 241 | |||
| 242 | |||
|
0 ignored issues
–
show
|
|||
| 243 | |||
| 244 | |||
| 245 | |||
| 246 | 1 | } |
|
| 247 | |||
| 248 | } |
||
| 249 | |||
| 250 | class VardefBrowser{ |
||
|
0 ignored issues
–
show
|
|||
| 251 | |||
| 252 | function __construct(){ |
||
| 253 | |||
| 254 | } |
||
| 255 | |||
| 256 | 5 | static function getModules(){ |
|
| 257 | 5 | $modules = array(); |
|
| 258 | 5 | foreach($GLOBALS['beanList'] as $module=>$object){ |
|
| 259 | 5 | $object = BeanFactory::getObjectName($module); |
|
| 260 | 5 | VardefManager::loadVardef($module, $object); |
|
| 261 | 5 | if(empty($GLOBALS['dictionary'][$object]['fields'] ))continue; |
|
| 262 | 5 | $modules[] = $module; |
|
| 263 | } |
||
| 264 | 5 | sort($modules); |
|
| 265 | 5 | return $modules; |
|
| 266 | |||
| 267 | |||
| 268 | } |
||
| 269 | |||
| 270 | 1 | static function findFieldsWithAttributes($attributes, $modules=null){ |
|
| 271 | 1 | $fields = array(); |
|
| 272 | 1 | if(empty($modules))$modules = VardefBrowser::getModules(); |
|
| 273 | 1 | foreach($modules as $module){ |
|
| 274 | 1 | if(!empty($GLOBALS['beanList'][$module])){ |
|
| 275 | 1 | $object = $GLOBALS['beanList'][$module]; |
|
| 276 | 1 | if($object == 'aCase')$object = 'Case'; |
|
| 277 | 1 | VardefManager::loadVardef($module, $object); |
|
| 278 | 1 | if(empty($GLOBALS['dictionary'][$object]['fields'] ))continue; |
|
| 279 | 1 | foreach($GLOBALS['dictionary'][$object]['fields'] as $name=>$def){ |
|
| 280 | 1 | $match = true; |
|
| 281 | 1 | foreach($attributes as $k=>$v){ |
|
| 282 | 1 | $alt = false; |
|
| 283 | 1 | if($k == 'type'){ |
|
| 284 | 1 | $alt = 'dbType'; |
|
| 285 | } |
||
| 286 | 1 | if($v == 'true' && !empty($def[$k])){ |
|
| 287 | continue; |
||
| 288 | } |
||
| 289 | 1 | if((empty($def[$k]) || $def[$k] != $v) && (empty($alt) || empty($def[$alt]) || $def[$alt] != $v )){ |
|
| 290 | 1 | $match = false; |
|
| 291 | } |
||
| 292 | } |
||
| 293 | 1 | if($match){ |
|
| 294 | 1 | $fields[$module][$object][$name] = $def; |
|
| 295 | } |
||
| 296 | |||
| 297 | } |
||
| 298 | |||
| 299 | } |
||
| 300 | } |
||
| 301 | 1 | return $fields; |
|
| 302 | } |
||
| 303 | |||
| 304 | 1 | static function findVardefs($modules=null){ |
|
| 305 | 1 | $defs = array(); |
|
| 306 | 1 | if(empty($modules))$modules = VardefBrowser::getModules(); |
|
| 307 | 1 | foreach($modules as $module){ |
|
| 308 | 1 | if(!empty($GLOBALS['beanList'][$module])){ |
|
| 309 | 1 | $object = $GLOBALS['beanList'][$module]; |
|
| 310 | 1 | if($object == 'aCase')$object = 'Case'; |
|
| 311 | 1 | VardefManager::loadVardef($module, $object); |
|
| 312 | 1 | if(empty($GLOBALS['dictionary'][$object]['fields'] ))continue; |
|
| 313 | 1 | $defs[$module][$object] = $GLOBALS['dictionary'][$object]; |
|
| 314 | } |
||
| 315 | } |
||
| 316 | 1 | return $defs; |
|
| 317 | } |
||
| 318 | |||
| 319 | |||
| 320 | 2 | static function findFieldAttributes($attributes=array(), $modules=null, $byModule=false, $byType=false){ |
|
| 321 | 2 | $fields = array(); |
|
| 322 | 2 | if(empty($modules))$modules = VardefBrowser::getModules(); |
|
| 323 | 2 | foreach($modules as $module){ |
|
| 324 | 2 | if(!empty($GLOBALS['beanList'][$module])){ |
|
| 325 | 2 | $object = $GLOBALS['beanList'][$module]; |
|
| 326 | 2 | if($object == 'aCase')$object = 'Case'; |
|
| 327 | 2 | VardefManager::loadVardef($module, $object); |
|
| 328 | 2 | if(empty($GLOBALS['dictionary'][$object]['fields'] ))continue; |
|
| 329 | 2 | foreach($GLOBALS['dictionary'][$object]['fields'] as $name=>$def){ |
|
| 330 | 2 | $fieldAttributes = (!empty($attributes))? $attributes:array_keys($def); |
|
| 331 | 2 | foreach($fieldAttributes as $k){ |
|
| 332 | 2 | if(isset($def[$k])){ |
|
| 333 | 2 | $v = var_export($def[$k], true); |
|
| 334 | 2 | $key = is_array($def[$k])?null:$def[$k]; |
|
| 335 | 2 | if($k == 'type'){ |
|
| 336 | 2 | if(isset($def['dbType'])){ |
|
| 337 | 2 | $v = var_export($def['dbType'], true); |
|
| 338 | } |
||
| 339 | } |
||
| 340 | 2 | if($byModule){ |
|
| 341 | 1 | $fields[$module][$object][$def['type']][$k][$key] = $v; |
|
| 342 | }else{ |
||
| 343 | 2 | if($byType){ |
|
| 344 | $fields[$def['type']][$k][$key] = $v; |
||
| 345 | }else{ |
||
| 346 | 2 | if(!is_array($def[$k])){ |
|
| 347 | 2 | if(isset($fields[$k][$key])){ |
|
| 348 | 2 | $fields[$k][$key]['refs']++; |
|
| 349 | }else{ |
||
| 350 | 2 | $fields[$k][$key] = array('attribute'=>$v, 'refs'=>1); |
|
| 351 | } |
||
| 352 | }else{ |
||
| 353 | 2 | $fields[$k]['_array'][] = $def[$k]; |
|
| 354 | |||
| 355 | } |
||
| 356 | } |
||
| 357 | } |
||
| 358 | |||
| 359 | |||
| 360 | } |
||
| 361 | |||
| 362 | } |
||
| 363 | |||
| 364 | |||
| 365 | |||
| 366 | } |
||
| 367 | |||
| 368 | } |
||
| 369 | } |
||
| 370 | 2 | return $fields; |
|
| 371 | } |
||
| 372 | |||
| 373 | |||
| 374 | |||
| 375 | } |
||
| 376 |