@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | global $current_language, $app_strings, $app_list_strings, $current_user, $beanFiles, $beanList; |
| 44 | 44 | |
| 45 | - $bean = BeanFactory::getBean($module,$id); |
|
| 45 | + $bean = BeanFactory::getBean($module, $id); |
|
| 46 | 46 | |
| 47 | - if(!checkAccess($bean)){ |
|
| 47 | + if (!checkAccess($bean)) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $mod_strings = return_module_language($current_language, $module); |
| 55 | 55 | |
| 56 | 56 | // set the filename for this control |
| 57 | - $file = create_cache_directory('include/InlineEditing/') . $module . $view . $alt_type . $fieldname . '.tpl'; |
|
| 57 | + $file = create_cache_directory('include/InlineEditing/').$module.$view.$alt_type.$fieldname.'.tpl'; |
|
| 58 | 58 | |
| 59 | 59 | if (!is_file($file) |
| 60 | 60 | || inDeveloperMode() |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | if ($vardef['type'] == 'link') { |
| 100 | 100 | $vardef['type'] = 'relate'; |
| 101 | 101 | $vardef['rname'] = 'name'; |
| 102 | - $vardef['id_name'] = $vardef['name'] . '_id'; |
|
| 102 | + $vardef['id_name'] = $vardef['name'].'_id'; |
|
| 103 | 103 | if ((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) { |
| 104 | 104 | $vardef['module'] = $focus->$vardef['name']->getRelatedModuleName(); |
| 105 | 105 | } |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | // Remove all the copyright comments |
| 136 | 136 | $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents); |
| 137 | 137 | // remove extra wrong javascript which breaks auto complete on flexi relationship parent fields |
| 138 | - $contents = preg_replace("/<script language=\"javascript\">if\(typeof sqs_objects == \'undefined\'\){var sqs_objects = new Array;}sqs_objects\[\'EditView_parent_name\'\].*?<\/script>/","",$contents); |
|
| 138 | + $contents = preg_replace("/<script language=\"javascript\">if\(typeof sqs_objects == \'undefined\'\){var sqs_objects = new Array;}sqs_objects\[\'EditView_parent_name\'\].*?<\/script>/", "", $contents); |
|
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | if ($view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')) { |
| 142 | 142 | |
| 143 | - $contents = str_replace('"' . $vardef['id_name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.id_name}"{literal}', $contents); |
|
| 144 | - $contents = str_replace('"' . $vardef['name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.name}"{literal}', $contents); |
|
| 143 | + $contents = str_replace('"'.$vardef['id_name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents); |
|
| 144 | + $contents = str_replace('"'.$vardef['name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents); |
|
| 145 | 145 | // regex below fixes button javascript for flexi relationship |
| 146 | - if($vardef['type'] == 'parent') { |
|
| 146 | + if ($vardef['type'] == 'parent') { |
|
| 147 | 147 | $contents = str_replace("onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"{\$fields.parent_name.id_name}", "onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"parent_id", $contents); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; |
| 179 | 179 | if (!isset($match[2]) || $match[2] == '') { |
| 180 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M"); |
|
| 180 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M"); |
|
| 181 | 181 | } else { |
| 182 | 182 | $pm = $match[2] == "pm" ? "%P" : "%p"; |
| 183 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm); |
|
| 183 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M".$pm); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
@@ -219,14 +219,14 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if ($fieldlist[$fieldname]['type'] == 'link') { |
| 222 | - $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id'; |
|
| 222 | + $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'].'_id'; |
|
| 223 | 223 | |
| 224 | 224 | if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) { |
| 225 | 225 | $fieldlist[$fieldname]['module'] = $focus->$fieldlist[$fieldname]['name']->getRelatedModuleName(); |
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if($fieldlist[$fieldname]['type'] == 'parent'){ |
|
| 229 | + if ($fieldlist[$fieldname]['type'] == 'parent') { |
|
| 230 | 230 | $fieldlist['parent_id']['name'] = 'parent_id'; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) { |
| 240 | - if($value){ |
|
| 241 | - $rel_value = $bean->$fieldlist[$fieldname]['id_name']; |
|
| 240 | + if ($value) { |
|
| 241 | + $rel_value = $bean->$fieldlist[$fieldname]['id_name']; |
|
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | $fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $rel_value; |
| 245 | 245 | $fieldlist[$fieldname]['value'] = $value; |
| 246 | 246 | $fieldlist[$fieldname]['id_name'] = $aow_field; |
| 247 | - $fieldlist[$fieldname]['name'] = $aow_field . '_display'; |
|
| 247 | + $fieldlist[$fieldname]['name'] = $aow_field.'_display'; |
|
| 248 | 248 | } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime')) { |
| 249 | 249 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
| 250 | 250 | if (!$value) { |
@@ -308,14 +308,14 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | if ($bean->field_defs[$field]['type'] == "multienum") { |
| 310 | 310 | $bean->$field = encodeMultienumValue($value); |
| 311 | - }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
| 311 | + } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent') { |
|
| 312 | 312 | $save_field = $bean->field_defs[$field]['id_name']; |
| 313 | 313 | $bean->$save_field = $value; |
| 314 | 314 | if ($bean->field_defs[$field]['type'] == 'parent') { |
| 315 | 315 | $bean->parent_type = $_REQUEST['parent_type']; |
| 316 | 316 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
| 317 | 317 | } |
| 318 | - }else{ |
|
| 318 | + } else { |
|
| 319 | 319 | $bean->$field = $value; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $fieldlist[$field] = $bean->getFieldDefinition($field); |
| 342 | 342 | |
| 343 | - if(is_array($listViewDefs)){ |
|
| 343 | + if (is_array($listViewDefs)) { |
|
| 344 | 344 | $fieldlist[$field] = array_merge($fieldlist[$field], $listViewDefs); |
| 345 | 345 | } |
| 346 | 346 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $vardef['module'] = $bean->module_dir; |
| 379 | 379 | |
| 380 | 380 | $SugarWidgetSubPanelDetailViewLink = new SugarWidgetSubPanelDetailViewLink($vardef); |
| 381 | - $value = "<b>" . $SugarWidgetSubPanelDetailViewLink->displayList($vardef) . "</b>"; |
|
| 381 | + $value = "<b>".$SugarWidgetSubPanelDetailViewLink->displayList($vardef)."</b>"; |
|
| 382 | 382 | |
| 383 | 383 | } |
| 384 | 384 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | $datetime_format = $timedate->get_date_time_format(); |
| 393 | 393 | // create utc date (as it's utc in db) |
| 394 | - $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value,new DateTimeZone('UTC')); |
|
| 394 | + $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value, new DateTimeZone('UTC')); |
|
| 395 | 395 | // convert it to timezone the user uses |
| 396 | 396 | $datetime = $timedate->tzUser($datetime); |
| 397 | 397 | |
@@ -430,17 +430,17 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | //if field is of type relate. |
| 433 | - if ($vardef['type'] == "relate" || $vardef['type'] == "parent") { |
|
| 433 | + if ($vardef['type'] == "relate" || $vardef['type'] == "parent") { |
|
| 434 | 434 | |
| 435 | - if($vardef['source'] == "non-db"){ |
|
| 435 | + if ($vardef['source'] == "non-db") { |
|
| 436 | 436 | |
| 437 | - if($vardef['module'] == "Employees"){ |
|
| 437 | + if ($vardef['module'] == "Employees") { |
|
| 438 | 438 | $vardef['ext2'] = "Users"; |
| 439 | 439 | $vardef['rname'] = "full_name"; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | } |
| 443 | - if($vardef['type'] == "parent") { |
|
| 443 | + if ($vardef['type'] == "parent") { |
|
| 444 | 444 | $vardef['module'] = $bean->parent_type; |
| 445 | 445 | $name = $bean->parent_name; |
| 446 | 446 | } |
@@ -449,19 +449,19 @@ discard block |
||
| 449 | 449 | $value = "<a class=\"listViewTdLinkS1\" href=\"index.php?action=DetailView&module=".$vardef['module']."&record=$record\">"; |
| 450 | 450 | |
| 451 | 451 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
| 452 | - $fieldName = 'name';//$vardef['name']; |
|
| 453 | - if(!is_null($vardef['rname'])) |
|
| 452 | + $fieldName = 'name'; //$vardef['name']; |
|
| 453 | + if (!is_null($vardef['rname'])) |
|
| 454 | 454 | $fieldName = $vardef['rname']; |
| 455 | 455 | |
| 456 | - if($vardef['ext2']){ |
|
| 456 | + if ($vardef['ext2']) { |
|
| 457 | 457 | |
| 458 | - $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record) . "</a>"; |
|
| 458 | + $value .= getFieldValueFromModule($fieldName, $vardef['ext2'], $record)."</a>"; |
|
| 459 | 459 | |
| 460 | - }else if(!empty($vardef['rname'])){ |
|
| 461 | - $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record) . "</a>"; |
|
| 460 | + } else if (!empty($vardef['rname'])) { |
|
| 461 | + $value .= getFieldValueFromModule($fieldName, $vardef['module'], $record)."</a>"; |
|
| 462 | 462 | |
| 463 | 463 | } else { |
| 464 | - $value .= $name . "</a>"; |
|
| 464 | + $value .= $name."</a>"; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | function getFieldValueFromModule($fieldname, $module, $id) |
| 473 | 473 | { |
| 474 | 474 | //Github bug 880, if the fieldname is null, do no call from bean |
| 475 | - if(is_null($fieldname)) |
|
| 475 | + if (is_null($fieldname)) |
|
| 476 | 476 | return ''; |
| 477 | 477 | |
| 478 | 478 | $bean = BeanFactory::getBean($module, $id); |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | return $value; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | -function checkAccess($bean){ |
|
| 496 | +function checkAccess($bean) { |
|
| 497 | 497 | |
| 498 | - if($bean->ACLAccess('EditView')) { |
|
| 498 | + if ($bean->ACLAccess('EditView')) { |
|
| 499 | 499 | return true; |
| 500 | - }else { |
|
| 500 | + } else { |
|
| 501 | 501 | return false; |
| 502 | 502 | } |
| 503 | 503 | } |
@@ -75,7 +75,9 @@ discard block |
||
| 75 | 75 | $vardef['type'] = 'varchar'; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (isset($vardef['precision'])) unset($vardef['precision']); |
|
| 78 | + if (isset($vardef['precision'])) { |
|
| 79 | + unset($vardef['precision']); |
|
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); |
| 81 | 83 | |
@@ -115,8 +117,9 @@ discard block |
||
| 115 | 117 | if (isset($vardef['function']) |
| 116 | 118 | && ($vardef['function'] == 'getEmailAddressWidget' |
| 117 | 119 | || $vardef['function']['name'] == 'getEmailAddressWidget') |
| 118 | - ) |
|
| 119 | - unset($vardef['function']); |
|
| 120 | + ) { |
|
| 121 | + unset($vardef['function']); |
|
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | if (isset($vardef['name']) && ($vardef['name'] == 'date_modified')) { |
| 122 | 125 | $vardef['name'] = 'aow_temp_date'; |
@@ -149,8 +152,9 @@ discard block |
||
| 149 | 152 | } |
| 150 | 153 | |
| 151 | 154 | // hack to disable one of the js calls in this control |
| 152 | - if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) |
|
| 153 | - $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
| 155 | + if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) { |
|
| 156 | + $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
| 157 | + } |
|
| 154 | 158 | |
| 155 | 159 | |
| 156 | 160 | |
@@ -186,8 +190,9 @@ discard block |
||
| 186 | 190 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
| 187 | 191 | |
| 188 | 192 | $fieldlist = array(); |
| 189 | - if (!isset($focus) || !($focus instanceof SugarBean)) |
|
| 190 | - require_once($beanFiles[$beanList[$module]]); |
|
| 193 | + if (!isset($focus) || !($focus instanceof SugarBean)) { |
|
| 194 | + require_once($beanFiles[$beanList[$module]]); |
|
| 195 | + } |
|
| 191 | 196 | $focus = new $beanList[$module]; |
| 192 | 197 | // create the dropdowns for the parent type fields |
| 193 | 198 | $vardefFields[$fieldname] = $focus->field_defs[$fieldname]; |
@@ -197,11 +202,13 @@ discard block |
||
| 197 | 202 | foreach ($vardefFields as $name => $properties) { |
| 198 | 203 | $fieldlist[$name] = $properties; |
| 199 | 204 | // fill in enums |
| 200 | - if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
|
| 201 | - $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
| 205 | + if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) { |
|
| 206 | + $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
| 207 | + } |
|
| 202 | 208 | // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings |
| 203 | - elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
|
| 204 | - $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
| 209 | + elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) { |
|
| 210 | + $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
| 211 | + } |
|
| 205 | 212 | } |
| 206 | 213 | |
| 207 | 214 | // fill in function return values |
@@ -209,8 +216,9 @@ discard block |
||
| 209 | 216 | if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') { |
| 210 | 217 | $function = $fieldlist[$fieldname]['function']['name']; |
| 211 | 218 | // include various functions required in the various vardefs |
| 212 | - if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
|
| 213 | - require_once($fieldlist[$fieldname]['function']['include']); |
|
| 219 | + if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) { |
|
| 220 | + require_once($fieldlist[$fieldname]['function']['include']); |
|
| 221 | + } |
|
| 214 | 222 | $_REQUEST[$fieldname] = $value; |
| 215 | 223 | $value = $function($focus, $fieldname, $value, $view); |
| 216 | 224 | |
@@ -308,14 +316,14 @@ discard block |
||
| 308 | 316 | |
| 309 | 317 | if ($bean->field_defs[$field]['type'] == "multienum") { |
| 310 | 318 | $bean->$field = encodeMultienumValue($value); |
| 311 | - }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
| 319 | + } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
| 312 | 320 | $save_field = $bean->field_defs[$field]['id_name']; |
| 313 | 321 | $bean->$save_field = $value; |
| 314 | 322 | if ($bean->field_defs[$field]['type'] == 'parent') { |
| 315 | 323 | $bean->parent_type = $_REQUEST['parent_type']; |
| 316 | 324 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
| 317 | 325 | } |
| 318 | - }else{ |
|
| 326 | + } else{ |
|
| 319 | 327 | $bean->$field = $value; |
| 320 | 328 | } |
| 321 | 329 | |
@@ -450,14 +458,15 @@ discard block |
||
| 450 | 458 | |
| 451 | 459 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
| 452 | 460 | $fieldName = 'name';//$vardef['name']; |
| 453 | - if(!is_null($vardef['rname'])) |
|
| 454 | - $fieldName = $vardef['rname']; |
|
| 461 | + if(!is_null($vardef['rname'])) { |
|
| 462 | + $fieldName = $vardef['rname']; |
|
| 463 | + } |
|
| 455 | 464 | |
| 456 | 465 | if($vardef['ext2']){ |
| 457 | 466 | |
| 458 | 467 | $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record) . "</a>"; |
| 459 | 468 | |
| 460 | - }else if(!empty($vardef['rname'])){ |
|
| 469 | + } else if(!empty($vardef['rname'])){ |
|
| 461 | 470 | $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record) . "</a>"; |
| 462 | 471 | |
| 463 | 472 | } else { |
@@ -472,8 +481,9 @@ discard block |
||
| 472 | 481 | function getFieldValueFromModule($fieldname, $module, $id) |
| 473 | 482 | { |
| 474 | 483 | //Github bug 880, if the fieldname is null, do no call from bean |
| 475 | - if(is_null($fieldname)) |
|
| 476 | - return ''; |
|
| 484 | + if(is_null($fieldname)) { |
|
| 485 | + return ''; |
|
| 486 | + } |
|
| 477 | 487 | |
| 478 | 488 | $bean = BeanFactory::getBean($module, $id); |
| 479 | 489 | if (is_object($bean) && $bean->id != "") { |
@@ -497,7 +507,7 @@ discard block |
||
| 497 | 507 | |
| 498 | 508 | if($bean->ACLAccess('EditView')) { |
| 499 | 509 | return true; |
| 500 | - }else { |
|
| 510 | + } else { |
|
| 501 | 511 | return false; |
| 502 | 512 | } |
| 503 | 513 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | //to translate, only modify the right value in each key/value pair |
| 51 | 51 | $app_list_strings = array ( |
| 52 | 52 | //e.g. auf Deutsch 'Contacts'=>'Contakten', |
| 53 | - 'language_pack_name' => 'US English', |
|
| 54 | - 'moduleList' => |
|
| 55 | - array ( |
|
| 53 | + 'language_pack_name' => 'US English', |
|
| 54 | + 'moduleList' => |
|
| 55 | + array ( |
|
| 56 | 56 | 'Home' => 'Home', |
| 57 | 57 | 'Contacts' => 'Contacts', |
| 58 | 58 | 'Accounts' => 'Accounts', |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | 'Newsletters' => 'Newsletters', |
| 107 | 107 | 'SugarFeed'=>'SuiteCRM Feed', |
| 108 | 108 | 'KBDocuments' => 'Knowledge Base', |
| 109 | - 'SugarFavorites'=>'SuiteCRM Favorites', |
|
| 109 | + 'SugarFavorites'=>'SuiteCRM Favorites', |
|
| 110 | 110 | |
| 111 | 111 | 'OAuthKeys' => 'OAuth Consumer Keys', |
| 112 | 112 | 'OAuthTokens' => 'OAuth Tokens', |
| 113 | - ), |
|
| 113 | + ), |
|
| 114 | 114 | |
| 115 | - 'moduleListSingular' => |
|
| 116 | - array ( |
|
| 115 | + 'moduleListSingular' => |
|
| 116 | + array ( |
|
| 117 | 117 | 'Home' => 'Home', |
| 118 | 118 | 'Dashboard' => 'Dashboard', |
| 119 | 119 | 'Contacts' => 'Contact', |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | 'SugarFollowing'=>'SuiteCRM Following', |
| 142 | 142 | 'Sync'=>'Sync', |
| 143 | 143 | 'Users' => 'User', |
| 144 | - 'SugarFavorites'=>'SuiteCRM Favorites' |
|
| 144 | + 'SugarFavorites'=>'SuiteCRM Favorites' |
|
| 145 | 145 | |
| 146 | 146 | ), |
| 147 | 147 | |
| 148 | - 'checkbox_dom'=> array( |
|
| 148 | + 'checkbox_dom'=> array( |
|
| 149 | 149 | ''=>'', |
| 150 | 150 | '1'=>'Yes', |
| 151 | 151 | '2'=>'No', |
| 152 | - ), |
|
| 152 | + ), |
|
| 153 | 153 | |
| 154 | - //e.g. en fran�ais 'Analyst'=>'Analyste', |
|
| 155 | - 'account_type_dom' => |
|
| 156 | - array ( |
|
| 154 | + //e.g. en fran�ais 'Analyst'=>'Analyste', |
|
| 155 | + 'account_type_dom' => |
|
| 156 | + array ( |
|
| 157 | 157 | '' => '', |
| 158 | 158 | 'Analyst' => 'Analyst', |
| 159 | 159 | 'Competitor' => 'Competitor', |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | 'Prospect' => 'Prospect', |
| 166 | 166 | 'Reseller' => 'Reseller', |
| 167 | 167 | 'Other' => 'Other', |
| 168 | - ), |
|
| 169 | - //e.g. en espa�ol 'Apparel'=>'Ropa', |
|
| 170 | - 'industry_dom' => |
|
| 171 | - array ( |
|
| 168 | + ), |
|
| 169 | + //e.g. en espa�ol 'Apparel'=>'Ropa', |
|
| 170 | + 'industry_dom' => |
|
| 171 | + array ( |
|
| 172 | 172 | '' => '', |
| 173 | 173 | 'Apparel' => 'Apparel', |
| 174 | 174 | 'Banking' => 'Banking', |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | 'Transportation' => 'Transportation', |
| 201 | 201 | 'Utilities' => 'Utilities', |
| 202 | 202 | 'Other' => 'Other', |
| 203 | - ), |
|
| 204 | - 'lead_source_default_key' => 'Self Generated', |
|
| 205 | - 'lead_source_dom' => |
|
| 206 | - array ( |
|
| 203 | + ), |
|
| 204 | + 'lead_source_default_key' => 'Self Generated', |
|
| 205 | + 'lead_source_dom' => |
|
| 206 | + array ( |
|
| 207 | 207 | '' => '', |
| 208 | 208 | 'Cold Call' => 'Cold Call', |
| 209 | 209 | 'Existing Customer' => 'Existing Customer', |
@@ -219,26 +219,26 @@ discard block |
||
| 219 | 219 | 'Email' => 'Email', |
| 220 | 220 | 'Campaign'=>'Campaign', |
| 221 | 221 | 'Other' => 'Other', |
| 222 | - ), |
|
| 223 | - 'opportunity_type_dom' => |
|
| 224 | - array ( |
|
| 222 | + ), |
|
| 223 | + 'opportunity_type_dom' => |
|
| 224 | + array ( |
|
| 225 | 225 | '' => '', |
| 226 | 226 | 'Existing Business' => 'Existing Business', |
| 227 | 227 | 'New Business' => 'New Business', |
| 228 | - ), |
|
| 229 | - 'roi_type_dom' => |
|
| 228 | + ), |
|
| 229 | + 'roi_type_dom' => |
|
| 230 | 230 | array ( |
| 231 | 231 | 'Revenue' => 'Revenue', |
| 232 | 232 | 'Investment'=>'Investment', |
| 233 | 233 | 'Expected_Revenue'=>'Expected Revenue', |
| 234 | 234 | 'Budget'=>'Budget', |
| 235 | 235 | |
| 236 | - ), |
|
| 237 | - //Note: do not translate opportunity_relationship_type_default_key |
|
| 236 | + ), |
|
| 237 | + //Note: do not translate opportunity_relationship_type_default_key |
|
| 238 | 238 | // it is the key for the default opportunity_relationship_type_dom value |
| 239 | - 'opportunity_relationship_type_default_key' => 'Primary Decision Maker', |
|
| 240 | - 'opportunity_relationship_type_dom' => |
|
| 241 | - array ( |
|
| 239 | + 'opportunity_relationship_type_default_key' => 'Primary Decision Maker', |
|
| 240 | + 'opportunity_relationship_type_dom' => |
|
| 241 | + array ( |
|
| 242 | 242 | '' => '', |
| 243 | 243 | 'Primary Decision Maker' => 'Primary Decision Maker', |
| 244 | 244 | 'Business Decision Maker' => 'Business Decision Maker', |
@@ -248,29 +248,29 @@ discard block |
||
| 248 | 248 | 'Executive Sponsor' => 'Executive Sponsor', |
| 249 | 249 | 'Influencer' => 'Influencer', |
| 250 | 250 | 'Other' => 'Other', |
| 251 | - ), |
|
| 252 | - //Note: do not translate case_relationship_type_default_key |
|
| 251 | + ), |
|
| 252 | + //Note: do not translate case_relationship_type_default_key |
|
| 253 | 253 | // it is the key for the default case_relationship_type_dom value |
| 254 | - 'case_relationship_type_default_key' => 'Primary Contact', |
|
| 255 | - 'case_relationship_type_dom' => |
|
| 256 | - array ( |
|
| 254 | + 'case_relationship_type_default_key' => 'Primary Contact', |
|
| 255 | + 'case_relationship_type_dom' => |
|
| 256 | + array ( |
|
| 257 | 257 | '' => '', |
| 258 | 258 | 'Primary Contact' => 'Primary Contact', |
| 259 | 259 | 'Alternate Contact' => 'Alternate Contact', |
| 260 | - ), |
|
| 261 | - 'payment_terms' => |
|
| 262 | - array ( |
|
| 260 | + ), |
|
| 261 | + 'payment_terms' => |
|
| 262 | + array ( |
|
| 263 | 263 | '' => '', |
| 264 | 264 | 'Net 15' => 'Net 15', |
| 265 | 265 | 'Net 30' => 'Net 30', |
| 266 | - ), |
|
| 267 | - 'sales_stage_default_key' => 'Prospecting', |
|
| 268 | - 'fts_type' => array ( |
|
| 269 | - '' => '', |
|
| 270 | - 'Elastic' => 'elasticsearch' |
|
| 271 | - ), |
|
| 272 | - 'sales_stage_dom' => |
|
| 273 | - array ( |
|
| 266 | + ), |
|
| 267 | + 'sales_stage_default_key' => 'Prospecting', |
|
| 268 | + 'fts_type' => array ( |
|
| 269 | + '' => '', |
|
| 270 | + 'Elastic' => 'elasticsearch' |
|
| 271 | + ), |
|
| 272 | + 'sales_stage_dom' => |
|
| 273 | + array ( |
|
| 274 | 274 | 'Prospecting' => 'Prospecting', |
| 275 | 275 | 'Qualification' => 'Qualification', |
| 276 | 276 | 'Needs Analysis' => 'Needs Analysis', |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | 'Negotiation/Review' => 'Negotiation/Review', |
| 282 | 282 | 'Closed Won' => 'Closed Won', |
| 283 | 283 | 'Closed Lost' => 'Closed Lost', |
| 284 | - ), |
|
| 285 | - 'in_total_group_stages' => array ( |
|
| 284 | + ), |
|
| 285 | + 'in_total_group_stages' => array ( |
|
| 286 | 286 | 'Draft' => 'Draft', |
| 287 | 287 | 'Negotiation' => 'Negotiation', |
| 288 | 288 | 'Delivered' => 'Delivered', |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | 'Closed Accepted' => 'Closed Accepted', |
| 292 | 292 | 'Closed Lost' => 'Closed Lost', |
| 293 | 293 | 'Closed Dead' => 'Closed Dead', |
| 294 | - ), |
|
| 295 | - 'sales_probability_dom' => // keys must be the same as sales_stage_dom |
|
| 296 | - array ( |
|
| 294 | + ), |
|
| 295 | + 'sales_probability_dom' => // keys must be the same as sales_stage_dom |
|
| 296 | + array ( |
|
| 297 | 297 | 'Prospecting' => '10', |
| 298 | 298 | 'Qualification' => '20', |
| 299 | 299 | 'Needs Analysis' => '25', |
@@ -304,85 +304,85 @@ discard block |
||
| 304 | 304 | 'Negotiation/Review' => '80', |
| 305 | 305 | 'Closed Won' => '100', |
| 306 | 306 | 'Closed Lost' => '0', |
| 307 | - ), |
|
| 308 | - 'activity_dom' => |
|
| 309 | - array ( |
|
| 307 | + ), |
|
| 308 | + 'activity_dom' => |
|
| 309 | + array ( |
|
| 310 | 310 | 'Call' => 'Call', |
| 311 | 311 | 'Meeting' => 'Meeting', |
| 312 | 312 | 'Task' => 'Task', |
| 313 | 313 | 'Email' => 'Email', |
| 314 | 314 | 'Note' => 'Note', |
| 315 | - ), |
|
| 316 | - 'salutation_dom' => |
|
| 317 | - array ( |
|
| 315 | + ), |
|
| 316 | + 'salutation_dom' => |
|
| 317 | + array ( |
|
| 318 | 318 | '' => '', |
| 319 | 319 | 'Mr.' => 'Mr.', |
| 320 | 320 | 'Ms.' => 'Ms.', |
| 321 | 321 | 'Mrs.' => 'Mrs.', |
| 322 | 322 | 'Dr.' => 'Dr.', |
| 323 | 323 | 'Prof.' => 'Prof.', |
| 324 | - ), |
|
| 325 | - //time is in seconds; the greater the time the longer it takes; |
|
| 326 | - 'reminder_max_time' => 90000, |
|
| 327 | - 'reminder_time_options' => array( 60=> '1 minute prior', |
|
| 328 | - 300=> '5 minutes prior', |
|
| 329 | - 600=> '10 minutes prior', |
|
| 330 | - 900=> '15 minutes prior', |
|
| 331 | - 1800=> '30 minutes prior', |
|
| 332 | - 3600=> '1 hour prior', |
|
| 333 | - 7200 => '2 hours prior', |
|
| 334 | - 10800 => '3 hours prior', |
|
| 335 | - 18000 => '5 hours prior', |
|
| 336 | - 86400 => '1 day prior', |
|
| 337 | - ), |
|
| 338 | - |
|
| 339 | - 'task_priority_default' => 'Medium', |
|
| 340 | - 'task_priority_dom' => |
|
| 341 | - array ( |
|
| 324 | + ), |
|
| 325 | + //time is in seconds; the greater the time the longer it takes; |
|
| 326 | + 'reminder_max_time' => 90000, |
|
| 327 | + 'reminder_time_options' => array( 60=> '1 minute prior', |
|
| 328 | + 300=> '5 minutes prior', |
|
| 329 | + 600=> '10 minutes prior', |
|
| 330 | + 900=> '15 minutes prior', |
|
| 331 | + 1800=> '30 minutes prior', |
|
| 332 | + 3600=> '1 hour prior', |
|
| 333 | + 7200 => '2 hours prior', |
|
| 334 | + 10800 => '3 hours prior', |
|
| 335 | + 18000 => '5 hours prior', |
|
| 336 | + 86400 => '1 day prior', |
|
| 337 | + ), |
|
| 338 | + |
|
| 339 | + 'task_priority_default' => 'Medium', |
|
| 340 | + 'task_priority_dom' => |
|
| 341 | + array ( |
|
| 342 | 342 | 'High' => 'High', |
| 343 | 343 | 'Medium' => 'Medium', |
| 344 | 344 | 'Low' => 'Low', |
| 345 | - ), |
|
| 346 | - 'task_status_default' => 'Not Started', |
|
| 347 | - 'task_status_dom' => |
|
| 348 | - array ( |
|
| 345 | + ), |
|
| 346 | + 'task_status_default' => 'Not Started', |
|
| 347 | + 'task_status_dom' => |
|
| 348 | + array ( |
|
| 349 | 349 | 'Not Started' => 'Not Started', |
| 350 | 350 | 'In Progress' => 'In Progress', |
| 351 | 351 | 'Completed' => 'Completed', |
| 352 | 352 | 'Pending Input' => 'Pending Input', |
| 353 | 353 | 'Deferred' => 'Deferred', |
| 354 | - ), |
|
| 355 | - 'meeting_status_default' => 'Planned', |
|
| 356 | - 'meeting_status_dom' => |
|
| 357 | - array ( |
|
| 354 | + ), |
|
| 355 | + 'meeting_status_default' => 'Planned', |
|
| 356 | + 'meeting_status_dom' => |
|
| 357 | + array ( |
|
| 358 | 358 | 'Planned' => 'Planned', |
| 359 | 359 | 'Held' => 'Held', |
| 360 | 360 | 'Not Held' => 'Not Held', |
| 361 | - ), |
|
| 362 | - 'extapi_meeting_password' => |
|
| 363 | - array ( |
|
| 364 | - 'WebEx' => 'WebEx', |
|
| 365 | - ), |
|
| 366 | - 'meeting_type_dom' => |
|
| 367 | - array ( |
|
| 368 | - 'Other' => 'Other', |
|
| 369 | - 'Sugar' => 'SuiteCRM', |
|
| 370 | - ), |
|
| 371 | - 'call_status_default' => 'Planned', |
|
| 372 | - 'call_status_dom' => |
|
| 373 | - array ( |
|
| 361 | + ), |
|
| 362 | + 'extapi_meeting_password' => |
|
| 363 | + array ( |
|
| 364 | + 'WebEx' => 'WebEx', |
|
| 365 | + ), |
|
| 366 | + 'meeting_type_dom' => |
|
| 367 | + array ( |
|
| 368 | + 'Other' => 'Other', |
|
| 369 | + 'Sugar' => 'SuiteCRM', |
|
| 370 | + ), |
|
| 371 | + 'call_status_default' => 'Planned', |
|
| 372 | + 'call_status_dom' => |
|
| 373 | + array ( |
|
| 374 | 374 | 'Planned' => 'Planned', |
| 375 | 375 | 'Held' => 'Held', |
| 376 | 376 | 'Not Held' => 'Not Held', |
| 377 | - ), |
|
| 378 | - 'call_direction_default' => 'Outbound', |
|
| 379 | - 'call_direction_dom' => |
|
| 380 | - array ( |
|
| 377 | + ), |
|
| 378 | + 'call_direction_default' => 'Outbound', |
|
| 379 | + 'call_direction_dom' => |
|
| 380 | + array ( |
|
| 381 | 381 | 'Inbound' => 'Inbound', |
| 382 | 382 | 'Outbound' => 'Outbound', |
| 383 | - ), |
|
| 384 | - 'lead_status_dom' => |
|
| 385 | - array ( |
|
| 383 | + ), |
|
| 384 | + 'lead_status_dom' => |
|
| 385 | + array ( |
|
| 386 | 386 | '' => '', |
| 387 | 387 | 'New' => 'New', |
| 388 | 388 | 'Assigned' => 'Assigned', |
@@ -390,54 +390,54 @@ discard block |
||
| 390 | 390 | 'Converted' => 'Converted', |
| 391 | 391 | 'Recycled' => 'Recycled', |
| 392 | 392 | 'Dead' => 'Dead', |
| 393 | - ), |
|
| 394 | - 'gender_list' => |
|
| 395 | - array ( |
|
| 393 | + ), |
|
| 394 | + 'gender_list' => |
|
| 395 | + array ( |
|
| 396 | 396 | 'male' => 'Male', |
| 397 | 397 | 'female' => 'Female', |
| 398 | - ), |
|
| 399 | - //Note: do not translate case_status_default_key |
|
| 398 | + ), |
|
| 399 | + //Note: do not translate case_status_default_key |
|
| 400 | 400 | // it is the key for the default case_status_dom value |
| 401 | - 'case_status_default_key' => 'New', |
|
| 402 | - 'case_status_dom' => |
|
| 403 | - array ( |
|
| 401 | + 'case_status_default_key' => 'New', |
|
| 402 | + 'case_status_dom' => |
|
| 403 | + array ( |
|
| 404 | 404 | 'New' => 'New', |
| 405 | 405 | 'Assigned' => 'Assigned', |
| 406 | 406 | 'Closed' => 'Closed', |
| 407 | 407 | 'Pending Input' => 'Pending Input', |
| 408 | 408 | 'Rejected' => 'Rejected', |
| 409 | 409 | 'Duplicate' => 'Duplicate', |
| 410 | - ), |
|
| 411 | - 'case_priority_default_key' => 'P2', |
|
| 412 | - 'case_priority_dom' => |
|
| 413 | - array ( |
|
| 410 | + ), |
|
| 411 | + 'case_priority_default_key' => 'P2', |
|
| 412 | + 'case_priority_dom' => |
|
| 413 | + array ( |
|
| 414 | 414 | 'P1' => 'High', |
| 415 | 415 | 'P2' => 'Medium', |
| 416 | 416 | 'P3' => 'Low', |
| 417 | - ), |
|
| 418 | - 'user_type_dom' => |
|
| 419 | - array ( |
|
| 417 | + ), |
|
| 418 | + 'user_type_dom' => |
|
| 419 | + array ( |
|
| 420 | 420 | 'RegularUser' => 'Regular User', |
| 421 | 421 | 'Administrator' => 'Administrator', |
| 422 | - ), |
|
| 423 | - 'user_status_dom' => |
|
| 424 | - array ( |
|
| 422 | + ), |
|
| 423 | + 'user_status_dom' => |
|
| 424 | + array ( |
|
| 425 | 425 | 'Active' => 'Active', |
| 426 | 426 | 'Inactive' => 'Inactive', |
| 427 | - ), |
|
| 428 | - 'employee_status_dom' => |
|
| 429 | - array ( |
|
| 427 | + ), |
|
| 428 | + 'employee_status_dom' => |
|
| 429 | + array ( |
|
| 430 | 430 | 'Active' => 'Active', |
| 431 | 431 | 'Terminated' => 'Terminated', |
| 432 | 432 | 'Leave of Absence' => 'Leave of Absence', |
| 433 | - ), |
|
| 434 | - 'messenger_type_dom' => |
|
| 435 | - array ( |
|
| 433 | + ), |
|
| 434 | + 'messenger_type_dom' => |
|
| 435 | + array ( |
|
| 436 | 436 | '' => '', |
| 437 | 437 | 'MSN' => 'MSN', |
| 438 | 438 | 'Yahoo!' => 'Yahoo!', |
| 439 | 439 | 'AOL' => 'AOL', |
| 440 | - ), |
|
| 440 | + ), |
|
| 441 | 441 | 'project_task_priority_options' => array ( |
| 442 | 442 | 'High' => 'High', |
| 443 | 443 | 'Medium' => 'Medium', |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | 'Low' => 'Low', |
| 481 | 481 | ), |
| 482 | 482 | 'project_priority_default' => 'Medium', |
| 483 | - //Note: do not translate record_type_default_key |
|
| 483 | + //Note: do not translate record_type_default_key |
|
| 484 | 484 | // it is the key for the default record_type_module value |
| 485 | - 'record_type_default_key' => 'Accounts', |
|
| 486 | - 'record_type_display' => |
|
| 487 | - array ( |
|
| 485 | + 'record_type_default_key' => 'Accounts', |
|
| 486 | + 'record_type_display' => |
|
| 487 | + array ( |
|
| 488 | 488 | '' => '', |
| 489 | 489 | 'Accounts' => 'Account', |
| 490 | 490 | 'Opportunities' => 'Opportunity', |
@@ -502,10 +502,10 @@ discard block |
||
| 502 | 502 | |
| 503 | 503 | 'Tasks' => 'Task', |
| 504 | 504 | |
| 505 | - ), |
|
| 505 | + ), |
|
| 506 | 506 | |
| 507 | - 'record_type_display_notes' => |
|
| 508 | - array ( |
|
| 507 | + 'record_type_display_notes' => |
|
| 508 | + array ( |
|
| 509 | 509 | 'Accounts' => 'Account', |
| 510 | 510 | 'Contacts' => 'Contact', |
| 511 | 511 | 'Opportunities' => 'Opportunity', |
@@ -521,10 +521,10 @@ discard block |
||
| 521 | 521 | |
| 522 | 522 | 'Meetings' => 'Meeting', |
| 523 | 523 | 'Calls' => 'Call', |
| 524 | - ), |
|
| 524 | + ), |
|
| 525 | 525 | |
| 526 | - 'parent_type_display' => |
|
| 527 | - array ( |
|
| 526 | + 'parent_type_display' => |
|
| 527 | + array ( |
|
| 528 | 528 | 'Accounts' => 'Account', |
| 529 | 529 | 'Contacts' => 'Contact', |
| 530 | 530 | 'Tasks' => 'Task', |
@@ -541,48 +541,48 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | 'Prospects' => 'Target', |
| 543 | 543 | |
| 544 | - ), |
|
| 544 | + ), |
|
| 545 | 545 | |
| 546 | - 'issue_priority_default_key' => 'Medium', |
|
| 547 | - 'issue_priority_dom' => |
|
| 548 | - array ( |
|
| 546 | + 'issue_priority_default_key' => 'Medium', |
|
| 547 | + 'issue_priority_dom' => |
|
| 548 | + array ( |
|
| 549 | 549 | 'Urgent' => 'Urgent', |
| 550 | 550 | 'High' => 'High', |
| 551 | 551 | 'Medium' => 'Medium', |
| 552 | 552 | 'Low' => 'Low', |
| 553 | - ), |
|
| 554 | - 'issue_resolution_default_key' => '', |
|
| 555 | - 'issue_resolution_dom' => |
|
| 556 | - array ( |
|
| 553 | + ), |
|
| 554 | + 'issue_resolution_default_key' => '', |
|
| 555 | + 'issue_resolution_dom' => |
|
| 556 | + array ( |
|
| 557 | 557 | '' => '', |
| 558 | 558 | 'Accepted' => 'Accepted', |
| 559 | 559 | 'Duplicate' => 'Duplicate', |
| 560 | 560 | 'Closed' => 'Closed', |
| 561 | 561 | 'Out of Date' => 'Out of Date', |
| 562 | 562 | 'Invalid' => 'Invalid', |
| 563 | - ), |
|
| 563 | + ), |
|
| 564 | 564 | |
| 565 | - 'issue_status_default_key' => 'New', |
|
| 566 | - 'issue_status_dom' => |
|
| 567 | - array ( |
|
| 565 | + 'issue_status_default_key' => 'New', |
|
| 566 | + 'issue_status_dom' => |
|
| 567 | + array ( |
|
| 568 | 568 | 'New' => 'New', |
| 569 | 569 | 'Assigned' => 'Assigned', |
| 570 | 570 | 'Closed' => 'Closed', |
| 571 | 571 | 'Pending' => 'Pending', |
| 572 | 572 | 'Rejected' => 'Rejected', |
| 573 | - ), |
|
| 573 | + ), |
|
| 574 | 574 | |
| 575 | - 'bug_priority_default_key' => 'Medium', |
|
| 576 | - 'bug_priority_dom' => |
|
| 577 | - array ( |
|
| 575 | + 'bug_priority_default_key' => 'Medium', |
|
| 576 | + 'bug_priority_dom' => |
|
| 577 | + array ( |
|
| 578 | 578 | 'Urgent' => 'Urgent', |
| 579 | 579 | 'High' => 'High', |
| 580 | 580 | 'Medium' => 'Medium', |
| 581 | 581 | 'Low' => 'Low', |
| 582 | - ), |
|
| 583 | - 'bug_resolution_default_key' => '', |
|
| 584 | - 'bug_resolution_dom' => |
|
| 585 | - array ( |
|
| 582 | + ), |
|
| 583 | + 'bug_resolution_default_key' => '', |
|
| 584 | + 'bug_resolution_dom' => |
|
| 585 | + array ( |
|
| 586 | 586 | '' => '', |
| 587 | 587 | 'Accepted' => 'Accepted', |
| 588 | 588 | 'Duplicate' => 'Duplicate', |
@@ -590,42 +590,42 @@ discard block |
||
| 590 | 590 | 'Out of Date' => 'Out of Date', |
| 591 | 591 | 'Invalid' => 'Invalid', |
| 592 | 592 | 'Later' => 'Later', |
| 593 | - ), |
|
| 594 | - 'bug_status_default_key' => 'New', |
|
| 595 | - 'bug_status_dom' => |
|
| 596 | - array ( |
|
| 593 | + ), |
|
| 594 | + 'bug_status_default_key' => 'New', |
|
| 595 | + 'bug_status_dom' => |
|
| 596 | + array ( |
|
| 597 | 597 | 'New' => 'New', |
| 598 | 598 | 'Assigned' => 'Assigned', |
| 599 | 599 | 'Closed' => 'Closed', |
| 600 | 600 | 'Pending' => 'Pending', |
| 601 | 601 | 'Rejected' => 'Rejected', |
| 602 | - ), |
|
| 603 | - 'bug_type_default_key' => 'Bug', |
|
| 604 | - 'bug_type_dom' => |
|
| 605 | - array ( |
|
| 602 | + ), |
|
| 603 | + 'bug_type_default_key' => 'Bug', |
|
| 604 | + 'bug_type_dom' => |
|
| 605 | + array ( |
|
| 606 | 606 | 'Defect' => 'Defect', |
| 607 | 607 | 'Feature' => 'Feature', |
| 608 | - ), |
|
| 609 | - 'case_type_dom' => |
|
| 610 | - array ( |
|
| 608 | + ), |
|
| 609 | + 'case_type_dom' => |
|
| 610 | + array ( |
|
| 611 | 611 | 'Administration' => 'Administration', |
| 612 | 612 | 'Product' => 'Product', |
| 613 | 613 | 'User' => 'User', |
| 614 | - ), |
|
| 614 | + ), |
|
| 615 | 615 | |
| 616 | - 'source_default_key' => '', |
|
| 617 | - 'source_dom' => |
|
| 618 | - array ( |
|
| 616 | + 'source_default_key' => '', |
|
| 617 | + 'source_dom' => |
|
| 618 | + array ( |
|
| 619 | 619 | '' => '', |
| 620 | 620 | 'Internal' => 'Internal', |
| 621 | 621 | 'Forum' => 'Forum', |
| 622 | 622 | 'Web' => 'Web', |
| 623 | 623 | 'InboundEmail' => 'Email' |
| 624 | - ), |
|
| 624 | + ), |
|
| 625 | 625 | |
| 626 | - 'product_category_default_key' => '', |
|
| 627 | - 'product_category_dom' => |
|
| 628 | - array ( |
|
| 626 | + 'product_category_default_key' => '', |
|
| 627 | + 'product_category_dom' => |
|
| 628 | + array ( |
|
| 629 | 629 | '' => '', |
| 630 | 630 | 'Accounts' => 'Accounts', |
| 631 | 631 | 'Activities' => 'Activities', |
@@ -636,15 +636,15 @@ discard block |
||
| 636 | 636 | 'Cases' => 'Cases', |
| 637 | 637 | 'Contacts' => 'Contacts', |
| 638 | 638 | 'Currencies' => 'Currencies', |
| 639 | - 'Dashboard' => 'Dashboard', |
|
| 640 | - 'Documents' => 'Documents', |
|
| 639 | + 'Dashboard' => 'Dashboard', |
|
| 640 | + 'Documents' => 'Documents', |
|
| 641 | 641 | 'Emails' => 'Emails', |
| 642 | 642 | 'Feeds' => 'Feeds', |
| 643 | 643 | 'Forecasts' => 'Forecasts', |
| 644 | 644 | 'Help' => 'Help', |
| 645 | 645 | 'Home' => 'Home', |
| 646 | - 'Leads' => 'Leads', |
|
| 647 | - 'Meetings' => 'Meetings', |
|
| 646 | + 'Leads' => 'Leads', |
|
| 647 | + 'Meetings' => 'Meetings', |
|
| 648 | 648 | 'Notes' => 'Notes', |
| 649 | 649 | 'Opportunities' => 'Opportunities', |
| 650 | 650 | 'Outlook Plugin' => 'Outlook Plugin', |
@@ -655,10 +655,10 @@ discard block |
||
| 655 | 655 | 'Studio' => 'Studio', |
| 656 | 656 | 'Upgrade' => 'Upgrade', |
| 657 | 657 | 'Users' => 'Users', |
| 658 | - ), |
|
| 659 | - /*Added entries 'Queued' and 'Sending' for 4.0 release..*/ |
|
| 660 | - 'campaign_status_dom' => |
|
| 661 | - array ( |
|
| 658 | + ), |
|
| 659 | + /*Added entries 'Queued' and 'Sending' for 4.0 release..*/ |
|
| 660 | + 'campaign_status_dom' => |
|
| 661 | + array ( |
|
| 662 | 662 | '' => '', |
| 663 | 663 | 'Planning' => 'Planning', |
| 664 | 664 | 'Active' => 'Active', |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | 'Complete' => 'Complete', |
| 667 | 667 | 'In Queue' => 'In Queue', |
| 668 | 668 | 'Sending'=> 'Sending', |
| 669 | - ), |
|
| 670 | - 'campaign_type_dom' => |
|
| 671 | - array ( |
|
| 669 | + ), |
|
| 670 | + 'campaign_type_dom' => |
|
| 671 | + array ( |
|
| 672 | 672 | '' => '', |
| 673 | 673 | 'Telesales' => 'Telesales', |
| 674 | 674 | 'Mail' => 'Mail', |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | 'NewsLetter' => 'Newsletter', |
| 681 | 681 | ), |
| 682 | 682 | |
| 683 | - 'newsletter_frequency_dom' => |
|
| 684 | - array ( |
|
| 683 | + 'newsletter_frequency_dom' => |
|
| 684 | + array ( |
|
| 685 | 685 | '' => '', |
| 686 | 686 | 'Weekly' => 'Weekly', |
| 687 | 687 | 'Monthly' => 'Monthly', |
@@ -689,11 +689,11 @@ discard block |
||
| 689 | 689 | 'Annually' => 'Annually', |
| 690 | 690 | ), |
| 691 | 691 | |
| 692 | - 'notifymail_sendtype' => |
|
| 693 | - array ( |
|
| 692 | + 'notifymail_sendtype' => |
|
| 693 | + array ( |
|
| 694 | 694 | 'SMTP' => 'SMTP', |
| 695 | - ), |
|
| 696 | - 'dom_cal_month_long'=>array( |
|
| 695 | + ), |
|
| 696 | + 'dom_cal_month_long'=>array( |
|
| 697 | 697 | '0'=>"", |
| 698 | 698 | '1'=>"January", |
| 699 | 699 | '2'=>"February", |
@@ -748,8 +748,8 @@ discard block |
||
| 748 | 748 | 'pm'=>"pm" |
| 749 | 749 | ), |
| 750 | 750 | 'dom_meridiem_uppercase'=>array( |
| 751 | - 'AM'=>'AM', |
|
| 752 | - 'PM'=>'PM' |
|
| 751 | + 'AM'=>'AM', |
|
| 752 | + 'PM'=>'PM' |
|
| 753 | 753 | ), |
| 754 | 754 | |
| 755 | 755 | 'dom_report_types'=>array( |
@@ -785,26 +785,26 @@ discard block |
||
| 785 | 785 | 'imap' => 'IMAP', |
| 786 | 786 | ), |
| 787 | 787 | 'dom_mailbox_type' => array(/*'' => '--None Specified--',*/ |
| 788 | - 'pick' => '--None--', |
|
| 789 | - 'createcase' => 'Create Case', |
|
| 790 | - 'bounce' => 'Bounce Handling', |
|
| 788 | + 'pick' => '--None--', |
|
| 789 | + 'createcase' => 'Create Case', |
|
| 790 | + 'bounce' => 'Bounce Handling', |
|
| 791 | 791 | ), |
| 792 | 792 | 'dom_email_distribution'=> array('' => '--None--', |
| 793 | - 'direct' => 'Direct Assign', |
|
| 794 | - 'roundRobin' => 'Round-Robin', |
|
| 795 | - 'leastBusy' => 'Least-Busy', |
|
| 793 | + 'direct' => 'Direct Assign', |
|
| 794 | + 'roundRobin' => 'Round-Robin', |
|
| 795 | + 'leastBusy' => 'Least-Busy', |
|
| 796 | 796 | ), |
| 797 | 797 | 'dom_email_distribution_for_auto_create'=> array('roundRobin' => 'Round-Robin', |
| 798 | - 'leastBusy' => 'Least-Busy', |
|
| 798 | + 'leastBusy' => 'Least-Busy', |
|
| 799 | 799 | ), |
| 800 | 800 | 'dom_email_errors' => array(1 => 'Only select one user when Direct Assigning items.', |
| 801 | - 2 => 'You must assign Only Checked Items when Direct Assigning items.', |
|
| 801 | + 2 => 'You must assign Only Checked Items when Direct Assigning items.', |
|
| 802 | 802 | ), |
| 803 | 803 | 'dom_email_bool' => array('bool_true' => 'Yes', |
| 804 | - 'bool_false' => 'No', |
|
| 804 | + 'bool_false' => 'No', |
|
| 805 | 805 | ), |
| 806 | 806 | 'dom_int_bool' => array(1 => 'Yes', |
| 807 | - 0 => 'No', |
|
| 807 | + 0 => 'No', |
|
| 808 | 808 | ), |
| 809 | 809 | 'dom_switch_bool' => array ('on' => 'Yes', |
| 810 | 810 | 'off' => 'No', |
@@ -841,19 +841,19 @@ discard block |
||
| 841 | 841 | array ( |
| 842 | 842 | 'Active' => 'Active', |
| 843 | 843 | 'Inactive' => 'Inactive', |
| 844 | - ), |
|
| 844 | + ), |
|
| 845 | 845 | 'forecast_type_dom' => |
| 846 | 846 | array ( |
| 847 | 847 | 'Direct' => 'Direct', |
| 848 | 848 | 'Rollup' => 'Rollup', |
| 849 | - ), |
|
| 849 | + ), |
|
| 850 | 850 | 'document_category_dom' => |
| 851 | 851 | array ( |
| 852 | 852 | '' => '', |
| 853 | 853 | 'Marketing' => 'Marketing', |
| 854 | 854 | 'Knowledege Base' => 'Knowledge Base', |
| 855 | 855 | 'Sales' => 'Sales', |
| 856 | - ), |
|
| 856 | + ), |
|
| 857 | 857 | |
| 858 | 858 | 'document_subcategory_dom' => |
| 859 | 859 | array ( |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | 'Marketing Collateral' => 'Marketing Collateral', |
| 862 | 862 | 'Product Brochures' => 'Product Brochures', |
| 863 | 863 | 'FAQ' => 'FAQ', |
| 864 | - ), |
|
| 864 | + ), |
|
| 865 | 865 | |
| 866 | 866 | 'document_status_dom' => |
| 867 | 867 | array ( |
@@ -871,39 +871,39 @@ discard block |
||
| 871 | 871 | 'Expired' => 'Expired', |
| 872 | 872 | 'Under Review' => 'Under Review', |
| 873 | 873 | 'Pending' => 'Pending', |
| 874 | - ), |
|
| 875 | - 'document_template_type_dom' => |
|
| 876 | - array( |
|
| 874 | + ), |
|
| 875 | + 'document_template_type_dom' => |
|
| 876 | + array( |
|
| 877 | 877 | ''=>'', |
| 878 | 878 | 'mailmerge'=>'Mail Merge', |
| 879 | 879 | 'eula'=>'EULA', |
| 880 | 880 | 'nda'=>'NDA', |
| 881 | 881 | 'license'=>'License Agreement', |
| 882 | - ), |
|
| 882 | + ), |
|
| 883 | 883 | 'dom_meeting_accept_options' => |
| 884 | 884 | array ( |
| 885 | 885 | 'accept' => 'Accept', |
| 886 | 886 | 'decline' => 'Decline', |
| 887 | 887 | 'tentative' => 'Tentative', |
| 888 | - ), |
|
| 888 | + ), |
|
| 889 | 889 | 'dom_meeting_accept_status' => |
| 890 | 890 | array ( |
| 891 | 891 | 'accept' => 'Accepted', |
| 892 | 892 | 'decline' => 'Declined', |
| 893 | 893 | 'tentative' => 'Tentative', |
| 894 | 894 | 'none' => 'None', |
| 895 | - ), |
|
| 895 | + ), |
|
| 896 | 896 | 'duration_intervals' => array('0'=>'00', |
| 897 | 897 | '15'=>'15', |
| 898 | 898 | '30'=>'30', |
| 899 | 899 | '45'=>'45', |
| 900 | - ), |
|
| 900 | + ), |
|
| 901 | 901 | 'repeat_type_dom' => array( |
| 902 | - '' => 'None', |
|
| 903 | - 'Daily' => 'Daily', |
|
| 904 | - 'Weekly' => 'Weekly', |
|
| 905 | - 'Monthly' => 'Monthly', |
|
| 906 | - 'Yearly' => 'Yearly', |
|
| 902 | + '' => 'None', |
|
| 903 | + 'Daily' => 'Daily', |
|
| 904 | + 'Weekly' => 'Weekly', |
|
| 905 | + 'Monthly' => 'Monthly', |
|
| 906 | + 'Yearly' => 'Yearly', |
|
| 907 | 907 | ), |
| 908 | 908 | |
| 909 | 909 | 'repeat_intervals' => array( |
@@ -915,19 +915,19 @@ discard block |
||
| 915 | 915 | ), |
| 916 | 916 | |
| 917 | 917 | 'duration_dom' => array( |
| 918 | - '' => 'None', |
|
| 919 | - '900' => '15 minutes', |
|
| 920 | - '1800' => '30 minutes', |
|
| 921 | - '2700' => '45 minutes', |
|
| 922 | - '3600' => '1 hour', |
|
| 923 | - '5400' => '1.5 hours', |
|
| 924 | - '7200' => '2 hours', |
|
| 925 | - '10800' => '3 hours', |
|
| 926 | - '21600' => '6 hours', |
|
| 927 | - '86400' => '1 day', |
|
| 928 | - '172800' => '2 days', |
|
| 929 | - '259200' => '3 days', |
|
| 930 | - '604800' => '1 week', |
|
| 918 | + '' => 'None', |
|
| 919 | + '900' => '15 minutes', |
|
| 920 | + '1800' => '30 minutes', |
|
| 921 | + '2700' => '45 minutes', |
|
| 922 | + '3600' => '1 hour', |
|
| 923 | + '5400' => '1.5 hours', |
|
| 924 | + '7200' => '2 hours', |
|
| 925 | + '10800' => '3 hours', |
|
| 926 | + '21600' => '6 hours', |
|
| 927 | + '86400' => '1 day', |
|
| 928 | + '172800' => '2 days', |
|
| 929 | + '259200' => '3 days', |
|
| 930 | + '604800' => '1 week', |
|
| 931 | 931 | ), |
| 932 | 932 | |
| 933 | 933 | // deferred |
@@ -938,31 +938,31 @@ discard block |
||
| 938 | 938 | ), |
| 939 | 939 | */ |
| 940 | 940 | //prospect list type dom |
| 941 | - 'prospect_list_type_dom' => |
|
| 942 | - array ( |
|
| 941 | + 'prospect_list_type_dom' => |
|
| 942 | + array ( |
|
| 943 | 943 | 'default' => 'Default', |
| 944 | 944 | 'seed' => 'Seed', |
| 945 | 945 | 'exempt_domain' => 'Suppression List - By Domain', |
| 946 | 946 | 'exempt_address' => 'Suppression List - By Email Address', |
| 947 | 947 | 'exempt' => 'Suppression List - By Id', |
| 948 | 948 | 'test' => 'Test', |
| 949 | - ), |
|
| 949 | + ), |
|
| 950 | 950 | |
| 951 | - 'email_settings_num_dom' => |
|
| 952 | - array( |
|
| 951 | + 'email_settings_num_dom' => |
|
| 952 | + array( |
|
| 953 | 953 | '10' => '10', |
| 954 | 954 | '20' => '20', |
| 955 | 955 | '50' => '50' |
| 956 | 956 | ), |
| 957 | - 'email_marketing_status_dom' => |
|
| 958 | - array ( |
|
| 957 | + 'email_marketing_status_dom' => |
|
| 958 | + array ( |
|
| 959 | 959 | '' => '', |
| 960 | 960 | 'active'=>'Active', |
| 961 | 961 | 'inactive'=>'Inactive' |
| 962 | - ), |
|
| 962 | + ), |
|
| 963 | 963 | |
| 964 | - 'campainglog_activity_type_dom' => |
|
| 965 | - array ( |
|
| 964 | + 'campainglog_activity_type_dom' => |
|
| 965 | + array ( |
|
| 966 | 966 | ''=>'', |
| 967 | 967 | 'targeted' => 'Message Sent/Attempted', |
| 968 | 968 | 'send error'=>'Bounced Messages,Other', |
@@ -973,27 +973,27 @@ discard block |
||
| 973 | 973 | 'lead'=>'Leads Created', |
| 974 | 974 | 'contact'=>'Contacts Created', |
| 975 | 975 | 'blocked'=>'Suppressed by address or domain', |
| 976 | - ), |
|
| 976 | + ), |
|
| 977 | 977 | |
| 978 | - 'campainglog_target_type_dom' => |
|
| 979 | - array ( |
|
| 978 | + 'campainglog_target_type_dom' => |
|
| 979 | + array ( |
|
| 980 | 980 | 'Contacts' => 'Contacts', |
| 981 | 981 | 'Users'=>'Users', |
| 982 | 982 | 'Prospects'=>'Targets', |
| 983 | 983 | 'Leads'=>'Leads', |
| 984 | 984 | 'Accounts'=>'Accounts', |
| 985 | - ), |
|
| 986 | - 'merge_operators_dom' => array ( |
|
| 985 | + ), |
|
| 986 | + 'merge_operators_dom' => array ( |
|
| 987 | 987 | 'like'=>'Contains', |
| 988 | 988 | 'exact'=>'Exactly', |
| 989 | 989 | 'start'=>'Starts With', |
| 990 | - ), |
|
| 990 | + ), |
|
| 991 | 991 | |
| 992 | - 'custom_fields_importable_dom' => array ( |
|
| 992 | + 'custom_fields_importable_dom' => array ( |
|
| 993 | 993 | 'true'=>'Yes', |
| 994 | 994 | 'false'=>'No', |
| 995 | 995 | 'required'=>'Required', |
| 996 | - ), |
|
| 996 | + ), |
|
| 997 | 997 | |
| 998 | 998 | 'Elastic_boost_options' => array ( |
| 999 | 999 | '0' =>'Disabled', |
@@ -1002,15 +1002,15 @@ discard block |
||
| 1002 | 1002 | '3'=>'High Boost', |
| 1003 | 1003 | ), |
| 1004 | 1004 | |
| 1005 | - 'custom_fields_merge_dup_dom'=> array ( |
|
| 1005 | + 'custom_fields_merge_dup_dom'=> array ( |
|
| 1006 | 1006 | 0=>'Disabled', |
| 1007 | 1007 | 1=>'Enabled', |
| 1008 | - ), |
|
| 1008 | + ), |
|
| 1009 | 1009 | |
| 1010 | - 'navigation_paradigms' => array( |
|
| 1010 | + 'navigation_paradigms' => array( |
|
| 1011 | 1011 | 'm'=>'Modules', |
| 1012 | 1012 | 'gm'=>'Grouped Modules', |
| 1013 | - ), |
|
| 1013 | + ), |
|
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | 1016 | 'projects_priority_options' => array ( |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | '300' => 'Every 5 minutes', |
| 1084 | 1084 | '600' => 'Every 10 minutes', |
| 1085 | 1085 | ), |
| 1086 | - 'dashlet_auto_refresh_options_admin' => |
|
| 1086 | + 'dashlet_auto_refresh_options_admin' => |
|
| 1087 | 1087 | array ( |
| 1088 | 1088 | '-1' => 'Never', |
| 1089 | 1089 | '30' => 'Every 30 seconds', |
@@ -1092,8 +1092,8 @@ discard block |
||
| 1092 | 1092 | '300' => 'Every 5 minutes', |
| 1093 | 1093 | '600' => 'Every 10 minutes', |
| 1094 | 1094 | ), |
| 1095 | - 'date_range_search_dom' => |
|
| 1096 | - array( |
|
| 1095 | + 'date_range_search_dom' => |
|
| 1096 | + array( |
|
| 1097 | 1097 | '=' => 'Equals', |
| 1098 | 1098 | 'not_equal' => 'Not On', |
| 1099 | 1099 | 'greater_than' => 'After', |
@@ -1109,9 +1109,9 @@ discard block |
||
| 1109 | 1109 | 'this_year' => 'This Year', |
| 1110 | 1110 | 'next_year' => 'Next Year', |
| 1111 | 1111 | 'between' => 'Is Between', |
| 1112 | - ), |
|
| 1113 | - 'numeric_range_search_dom' => |
|
| 1114 | - array( |
|
| 1112 | + ), |
|
| 1113 | + 'numeric_range_search_dom' => |
|
| 1114 | + array( |
|
| 1115 | 1115 | '=' => 'Equals', |
| 1116 | 1116 | 'not_equal' => 'Does Not Equal', |
| 1117 | 1117 | 'greater_than' => 'Greater Than', |
@@ -1119,46 +1119,46 @@ discard block |
||
| 1119 | 1119 | 'less_than' => 'Less Than', |
| 1120 | 1120 | 'less_than_equals' => 'Less Than Or Equal To', |
| 1121 | 1121 | 'between' => 'Is Between', |
| 1122 | - ), |
|
| 1123 | - 'lead_conv_activity_opt' => |
|
| 1124 | - array( |
|
| 1122 | + ), |
|
| 1123 | + 'lead_conv_activity_opt' => |
|
| 1124 | + array( |
|
| 1125 | 1125 | 'copy' => 'Copy', |
| 1126 | 1126 | 'move' => 'Move', |
| 1127 | 1127 | 'donothing' => 'Do Nothing', |
| 1128 | - ), |
|
| 1128 | + ), |
|
| 1129 | 1129 | ); |
| 1130 | 1130 | |
| 1131 | 1131 | $app_strings = array ( |
| 1132 | - 'LBL_TOUR_NEXT' => 'Next', |
|
| 1133 | - 'LBL_TOUR_SKIP' => 'Skip', |
|
| 1134 | - 'LBL_TOUR_BACK' => 'Back', |
|
| 1135 | - 'LBL_TOUR_CLOSE' => 'Close', |
|
| 1136 | - 'LBL_TOUR_TAKE_TOUR' => 'Take the tour', |
|
| 1137 | - 'LBL_MY_AREA_LINKS' => 'My area links: ' /*for 508 compliance fix*/, |
|
| 1138 | - 'LBL_GETTINGAIR' => 'Getting Air' /*for 508 compliance fix*/, |
|
| 1139 | - 'LBL_WELCOMEBAR' => 'Welcome' /*for 508 compliance fix*/, |
|
| 1140 | - 'LBL_ADVANCEDSEARCH' => 'Advanced Search' /*for 508 compliance fix*/, |
|
| 1141 | - 'LBL_MOREDETAIL' => 'More Detail' /*for 508 compliance fix*/, |
|
| 1142 | - 'LBL_EDIT_INLINE' => 'Edit Inline' /*for 508 compliance fix*/, |
|
| 1143 | - 'LBL_VIEW_INLINE' => 'View' /*for 508 compliance fix*/, |
|
| 1144 | - 'LBL_BASIC_SEARCH' => 'Search' /*for 508 compliance fix*/, |
|
| 1145 | - 'LBL_PROJECT_MINUS' => 'Remove' /*for 508 compliance fix*/, |
|
| 1146 | - 'LBL_PROJECT_PLUS' => 'Add' /*for 508 compliance fix*/, |
|
| 1147 | - 'LBL_Blank' => ' ' /*for 508 compliance fix*/, |
|
| 1148 | - 'LBL_ICON_COLUMN_1' => 'Column' /*for 508 compliance fix*/, |
|
| 1149 | - 'LBL_ICON_COLUMN_2' => '2 Columns' /*for 508 compliance fix*/, |
|
| 1150 | - 'LBL_ICON_COLUMN_3' => '3 Columns' /*for 508 compliance fix*/, |
|
| 1151 | - 'LBL_ADVANCED_SEARCH' => 'Advanced Search' /*for 508 compliance fix*/, |
|
| 1152 | - 'LBL_ID_FF_ADD' => 'Add' /*for 508 compliance fix*/, |
|
| 1153 | - 'LBL_HIDE_SHOW' => 'Hide/Show' /*for 508 compliance fix*/, |
|
| 1154 | - 'LBL_DELETE_INLINE' => 'Delete' /*for 508 compliance fix*/, |
|
| 1155 | - 'LBL_PLUS_INLINE' => 'Add' /*for 508 compliance fix*/, |
|
| 1156 | - 'LBL_ID_FF_CLEAR' => 'Clear' /*for 508 compliance fix*/, |
|
| 1157 | - 'LBL_ID_FF_VCARD' => 'vCard' /*for 508 compliance fix*/, |
|
| 1158 | - 'LBL_ID_FF_REMOVE' => 'Remove' /*for 508 compliance fix*/, |
|
| 1159 | - 'LBL_ADD' => 'Add' /*for 508 compliance fix*/, |
|
| 1160 | - 'LBL_COMPANY_LOGO' => 'Company logo' /*for 508 compliance fix*/, |
|
| 1161 | - 'LBL_JS_CALENDAR' => 'Calendar' /*for 508 compliance fix*/, |
|
| 1132 | + 'LBL_TOUR_NEXT' => 'Next', |
|
| 1133 | + 'LBL_TOUR_SKIP' => 'Skip', |
|
| 1134 | + 'LBL_TOUR_BACK' => 'Back', |
|
| 1135 | + 'LBL_TOUR_CLOSE' => 'Close', |
|
| 1136 | + 'LBL_TOUR_TAKE_TOUR' => 'Take the tour', |
|
| 1137 | + 'LBL_MY_AREA_LINKS' => 'My area links: ' /*for 508 compliance fix*/, |
|
| 1138 | + 'LBL_GETTINGAIR' => 'Getting Air' /*for 508 compliance fix*/, |
|
| 1139 | + 'LBL_WELCOMEBAR' => 'Welcome' /*for 508 compliance fix*/, |
|
| 1140 | + 'LBL_ADVANCEDSEARCH' => 'Advanced Search' /*for 508 compliance fix*/, |
|
| 1141 | + 'LBL_MOREDETAIL' => 'More Detail' /*for 508 compliance fix*/, |
|
| 1142 | + 'LBL_EDIT_INLINE' => 'Edit Inline' /*for 508 compliance fix*/, |
|
| 1143 | + 'LBL_VIEW_INLINE' => 'View' /*for 508 compliance fix*/, |
|
| 1144 | + 'LBL_BASIC_SEARCH' => 'Search' /*for 508 compliance fix*/, |
|
| 1145 | + 'LBL_PROJECT_MINUS' => 'Remove' /*for 508 compliance fix*/, |
|
| 1146 | + 'LBL_PROJECT_PLUS' => 'Add' /*for 508 compliance fix*/, |
|
| 1147 | + 'LBL_Blank' => ' ' /*for 508 compliance fix*/, |
|
| 1148 | + 'LBL_ICON_COLUMN_1' => 'Column' /*for 508 compliance fix*/, |
|
| 1149 | + 'LBL_ICON_COLUMN_2' => '2 Columns' /*for 508 compliance fix*/, |
|
| 1150 | + 'LBL_ICON_COLUMN_3' => '3 Columns' /*for 508 compliance fix*/, |
|
| 1151 | + 'LBL_ADVANCED_SEARCH' => 'Advanced Search' /*for 508 compliance fix*/, |
|
| 1152 | + 'LBL_ID_FF_ADD' => 'Add' /*for 508 compliance fix*/, |
|
| 1153 | + 'LBL_HIDE_SHOW' => 'Hide/Show' /*for 508 compliance fix*/, |
|
| 1154 | + 'LBL_DELETE_INLINE' => 'Delete' /*for 508 compliance fix*/, |
|
| 1155 | + 'LBL_PLUS_INLINE' => 'Add' /*for 508 compliance fix*/, |
|
| 1156 | + 'LBL_ID_FF_CLEAR' => 'Clear' /*for 508 compliance fix*/, |
|
| 1157 | + 'LBL_ID_FF_VCARD' => 'vCard' /*for 508 compliance fix*/, |
|
| 1158 | + 'LBL_ID_FF_REMOVE' => 'Remove' /*for 508 compliance fix*/, |
|
| 1159 | + 'LBL_ADD' => 'Add' /*for 508 compliance fix*/, |
|
| 1160 | + 'LBL_COMPANY_LOGO' => 'Company logo' /*for 508 compliance fix*/, |
|
| 1161 | + 'LBL_JS_CALENDAR' => 'Calendar' /*for 508 compliance fix*/, |
|
| 1162 | 1162 | 'LBL_ADVANCED' => 'Advanced', |
| 1163 | 1163 | 'LBL_BASIC' => 'Basic', |
| 1164 | 1164 | 'LBL_MODULE_FILTER' => 'Filter By', |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | 'LBL_ROUTING_TO' => 'to', |
| 1229 | 1229 | 'LBL_ROUTING_TO_ADDRESS' => 'to address', |
| 1230 | 1230 | 'LBL_ROUTING_WITH_TEMPLATE' => 'with template', |
| 1231 | - 'NTC_OVERWRITE_ADDRESS_PHONE_CONFIRM' => 'This record currently contains values in the Office Phone and Address fields. To overwrite these values with the following Office Phone and Address of the Account that you selected, click "OK". To keep the current values, click "Cancel".', |
|
| 1232 | - 'LBL_DROP_HERE' => '[Drop Here]', |
|
| 1231 | + 'NTC_OVERWRITE_ADDRESS_PHONE_CONFIRM' => 'This record currently contains values in the Office Phone and Address fields. To overwrite these values with the following Office Phone and Address of the Account that you selected, click "OK". To keep the current values, click "Cancel".', |
|
| 1232 | + 'LBL_DROP_HERE' => '[Drop Here]', |
|
| 1233 | 1233 | 'LBL_EMAIL_ACCOUNTS_EDIT' => 'Edit', |
| 1234 | 1234 | 'LBL_EMAIL_ACCOUNTS_GMAIL_DEFAULTS' => 'Prefill Gmail™ Defaults', |
| 1235 | 1235 | 'LBL_EMAIL_ACCOUNTS_NAME' => 'Name', |
@@ -1247,8 +1247,8 @@ discard block |
||
| 1247 | 1247 | 'LBL_EMAIL_ACCOUNTS_SMTPPASS_REQD' => 'SMTP Password is required', |
| 1248 | 1248 | 'LBL_EMAIL_ACCOUNTS_TITLE' => 'Mail Account Management', |
| 1249 | 1249 | 'LBL_EMAIL_POP3_REMOVE_MESSAGE' => 'Mail Server Protocol of type POP3 will not be supported in the next release. Only IMAP will be supported.', |
| 1250 | - 'LBL_EMAIL_ACCOUNTS_SUBTITLE' => 'Set up Mail Accounts to view incoming emails from your email accounts.', |
|
| 1251 | - 'LBL_EMAIL_ACCOUNTS_OUTBOUND_SUBTITLE' => 'Provide SMTP mail server information to use for outgoing email in Mail Accounts.', |
|
| 1250 | + 'LBL_EMAIL_ACCOUNTS_SUBTITLE' => 'Set up Mail Accounts to view incoming emails from your email accounts.', |
|
| 1251 | + 'LBL_EMAIL_ACCOUNTS_OUTBOUND_SUBTITLE' => 'Provide SMTP mail server information to use for outgoing email in Mail Accounts.', |
|
| 1252 | 1252 | 'LBL_EMAIL_ADD' => 'Add Address', |
| 1253 | 1253 | |
| 1254 | 1254 | 'LBL_EMAIL_ADDRESS_BOOK_ADD' => 'Done', |
@@ -1318,7 +1318,7 @@ discard block |
||
| 1318 | 1318 | 'LBL_EMAIL_MULT_GROUP_FOLDER_ACCOUNTS' => 'Multiple', |
| 1319 | 1319 | 'LBL_EMAIL_MULT_GROUP_FOLDER_ACCOUNTS_EMPTY' => 'Empty', |
| 1320 | 1320 | 'LBL_EMAIL_DATE_SENT_BY_SENDER' => 'Date Sent by Sender', |
| 1321 | - 'LBL_EMAIL_DATE_RECEIVED' => 'Date Received', |
|
| 1321 | + 'LBL_EMAIL_DATE_RECEIVED' => 'Date Received', |
|
| 1322 | 1322 | 'LBL_EMAIL_ASSIGNED_TO_USER' => 'Assigned to User', |
| 1323 | 1323 | 'LBL_EMAIL_DATE_TODAY' => 'Today', |
| 1324 | 1324 | 'LBL_EMAIL_DATE_YESTERDAY' => 'Yesterday', |
@@ -1563,17 +1563,17 @@ discard block |
||
| 1563 | 1563 | 'LBL_EMAIL_SETTINGS_TOGGLE_ADV' => 'Show Advanced', |
| 1564 | 1564 | 'LBL_EMAIL_SETTINGS_USER_FOLDERS' => 'Available User Folders', |
| 1565 | 1565 | 'LBL_EMAIL_ERROR_PREPEND' => 'Error:', |
| 1566 | - 'LBL_EMAIL_INVALID_PERSONAL_OUTBOUND' => 'The outbound mail server selected for the mail account you are using is invalid. Check the settings or select a different mail server for the mail account.', |
|
| 1567 | - 'LBL_EMAIL_INVALID_SYSTEM_OUTBOUND' => 'An outgoing mail server is not configured to send emails. Please configure an outgoing mail server or select an outgoing mail server for the mail account that you are using in Settings >> Mail Account.', |
|
| 1566 | + 'LBL_EMAIL_INVALID_PERSONAL_OUTBOUND' => 'The outbound mail server selected for the mail account you are using is invalid. Check the settings or select a different mail server for the mail account.', |
|
| 1567 | + 'LBL_EMAIL_INVALID_SYSTEM_OUTBOUND' => 'An outgoing mail server is not configured to send emails. Please configure an outgoing mail server or select an outgoing mail server for the mail account that you are using in Settings >> Mail Account.', |
|
| 1568 | 1568 | 'LBL_EMAIL_SHOW_READ' => 'Show All', |
| 1569 | 1569 | 'LBL_EMAIL_SHOW_UNREAD_ONLY' => 'Show Unread Only', |
| 1570 | 1570 | 'LBL_EMAIL_SIGNATURES' => 'Signatures', |
| 1571 | 1571 | 'LBL_EMAIL_SIGNATURE_CREATE' => 'Create Signature', |
| 1572 | 1572 | 'LBL_EMAIL_SIGNATURE_NAME' => 'Signature Name', |
| 1573 | 1573 | 'LBL_EMAIL_SIGNATURE_TEXT' => 'Signature Body', |
| 1574 | - 'LBL_SMTPTYPE_GMAIL' => 'Gmail', |
|
| 1575 | - 'LBL_SMTPTYPE_YAHOO' => 'Yahoo! Mail', |
|
| 1576 | - 'LBL_SMTPTYPE_EXCHANGE' => 'Microsoft Exchange', |
|
| 1574 | + 'LBL_SMTPTYPE_GMAIL' => 'Gmail', |
|
| 1575 | + 'LBL_SMTPTYPE_YAHOO' => 'Yahoo! Mail', |
|
| 1576 | + 'LBL_SMTPTYPE_EXCHANGE' => 'Microsoft Exchange', |
|
| 1577 | 1577 | 'LBL_SMTPTYPE_OTHER' => 'Other', |
| 1578 | 1578 | 'LBL_EMAIL_SPACER_MAIL_SERVER' => '[ Remote Folders ]', |
| 1579 | 1579 | 'LBL_EMAIL_SPACER_LOCAL_FOLDER' => '[ SuiteCRM Folders ]', |
@@ -1880,8 +1880,8 @@ discard block |
||
| 1880 | 1880 | 'LBL_PRIMARY_ADDRESS_STREET' => 'Primary Address Street:', |
| 1881 | 1881 | 'LBL_PRIMARY_ADDRESS' => 'Primary Address:', |
| 1882 | 1882 | |
| 1883 | - 'LBL_BILLING_STREET'=> 'Street:', |
|
| 1884 | - 'LBL_SHIPPING_STREET'=> 'Street:', |
|
| 1883 | + 'LBL_BILLING_STREET'=> 'Street:', |
|
| 1884 | + 'LBL_SHIPPING_STREET'=> 'Street:', |
|
| 1885 | 1885 | |
| 1886 | 1886 | 'LBL_PROSPECTS'=>'Prospects', |
| 1887 | 1887 | 'LBL_PRODUCT_BUNDLES'=>'Product Bundles', |
@@ -2151,16 +2151,16 @@ discard block |
||
| 2151 | 2151 | 'MSG_JS_ALERT_MTG_REMINDER_STATUS' => 'Status: ', |
| 2152 | 2152 | 'MSG_JS_ALERT_MTG_REMINDER_RELATED_TO' => 'Related To: ', |
| 2153 | 2153 | 'MSG_JS_ALERT_MTG_REMINDER_CALL_MSG' => "\nClick OK to view this call or click Cancel to dismiss this message.", |
| 2154 | - 'MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG' => "\nClick OK to view this meeting or click Cancel to dismiss this message.", |
|
| 2155 | - 'MSG_JS_ALERT_MTG_REMINDER_NO_EVENT_NAME' => 'Event', |
|
| 2156 | - 'MSG_JS_ALERT_MTG_REMINDER_NO_DESCRIPTION' => 'Event isn\'t set.', |
|
| 2157 | - 'MSG_JS_ALERT_MTG_REMINDER_NO_LOCATION' => 'Location isn\'t set.', |
|
| 2158 | - 'MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE' => 'Start date isn\'t defined.', |
|
| 2159 | - 'MSG_LIST_VIEW_NO_RESULTS_BASIC' => "No results found.", |
|
| 2160 | - 'MSG_LIST_VIEW_NO_RESULTS' => "No results found for <item1>", |
|
| 2161 | - 'MSG_LIST_VIEW_NO_RESULTS_SUBMSG' => "Create <item1> as a new <item2>", |
|
| 2162 | - 'MSG_EMPTY_LIST_VIEW_NO_RESULTS' => "You currently have no records saved. <item2> or <item3> one now.", |
|
| 2163 | - 'MSG_EMPTY_LIST_VIEW_NO_RESULTS_SUBMSG' => "<item4> to learn more about the <item1> module. In order to access more information, use the user menu drop down located on the main navigation bar to access Help.", |
|
| 2154 | + 'MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG' => "\nClick OK to view this meeting or click Cancel to dismiss this message.", |
|
| 2155 | + 'MSG_JS_ALERT_MTG_REMINDER_NO_EVENT_NAME' => 'Event', |
|
| 2156 | + 'MSG_JS_ALERT_MTG_REMINDER_NO_DESCRIPTION' => 'Event isn\'t set.', |
|
| 2157 | + 'MSG_JS_ALERT_MTG_REMINDER_NO_LOCATION' => 'Location isn\'t set.', |
|
| 2158 | + 'MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE' => 'Start date isn\'t defined.', |
|
| 2159 | + 'MSG_LIST_VIEW_NO_RESULTS_BASIC' => "No results found.", |
|
| 2160 | + 'MSG_LIST_VIEW_NO_RESULTS' => "No results found for <item1>", |
|
| 2161 | + 'MSG_LIST_VIEW_NO_RESULTS_SUBMSG' => "Create <item1> as a new <item2>", |
|
| 2162 | + 'MSG_EMPTY_LIST_VIEW_NO_RESULTS' => "You currently have no records saved. <item2> or <item3> one now.", |
|
| 2163 | + 'MSG_EMPTY_LIST_VIEW_NO_RESULTS_SUBMSG' => "<item4> to learn more about the <item1> module. In order to access more information, use the user menu drop down located on the main navigation bar to access Help.", |
|
| 2164 | 2164 | |
| 2165 | 2165 | 'LBL_CLICK_HERE' => "Click here", |
| 2166 | 2166 | // contextMenu strings |
@@ -2187,13 +2187,13 @@ discard block |
||
| 2187 | 2187 | 'LBL_TRAINING' => 'Support', |
| 2188 | 2188 | 'ERR_DATABASE_CONN_DROPPED'=>'Error executing a query. Possibly, your database dropped the connection. Please refresh this page, you may need to restart you web server.', |
| 2189 | 2189 | 'ERR_MSSQL_DB_CONTEXT' =>'Changed database context to', |
| 2190 | - 'ERR_MSSQL_WARNING' =>'Warning:', |
|
| 2190 | + 'ERR_MSSQL_WARNING' =>'Warning:', |
|
| 2191 | 2191 | |
| 2192 | 2192 | //Meta-Data framework |
| 2193 | 2193 | 'ERR_MISSING_VARDEF_NAME' => 'Warning: field [[field]] does not have a mapped entry in [moduleDir] vardefs.php file', |
| 2194 | 2194 | 'ERR_CANNOT_CREATE_METADATA_FILE' => 'Error: File [[file]] is missing. Unable to create because no corresponding HTML file was found.', |
| 2195 | - 'ERR_CANNOT_FIND_MODULE' => 'Error: Module [module] does not exist.', |
|
| 2196 | - 'LBL_ALT_ADDRESS' => 'Other Address:', |
|
| 2195 | + 'ERR_CANNOT_FIND_MODULE' => 'Error: Module [module] does not exist.', |
|
| 2196 | + 'LBL_ALT_ADDRESS' => 'Other Address:', |
|
| 2197 | 2197 | 'ERR_SMARTY_UNEQUAL_RELATED_FIELD_PARAMETERS' => 'Error: There are an unequal number of arguments for the \'key\' and \'copy\' elements in the displayParams array.', |
| 2198 | 2198 | 'ERR_SMARTY_MISSING_DISPLAY_PARAMS' => 'Missing index in displayParams Array for: ', |
| 2199 | 2199 | |
@@ -2284,10 +2284,10 @@ discard block |
||
| 2284 | 2284 | |
| 2285 | 2285 | //jc:#12287 - For javascript validation messages |
| 2286 | 2286 | 'MSG_IS_NOT_BEFORE' => 'is not before', |
| 2287 | - 'MSG_IS_MORE_THAN' => 'is more than', |
|
| 2288 | - 'MSG_IS_LESS_THAN' => 'is less than', |
|
| 2289 | - 'MSG_SHOULD_BE' => 'should be', |
|
| 2290 | - 'MSG_OR_GREATER' => 'or greater', |
|
| 2287 | + 'MSG_IS_MORE_THAN' => 'is more than', |
|
| 2288 | + 'MSG_IS_LESS_THAN' => 'is less than', |
|
| 2289 | + 'MSG_SHOULD_BE' => 'should be', |
|
| 2290 | + 'MSG_OR_GREATER' => 'or greater', |
|
| 2291 | 2291 | |
| 2292 | 2292 | 'LBL_PORTAL_WELCOME_TITLE' => 'Welcome to SuiteCRM Portal', |
| 2293 | 2293 | 'LBL_PORTAL_WELCOME_INFO' => 'SuiteCRM Portal is a framework which provides real-time view of cases, bugs & newsletters etc to customers. This is an external facing interface to SuiteCRM that can be deployed within any website.', |
@@ -2319,13 +2319,13 @@ discard block |
||
| 2319 | 2319 | 'LBL_OPERATOR_NOT_IN_TEXT' => 'is not one of the following:', |
| 2320 | 2320 | |
| 2321 | 2321 | |
| 2322 | - //Connector |
|
| 2322 | + //Connector |
|
| 2323 | 2323 | 'ERR_CONNECTOR_FILL_BEANS_SIZE_MISMATCH' => 'Error: The Array count of the bean parameter does not match the Array count of the results.', |
| 2324 | - 'ERR_MISSING_MAPPING_ENTRY_FORM_MODULE' => 'Error: Missing mapping entry for module.', |
|
| 2325 | - 'ERROR_UNABLE_TO_RETRIEVE_DATA' => 'Error: Unable to retrieve data for {0} Connector. The service may currently be inaccessible or the configuration settings may be invalid. Connector error message: ({1}).', |
|
| 2326 | - 'LBL_MERGE_CONNECTORS' => 'Get Data', |
|
| 2327 | - 'LBL_MERGE_CONNECTORS_BUTTON_KEY' => '[D]', |
|
| 2328 | - 'LBL_REMOVE_MODULE_ENTRY' => 'Are you sure you want to disable connector integration for this module?', |
|
| 2324 | + 'ERR_MISSING_MAPPING_ENTRY_FORM_MODULE' => 'Error: Missing mapping entry for module.', |
|
| 2325 | + 'ERROR_UNABLE_TO_RETRIEVE_DATA' => 'Error: Unable to retrieve data for {0} Connector. The service may currently be inaccessible or the configuration settings may be invalid. Connector error message: ({1}).', |
|
| 2326 | + 'LBL_MERGE_CONNECTORS' => 'Get Data', |
|
| 2327 | + 'LBL_MERGE_CONNECTORS_BUTTON_KEY' => '[D]', |
|
| 2328 | + 'LBL_REMOVE_MODULE_ENTRY' => 'Are you sure you want to disable connector integration for this module?', |
|
| 2329 | 2329 | |
| 2330 | 2330 | // fastcgi checks |
| 2331 | 2331 | 'LBL_FASTCGI_LOGGING' => 'For optimal experience using IIS/FastCGI sapi, set fastcgi.logging to 0 in your php.ini file.', |
@@ -2336,28 +2336,28 @@ discard block |
||
| 2336 | 2336 | |
| 2337 | 2337 | //martin #25548 |
| 2338 | 2338 | 'LBL_NO_FLASH_PLAYER' => 'You either have Abobe Flash turned off or are using an older version of the Adobe Flash Player. To get the latest version of the Flash Player, <a href="http://www.adobe.com/go/getflashplayer/">click here</a>.', |
| 2339 | - //Collection Field |
|
| 2340 | - 'LBL_COLLECTION_NAME' => 'Name', |
|
| 2341 | - 'LBL_COLLECTION_PRIMARY' => 'Primary', |
|
| 2342 | - 'ERROR_MISSING_COLLECTION_SELECTION' => 'Empty required field', |
|
| 2339 | + //Collection Field |
|
| 2340 | + 'LBL_COLLECTION_NAME' => 'Name', |
|
| 2341 | + 'LBL_COLLECTION_PRIMARY' => 'Primary', |
|
| 2342 | + 'ERROR_MISSING_COLLECTION_SELECTION' => 'Empty required field', |
|
| 2343 | 2343 | 'LBL_COLLECTION_EXACT' => 'Exact', |
| 2344 | 2344 | |
| 2345 | 2345 | //MB -Fixed Bug #32812 -Max |
| 2346 | 2346 | 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
| 2347 | 2347 | 'LBL_DESCRIPTION' => 'Description', |
| 2348 | 2348 | |
| 2349 | - 'LBL_YESTERDAY'=> 'yesterday', |
|
| 2350 | - 'LBL_TODAY'=>'today', |
|
| 2351 | - 'LBL_TOMORROW'=>'tomorrow', |
|
| 2352 | - 'LBL_NEXT_WEEK'=> 'next week', |
|
| 2353 | - 'LBL_NEXT_MONDAY'=>'next monday', |
|
| 2354 | - 'LBL_NEXT_FRIDAY'=>'next friday', |
|
| 2355 | - 'LBL_TWO_WEEKS'=> 'two weeks', |
|
| 2356 | - 'LBL_NEXT_MONTH'=> 'next month', |
|
| 2357 | - 'LBL_FIRST_DAY_OF_NEXT_MONTH'=> 'first day of next month', |
|
| 2358 | - 'LBL_THREE_MONTHS'=> 'three months', |
|
| 2359 | - 'LBL_SIXMONTHS'=> 'six months', |
|
| 2360 | - 'LBL_NEXT_YEAR'=> 'next year', |
|
| 2349 | + 'LBL_YESTERDAY'=> 'yesterday', |
|
| 2350 | + 'LBL_TODAY'=>'today', |
|
| 2351 | + 'LBL_TOMORROW'=>'tomorrow', |
|
| 2352 | + 'LBL_NEXT_WEEK'=> 'next week', |
|
| 2353 | + 'LBL_NEXT_MONDAY'=>'next monday', |
|
| 2354 | + 'LBL_NEXT_FRIDAY'=>'next friday', |
|
| 2355 | + 'LBL_TWO_WEEKS'=> 'two weeks', |
|
| 2356 | + 'LBL_NEXT_MONTH'=> 'next month', |
|
| 2357 | + 'LBL_FIRST_DAY_OF_NEXT_MONTH'=> 'first day of next month', |
|
| 2358 | + 'LBL_THREE_MONTHS'=> 'three months', |
|
| 2359 | + 'LBL_SIXMONTHS'=> 'six months', |
|
| 2360 | + 'LBL_NEXT_YEAR'=> 'next year', |
|
| 2361 | 2361 | 'LBL_FILTERED' => 'Filtered', |
| 2362 | 2362 | |
| 2363 | 2363 | //Datetimecombo fields |
@@ -2384,7 +2384,7 @@ discard block |
||
| 2384 | 2384 | |
| 2385 | 2385 | //File write error label |
| 2386 | 2386 | 'ERR_FILE_WRITE' => 'Error: Could not write file {0}. Please check system and web server permissions.', |
| 2387 | - 'ERR_FILE_NOT_FOUND' => 'Error: Could not load file {0}. Please check system and web server permissions.', |
|
| 2387 | + 'ERR_FILE_NOT_FOUND' => 'Error: Could not load file {0}. Please check system and web server permissions.', |
|
| 2388 | 2388 | |
| 2389 | 2389 | 'LBL_AND' => 'And', |
| 2390 | 2390 | 'LBL_BEFORE' => 'Before', |
@@ -2456,7 +2456,7 @@ discard block |
||
| 2456 | 2456 | 'LBL_ALT_MOVE_COLUMN_UP' =>'Move selected entry up in the displayed list order', |
| 2457 | 2457 | 'LBL_ALT_MOVE_COLUMN_DOWN' => 'Move selected entry down in the displayed list order', |
| 2458 | 2458 | 'LBL_ALT_INFO' => 'Information', |
| 2459 | - 'MSG_DUPLICATE' => 'The {0} record you are about to create might be a duplicate of an {0} record that already exists. {1} records containing similar names are listed below.<br>Click Create {1} to continue creating this new {0}, or select an existing {0} listed below.', |
|
| 2459 | + 'MSG_DUPLICATE' => 'The {0} record you are about to create might be a duplicate of an {0} record that already exists. {1} records containing similar names are listed below.<br>Click Create {1} to continue creating this new {0}, or select an existing {0} listed below.', |
|
| 2460 | 2460 | 'MSG_SHOW_DUPLICATES' => 'The {0} record you are about to create might be a duplicate of a {0} record that already exists. {1} records containing similar names are listed below. Click Save to continue creating this new {0}, or click Cancel to return to the module without creating the {0}.', |
| 2461 | 2461 | 'LBL_EMAIL_TITLE' => 'email address', |
| 2462 | 2462 | 'LBL_EMAIL_OPT_TITLE' => 'opted out email address', |
@@ -2532,9 +2532,9 @@ discard block |
||
| 2532 | 2532 | 'Expired' => 'Expired', |
| 2533 | 2533 | 'In Review' => 'In Review', |
| 2534 | 2534 | 'Published' => 'Published', |
| 2535 | - ); |
|
| 2535 | + ); |
|
| 2536 | 2536 | |
| 2537 | - $app_list_strings['kbadmin_actions_dom'] = |
|
| 2537 | + $app_list_strings['kbadmin_actions_dom'] = |
|
| 2538 | 2538 | array ( |
| 2539 | 2539 | '' => '--Admin Actions--', |
| 2540 | 2540 | 'Create New Tag' => 'Create New Tag', |
@@ -2543,10 +2543,10 @@ discard block |
||
| 2543 | 2543 | 'Move Selected Articles'=>'Move Selected Articles', |
| 2544 | 2544 | 'Apply Tags On Articles'=>'Apply Tags To Articles', |
| 2545 | 2545 | 'Delete Selected Articles'=>'Delete Selected Articles', |
| 2546 | - ); |
|
| 2546 | + ); |
|
| 2547 | 2547 | |
| 2548 | 2548 | |
| 2549 | - $app_list_strings['kbdocument_attachment_option_dom'] = |
|
| 2549 | + $app_list_strings['kbdocument_attachment_option_dom'] = |
|
| 2550 | 2550 | array( |
| 2551 | 2551 | ''=>'', |
| 2552 | 2552 | 'some' => 'Has Attachments', |
@@ -2555,10 +2555,10 @@ discard block |
||
| 2555 | 2555 | 'name' => 'Specify Name', |
| 2556 | 2556 | ); |
| 2557 | 2557 | |
| 2558 | - $app_list_strings['moduleList']['KBDocuments'] = 'Knowledge Base'; |
|
| 2559 | - $app_strings['LBL_CREATE_KB_DOCUMENT'] = 'Create Article'; |
|
| 2560 | - $app_list_strings['kbdocument_viewing_frequency_dom'] = |
|
| 2561 | - array( |
|
| 2558 | + $app_list_strings['moduleList']['KBDocuments'] = 'Knowledge Base'; |
|
| 2559 | + $app_strings['LBL_CREATE_KB_DOCUMENT'] = 'Create Article'; |
|
| 2560 | + $app_list_strings['kbdocument_viewing_frequency_dom'] = |
|
| 2561 | + array( |
|
| 2562 | 2562 | ''=>'', |
| 2563 | 2563 | 'Top_5' => 'Top 5', |
| 2564 | 2564 | 'Top_10' => 'Top 10', |
@@ -2566,9 +2566,9 @@ discard block |
||
| 2566 | 2566 | 'Bot_5' => 'Bottom 5', |
| 2567 | 2567 | 'Bot_10' => 'Bottom 10', |
| 2568 | 2568 | 'Bot_20' => 'Bottom 20', |
| 2569 | - ); |
|
| 2569 | + ); |
|
| 2570 | 2570 | |
| 2571 | - $app_list_strings['kbdocument_canned_search'] = |
|
| 2571 | + $app_list_strings['kbdocument_canned_search'] = |
|
| 2572 | 2572 | array( |
| 2573 | 2573 | 'all'=>'All', |
| 2574 | 2574 | 'added' => 'Added Last 30 days', |
@@ -2835,7 +2835,7 @@ discard block |
||
| 2835 | 2835 | 'ZIMBABWE' => 'ZIMBABWE', |
| 2836 | 2836 | ); |
| 2837 | 2837 | |
| 2838 | - $app_list_strings['charset_dom'] = array( |
|
| 2838 | + $app_list_strings['charset_dom'] = array( |
|
| 2839 | 2839 | 'BIG-5' => 'BIG-5 (Taiwan and Hong Kong)', |
| 2840 | 2840 | /*'CP866' => 'CP866', // ms-dos Cyrillic */ |
| 2841 | 2841 | /*'CP949' => 'CP949 (Microsoft Korean)', */ |
@@ -2864,389 +2864,389 @@ discard block |
||
| 2864 | 2864 | 'KOI8-U' => 'KOI8-U (Cyrillic Ukranian)', |
| 2865 | 2865 | 'SJIS' => 'SJIS (MS Japanese)', |
| 2866 | 2866 | 'UTF-8' => 'UTF-8', |
| 2867 | - ); |
|
| 2868 | - |
|
| 2869 | - $app_list_strings['timezone_dom'] = array( |
|
| 2870 | - |
|
| 2871 | - 'Africa/Algiers' => 'Africa/Algiers', |
|
| 2872 | - 'Africa/Luanda' => 'Africa/Luanda', |
|
| 2873 | - 'Africa/Porto-Novo' => 'Africa/Porto-Novo', |
|
| 2874 | - 'Africa/Gaborone' => 'Africa/Gaborone', |
|
| 2875 | - 'Africa/Ouagadougou' => 'Africa/Ouagadougou', |
|
| 2876 | - 'Africa/Bujumbura' => 'Africa/Bujumbura', |
|
| 2877 | - 'Africa/Douala' => 'Africa/Douala', |
|
| 2878 | - 'Atlantic/Cape_Verde' => 'Atlantic/Cape Verde', |
|
| 2879 | - 'Africa/Bangui' => 'Africa/Bangui', |
|
| 2880 | - 'Africa/Ndjamena' => 'Africa/Ndjamena', |
|
| 2881 | - 'Indian/Comoro' => 'Indian/Comoro', |
|
| 2882 | - 'Africa/Kinshasa' => 'Africa/Kinshasa', |
|
| 2883 | - 'Africa/Lubumbashi' => 'Africa/Lubumbashi', |
|
| 2884 | - 'Africa/Brazzaville' => 'Africa/Brazzaville', |
|
| 2885 | - 'Africa/Abidjan' => 'Africa/Abidjan', |
|
| 2886 | - 'Africa/Djibouti' => 'Africa/Djibouti', |
|
| 2887 | - 'Africa/Cairo' => 'Africa/Cairo', |
|
| 2888 | - 'Africa/Malabo' => 'Africa/Malabo', |
|
| 2889 | - 'Africa/Asmera' => 'Africa/Asmera', |
|
| 2890 | - 'Africa/Addis_Ababa' => 'Africa/Addis Ababa', |
|
| 2891 | - 'Africa/Libreville' => 'Africa/Libreville', |
|
| 2892 | - 'Africa/Banjul' => 'Africa/Banjul', |
|
| 2893 | - 'Africa/Accra' => 'Africa/Accra', |
|
| 2894 | - 'Africa/Conakry' => 'Africa/Conakry', |
|
| 2895 | - 'Africa/Bissau' => 'Africa/Bissau', |
|
| 2896 | - 'Africa/Nairobi' => 'Africa/Nairobi', |
|
| 2897 | - 'Africa/Maseru' => 'Africa/Maseru', |
|
| 2898 | - 'Africa/Monrovia' => 'Africa/Monrovia', |
|
| 2899 | - 'Africa/Tripoli' => 'Africa/Tripoli', |
|
| 2900 | - 'Indian/Antananarivo' => 'Indian/Antananarivo', |
|
| 2901 | - 'Africa/Blantyre' => 'Africa/Blantyre', |
|
| 2902 | - 'Africa/Bamako' => 'Africa/Bamako', |
|
| 2903 | - 'Africa/Nouakchott' => 'Africa/Nouakchott', |
|
| 2904 | - 'Indian/Mauritius' => 'Indian/Mauritius', |
|
| 2905 | - 'Indian/Mayotte' => 'Indian/Mayotte', |
|
| 2906 | - 'Africa/Casablanca' => 'Africa/Casablanca', |
|
| 2907 | - 'Africa/El_Aaiun' => 'Africa/El Aaiun', |
|
| 2908 | - 'Africa/Maputo' => 'Africa/Maputo', |
|
| 2909 | - 'Africa/Windhoek' => 'Africa/Windhoek', |
|
| 2910 | - 'Africa/Niamey' => 'Africa/Niamey', |
|
| 2911 | - 'Africa/Lagos' => 'Africa/Lagos', |
|
| 2912 | - 'Indian/Reunion' => 'Indian/Reunion', |
|
| 2913 | - 'Africa/Kigali' => 'Africa/Kigali', |
|
| 2914 | - 'Atlantic/St_Helena' => 'Atlantic/St. Helena', |
|
| 2915 | - 'Africa/Sao_Tome' => 'Africa/Sao Tome', |
|
| 2916 | - 'Africa/Dakar' => 'Africa/Dakar', |
|
| 2917 | - 'Indian/Mahe' => 'Indian/Mahe', |
|
| 2918 | - 'Africa/Freetown' => 'Africa/Freetown', |
|
| 2919 | - 'Africa/Mogadishu' => 'Africa/Mogadishu', |
|
| 2920 | - 'Africa/Johannesburg' => 'Africa/Johannesburg', |
|
| 2921 | - 'Africa/Khartoum' => 'Africa/Khartoum', |
|
| 2922 | - 'Africa/Mbabane' => 'Africa/Mbabane', |
|
| 2923 | - 'Africa/Dar_es_Salaam' => 'Africa/Dar es Salaam', |
|
| 2924 | - 'Africa/Lome' => 'Africa/Lome', |
|
| 2925 | - 'Africa/Tunis' => 'Africa/Tunis', |
|
| 2926 | - 'Africa/Kampala' => 'Africa/Kampala', |
|
| 2927 | - 'Africa/Lusaka' => 'Africa/Lusaka', |
|
| 2928 | - 'Africa/Harare' => 'Africa/Harare', |
|
| 2929 | - 'Antarctica/Casey' => 'Antarctica/Casey', |
|
| 2930 | - 'Antarctica/Davis' => 'Antarctica/Davis', |
|
| 2931 | - 'Antarctica/Mawson' => 'Antarctica/Mawson', |
|
| 2932 | - 'Indian/Kerguelen' => 'Indian/Kerguelen', |
|
| 2933 | - 'Antarctica/DumontDUrville' => 'Antarctica/DumontDUrville', |
|
| 2934 | - 'Antarctica/Syowa' => 'Antarctica/Syowa', |
|
| 2935 | - 'Antarctica/Vostok' => 'Antarctica/Vostok', |
|
| 2936 | - 'Antarctica/Rothera' => 'Antarctica/Rothera', |
|
| 2937 | - 'Antarctica/Palmer' => 'Antarctica/Palmer', |
|
| 2938 | - 'Antarctica/McMurdo' => 'Antarctica/McMurdo', |
|
| 2939 | - 'Asia/Kabul' => 'Asia/Kabul', |
|
| 2940 | - 'Asia/Yerevan' => 'Asia/Yerevan', |
|
| 2941 | - 'Asia/Baku' => 'Asia/Baku', |
|
| 2942 | - 'Asia/Bahrain' => 'Asia/Bahrain', |
|
| 2943 | - 'Asia/Dhaka' => 'Asia/Dhaka', |
|
| 2944 | - 'Asia/Thimphu' => 'Asia/Thimphu', |
|
| 2945 | - 'Indian/Chagos' => 'Indian/Chagos', |
|
| 2946 | - 'Asia/Brunei' => 'Asia/Brunei', |
|
| 2947 | - 'Asia/Rangoon' => 'Asia/Rangoon', |
|
| 2948 | - 'Asia/Phnom_Penh' => 'Asia/Phnom Penh', |
|
| 2949 | - 'Asia/Beijing' => 'Asia/Beijing', |
|
| 2950 | - 'Asia/Harbin' => 'Asia/Harbin', |
|
| 2951 | - 'Asia/Shanghai' => 'Asia/Shanghai', |
|
| 2952 | - 'Asia/Chongqing' => 'Asia/Chongqing', |
|
| 2953 | - 'Asia/Urumqi' => 'Asia/Urumqi', |
|
| 2954 | - 'Asia/Kashgar' => 'Asia/Kashgar', |
|
| 2955 | - 'Asia/Hong_Kong' => 'Asia/Hong Kong', |
|
| 2956 | - 'Asia/Taipei' => 'Asia/Taipei', |
|
| 2957 | - 'Asia/Macau' => 'Asia/Macau', |
|
| 2958 | - 'Asia/Nicosia' => 'Asia/Nicosia', |
|
| 2959 | - 'Asia/Tbilisi' => 'Asia/Tbilisi', |
|
| 2960 | - 'Asia/Dili' => 'Asia/Dili', |
|
| 2961 | - 'Asia/Calcutta' => 'Asia/Calcutta', |
|
| 2962 | - 'Asia/Jakarta' => 'Asia/Jakarta', |
|
| 2963 | - 'Asia/Pontianak' => 'Asia/Pontianak', |
|
| 2964 | - 'Asia/Makassar' => 'Asia/Makassar', |
|
| 2965 | - 'Asia/Jayapura' => 'Asia/Jayapura', |
|
| 2966 | - 'Asia/Tehran' => 'Asia/Tehran', |
|
| 2967 | - 'Asia/Baghdad' => 'Asia/Baghdad', |
|
| 2968 | - 'Asia/Jerusalem' => 'Asia/Jerusalem', |
|
| 2969 | - 'Asia/Tokyo' => 'Asia/Tokyo', |
|
| 2970 | - 'Asia/Amman' => 'Asia/Amman', |
|
| 2971 | - 'Asia/Almaty' => 'Asia/Almaty', |
|
| 2972 | - 'Asia/Qyzylorda' => 'Asia/Qyzylorda', |
|
| 2973 | - 'Asia/Aqtobe' => 'Asia/Aqtobe', |
|
| 2974 | - 'Asia/Aqtau' => 'Asia/Aqtau', |
|
| 2975 | - 'Asia/Oral' => 'Asia/Oral', |
|
| 2976 | - 'Asia/Bishkek' => 'Asia/Bishkek', |
|
| 2977 | - 'Asia/Seoul' => 'Asia/Seoul', |
|
| 2978 | - 'Asia/Pyongyang' => 'Asia/Pyongyang', |
|
| 2979 | - 'Asia/Kuwait' => 'Asia/Kuwait', |
|
| 2980 | - 'Asia/Vientiane' => 'Asia/Vientiane', |
|
| 2981 | - 'Asia/Beirut' => 'Asia/Beirut', |
|
| 2982 | - 'Asia/Kuala_Lumpur' => 'Asia/Kuala Lumpur', |
|
| 2983 | - 'Asia/Kuching' => 'Asia/Kuching', |
|
| 2984 | - 'Indian/Maldives' => 'Indian/Maldives', |
|
| 2985 | - 'Asia/Hovd' => 'Asia/Hovd', |
|
| 2986 | - 'Asia/Ulaanbaatar' => 'Asia/Ulaanbaatar', |
|
| 2987 | - 'Asia/Choibalsan' => 'Asia/Choibalsan', |
|
| 2988 | - 'Asia/Katmandu' => 'Asia/Katmandu', |
|
| 2989 | - 'Asia/Muscat' => 'Asia/Muscat', |
|
| 2990 | - 'Asia/Karachi' => 'Asia/Karachi', |
|
| 2991 | - 'Asia/Gaza' => 'Asia/Gaza', |
|
| 2992 | - 'Asia/Manila' => 'Asia/Manila', |
|
| 2993 | - 'Asia/Qatar' => 'Asia/Qatar', |
|
| 2994 | - 'Asia/Riyadh' => 'Asia/Riyadh', |
|
| 2995 | - 'Asia/Singapore' => 'Asia/Singapore', |
|
| 2996 | - 'Asia/Colombo' => 'Asia/Colombo', |
|
| 2997 | - 'Asia/Damascus' => 'Asia/Damascus', |
|
| 2998 | - 'Asia/Dushanbe' => 'Asia/Dushanbe', |
|
| 2999 | - 'Asia/Bangkok' => 'Asia/Bangkok', |
|
| 3000 | - 'Asia/Ashgabat' => 'Asia/Ashgabat', |
|
| 3001 | - 'Asia/Dubai' => 'Asia/Dubai', |
|
| 3002 | - 'Asia/Samarkand' => 'Asia/Samarkand', |
|
| 3003 | - 'Asia/Tashkent' => 'Asia/Tashkent', |
|
| 3004 | - 'Asia/Saigon' => 'Asia/Saigon', |
|
| 3005 | - 'Asia/Aden' => 'Asia/Aden', |
|
| 3006 | - 'Australia/Darwin' => 'Australia/Darwin', |
|
| 3007 | - 'Australia/Perth' => 'Australia/Perth', |
|
| 3008 | - 'Australia/Brisbane' => 'Australia/Brisbane', |
|
| 3009 | - 'Australia/Lindeman' => 'Australia/Lindeman', |
|
| 3010 | - 'Australia/Adelaide' => 'Australia/Adelaide', |
|
| 3011 | - 'Australia/Hobart' => 'Australia/Hobart', |
|
| 3012 | - 'Australia/Currie' => 'Australia/Currie', |
|
| 3013 | - 'Australia/Melbourne' => 'Australia/Melbourne', |
|
| 3014 | - 'Australia/Sydney' => 'Australia/Sydney', |
|
| 3015 | - 'Australia/Broken_Hill' => 'Australia/Broken Hill', |
|
| 3016 | - 'Indian/Christmas' => 'Indian/Christmas', |
|
| 3017 | - 'Pacific/Rarotonga' => 'Pacific/Rarotonga', |
|
| 3018 | - 'Indian/Cocos' => 'Indian/Cocos', |
|
| 3019 | - 'Pacific/Fiji' => 'Pacific/Fiji', |
|
| 3020 | - 'Pacific/Gambier' => 'Pacific/Gambier', |
|
| 3021 | - 'Pacific/Marquesas' => 'Pacific/Marquesas', |
|
| 3022 | - 'Pacific/Tahiti' => 'Pacific/Tahiti', |
|
| 3023 | - 'Pacific/Guam' => 'Pacific/Guam', |
|
| 3024 | - 'Pacific/Tarawa' => 'Pacific/Tarawa', |
|
| 3025 | - 'Pacific/Enderbury' => 'Pacific/Enderbury', |
|
| 3026 | - 'Pacific/Kiritimati' => 'Pacific/Kiritimati', |
|
| 3027 | - 'Pacific/Saipan' => 'Pacific/Saipan', |
|
| 3028 | - 'Pacific/Majuro' => 'Pacific/Majuro', |
|
| 3029 | - 'Pacific/Kwajalein' => 'Pacific/Kwajalein', |
|
| 3030 | - 'Pacific/Truk' => 'Pacific/Truk', |
|
| 3031 | - 'Pacific/Pohnpei' => 'Pacific/Pohnpei', |
|
| 3032 | - 'Pacific/Kosrae' => 'Pacific/Kosrae', |
|
| 3033 | - 'Pacific/Nauru' => 'Pacific/Nauru', |
|
| 3034 | - 'Pacific/Noumea' => 'Pacific/Noumea', |
|
| 3035 | - 'Pacific/Auckland' => 'Pacific/Auckland', |
|
| 3036 | - 'Pacific/Chatham' => 'Pacific/Chatham', |
|
| 3037 | - 'Pacific/Niue' => 'Pacific/Niue', |
|
| 3038 | - 'Pacific/Norfolk' => 'Pacific/Norfolk', |
|
| 3039 | - 'Pacific/Palau' => 'Pacific/Palau', |
|
| 3040 | - 'Pacific/Port_Moresby' => 'Pacific/Port Moresby', |
|
| 3041 | - 'Pacific/Pitcairn' => 'Pacific/Pitcairn', |
|
| 3042 | - 'Pacific/Pago_Pago' => 'Pacific/Pago Pago', |
|
| 3043 | - 'Pacific/Apia' => 'Pacific/Apia', |
|
| 3044 | - 'Pacific/Guadalcanal' => 'Pacific/Guadalcanal', |
|
| 3045 | - 'Pacific/Fakaofo' => 'Pacific/Fakaofo', |
|
| 3046 | - 'Pacific/Tongatapu' => 'Pacific/Tongatapu', |
|
| 3047 | - 'Pacific/Funafuti' => 'Pacific/Funafuti', |
|
| 3048 | - 'Pacific/Johnston' => 'Pacific/Johnston', |
|
| 3049 | - 'Pacific/Midway' => 'Pacific/Midway', |
|
| 3050 | - 'Pacific/Wake' => 'Pacific/Wake', |
|
| 3051 | - 'Pacific/Efate' => 'Pacific/Efate', |
|
| 3052 | - 'Pacific/Wallis' => 'Pacific/Wallis', |
|
| 3053 | - 'Europe/London' => 'Europe/London', |
|
| 3054 | - 'Europe/Dublin' => 'Europe/Dublin', |
|
| 3055 | - 'WET' => 'WET', |
|
| 3056 | - 'CET' => 'CET', |
|
| 3057 | - 'MET' => 'MET', |
|
| 3058 | - 'EET' => 'EET', |
|
| 3059 | - 'Europe/Tirane' => 'Europe/Tirane', |
|
| 3060 | - 'Europe/Andorra' => 'Europe/Andorra', |
|
| 3061 | - 'Europe/Vienna' => 'Europe/Vienna', |
|
| 3062 | - 'Europe/Minsk' => 'Europe/Minsk', |
|
| 3063 | - 'Europe/Brussels' => 'Europe/Brussels', |
|
| 3064 | - 'Europe/Sofia' => 'Europe/Sofia', |
|
| 3065 | - 'Europe/Prague' => 'Europe/Prague', |
|
| 3066 | - 'Europe/Copenhagen' => 'Europe/Copenhagen', |
|
| 3067 | - 'Atlantic/Faeroe' => 'Atlantic/Faeroe', |
|
| 3068 | - 'America/Danmarkshavn' => 'America/Danmarkshavn', |
|
| 3069 | - 'America/Scoresbysund' => 'America/Scoresbysund', |
|
| 3070 | - 'America/Godthab' => 'America/Godthab', |
|
| 3071 | - 'America/Thule' => 'America/Thule', |
|
| 3072 | - 'Europe/Tallinn' => 'Europe/Tallinn', |
|
| 3073 | - 'Europe/Helsinki' => 'Europe/Helsinki', |
|
| 3074 | - 'Europe/Paris' => 'Europe/Paris', |
|
| 3075 | - 'Europe/Berlin' => 'Europe/Berlin', |
|
| 3076 | - 'Europe/Gibraltar' => 'Europe/Gibraltar', |
|
| 3077 | - 'Europe/Athens' => 'Europe/Athens', |
|
| 3078 | - 'Europe/Budapest' => 'Europe/Budapest', |
|
| 3079 | - 'Atlantic/Reykjavik' => 'Atlantic/Reykjavik', |
|
| 3080 | - 'Europe/Rome' => 'Europe/Rome', |
|
| 3081 | - 'Europe/Riga' => 'Europe/Riga', |
|
| 3082 | - 'Europe/Vaduz' => 'Europe/Vaduz', |
|
| 3083 | - 'Europe/Vilnius' => 'Europe/Vilnius', |
|
| 3084 | - 'Europe/Luxembourg' => 'Europe/Luxembourg', |
|
| 3085 | - 'Europe/Malta' => 'Europe/Malta', |
|
| 3086 | - 'Europe/Chisinau' => 'Europe/Chisinau', |
|
| 3087 | - 'Europe/Monaco' => 'Europe/Monaco', |
|
| 3088 | - 'Europe/Amsterdam' => 'Europe/Amsterdam', |
|
| 3089 | - 'Europe/Oslo' => 'Europe/Oslo', |
|
| 3090 | - 'Europe/Warsaw' => 'Europe/Warsaw', |
|
| 3091 | - 'Europe/Lisbon' => 'Europe/Lisbon', |
|
| 3092 | - 'Atlantic/Azores' => 'Atlantic/Azores', |
|
| 3093 | - 'Atlantic/Madeira' => 'Atlantic/Madeira', |
|
| 3094 | - 'Europe/Bucharest' => 'Europe/Bucharest', |
|
| 3095 | - 'Europe/Kaliningrad' => 'Europe/Kaliningrad', |
|
| 3096 | - 'Europe/Moscow' => 'Europe/Moscow', |
|
| 3097 | - 'Europe/Samara' => 'Europe/Samara', |
|
| 3098 | - 'Asia/Yekaterinburg' => 'Asia/Yekaterinburg', |
|
| 3099 | - 'Asia/Omsk' => 'Asia/Omsk', |
|
| 3100 | - 'Asia/Novosibirsk' => 'Asia/Novosibirsk', |
|
| 3101 | - 'Asia/Krasnoyarsk' => 'Asia/Krasnoyarsk', |
|
| 3102 | - 'Asia/Irkutsk' => 'Asia/Irkutsk', |
|
| 3103 | - 'Asia/Yakutsk' => 'Asia/Yakutsk', |
|
| 3104 | - 'Asia/Vladivostok' => 'Asia/Vladivostok', |
|
| 3105 | - 'Asia/Sakhalin' => 'Asia/Sakhalin', |
|
| 3106 | - 'Asia/Magadan' => 'Asia/Magadan', |
|
| 3107 | - 'Asia/Kamchatka' => 'Asia/Kamchatka', |
|
| 3108 | - 'Asia/Anadyr' => 'Asia/Anadyr', |
|
| 3109 | - 'Europe/Belgrade' => 'Europe/Belgrade' , |
|
| 3110 | - 'Europe/Madrid' =>'Europe/Madrid' , |
|
| 3111 | - 'Africa/Ceuta' => 'Africa/Ceuta', |
|
| 3112 | - 'Atlantic/Canary' => 'Atlantic/Canary', |
|
| 3113 | - 'Europe/Stockholm' => 'Europe/Stockholm', |
|
| 3114 | - 'Europe/Zurich' => 'Europe/Zurich' , |
|
| 3115 | - 'Europe/Istanbul' => 'Europe/Istanbul', |
|
| 3116 | - 'Europe/Kiev' => 'Europe/Kiev', |
|
| 3117 | - 'Europe/Uzhgorod' => 'Europe/Uzhgorod', |
|
| 3118 | - 'Europe/Zaporozhye' => 'Europe/Zaporozhye', |
|
| 3119 | - 'Europe/Simferopol' => 'Europe/Simferopol', |
|
| 3120 | - 'America/New_York' => 'America/New York', |
|
| 3121 | - 'America/Chicago' =>'America/Chicago' , |
|
| 3122 | - 'America/North_Dakota/Center' => 'America/North Dakota/Center', |
|
| 3123 | - 'America/Denver' => 'America/Denver', |
|
| 3124 | - 'America/Los_Angeles' => 'America/Los Angeles', |
|
| 3125 | - 'America/Juneau' => 'America/Juneau', |
|
| 3126 | - 'America/Yakutat' => 'America/Yakutat', |
|
| 3127 | - 'America/Anchorage' => 'America/Anchorage', |
|
| 3128 | - 'America/Nome' =>'America/Nome' , |
|
| 3129 | - 'America/Adak' => 'America/Adak', |
|
| 3130 | - 'Pacific/Honolulu' => 'Pacific/Honolulu', |
|
| 3131 | - 'America/Phoenix' => 'America/Phoenix', |
|
| 3132 | - 'America/Boise' => 'America/Boise', |
|
| 3133 | - 'America/Indiana/Indianapolis' => 'America/Indiana/Indianapolis', |
|
| 3134 | - 'America/Indiana/Marengo' => 'America/Indiana/Marengo', |
|
| 3135 | - 'America/Indiana/Knox' => 'America/Indiana/Knox', |
|
| 3136 | - 'America/Indiana/Vevay' => 'America/Indiana/Vevay', |
|
| 3137 | - 'America/Kentucky/Louisville' =>'America/Kentucky/Louisville' , |
|
| 3138 | - 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello' , |
|
| 3139 | - 'America/Detroit' => 'America/Detroit', |
|
| 3140 | - 'America/Menominee' => 'America/Menominee', |
|
| 3141 | - 'America/St_Johns' => 'America/St. Johns', |
|
| 3142 | - 'America/Goose_Bay' => 'America/Goose_Bay' , |
|
| 3143 | - 'America/Halifax' => 'America/Halifax', |
|
| 3144 | - 'America/Glace_Bay' =>'America/Glace Bay' , |
|
| 3145 | - 'America/Montreal' => 'America/Montreal', |
|
| 3146 | - 'America/Toronto' => 'America/Toronto', |
|
| 3147 | - 'America/Thunder_Bay' => 'America/Thunder Bay' , |
|
| 3148 | - 'America/Nipigon' => 'America/Nipigon', |
|
| 3149 | - 'America/Rainy_River' => 'America/Rainy River', |
|
| 3150 | - 'America/Winnipeg' => 'America/Winnipeg', |
|
| 3151 | - 'America/Regina' => 'America/Regina', |
|
| 3152 | - 'America/Swift_Current' => 'America/Swift Current', |
|
| 3153 | - 'America/Edmonton' => 'America/Edmonton', |
|
| 3154 | - 'America/Vancouver' => 'America/Vancouver', |
|
| 3155 | - 'America/Dawson_Creek' => 'America/Dawson Creek', |
|
| 3156 | - 'America/Pangnirtung' => 'America/Pangnirtung' , |
|
| 3157 | - 'America/Iqaluit' => 'America/Iqaluit' , |
|
| 3158 | - 'America/Coral_Harbour' => 'America/Coral Harbour' , |
|
| 3159 | - 'America/Rankin_Inlet' => 'America/Rankin Inlet', |
|
| 3160 | - 'America/Cambridge_Bay' => 'America/Cambridge Bay', |
|
| 3161 | - 'America/Yellowknife' => 'America/Yellowknife', |
|
| 3162 | - 'America/Inuvik' =>'America/Inuvik' , |
|
| 3163 | - 'America/Whitehorse' => 'America/Whitehorse' , |
|
| 3164 | - 'America/Dawson' => 'America/Dawson', |
|
| 3165 | - 'America/Cancun' => 'America/Cancun', |
|
| 3166 | - 'America/Merida' => 'America/Merida', |
|
| 3167 | - 'America/Monterrey' => 'America/Monterrey', |
|
| 3168 | - 'America/Mexico_City' => 'America/Mexico City', |
|
| 3169 | - 'America/Chihuahua' => 'America/Chihuahua', |
|
| 3170 | - 'America/Hermosillo' => 'America/Hermosillo', |
|
| 3171 | - 'America/Mazatlan' => 'America/Mazatlan', |
|
| 3172 | - 'America/Tijuana' => 'America/Tijuana', |
|
| 3173 | - 'America/Anguilla' => 'America/Anguilla', |
|
| 3174 | - 'America/Antigua' => 'America/Antigua', |
|
| 3175 | - 'America/Nassau' =>'America/Nassau' , |
|
| 3176 | - 'America/Barbados' => 'America/Barbados', |
|
| 3177 | - 'America/Belize' => 'America/Belize', |
|
| 3178 | - 'Atlantic/Bermuda' => 'Atlantic/Bermuda', |
|
| 3179 | - 'America/Cayman' => 'America/Cayman', |
|
| 3180 | - 'America/Costa_Rica' => 'America/Costa Rica', |
|
| 3181 | - 'America/Havana' => 'America/Havana', |
|
| 3182 | - 'America/Dominica' => 'America/Dominica', |
|
| 3183 | - 'America/Santo_Domingo' => 'America/Santo Domingo', |
|
| 3184 | - 'America/El_Salvador' => 'America/El Salvador', |
|
| 3185 | - 'America/Grenada' => 'America/Grenada', |
|
| 3186 | - 'America/Guadeloupe' => 'America/Guadeloupe', |
|
| 3187 | - 'America/Guatemala' => 'America/Guatemala', |
|
| 3188 | - 'America/Port-au-Prince' => 'America/Port-au-Prince', |
|
| 3189 | - 'America/Tegucigalpa' => 'America/Tegucigalpa', |
|
| 3190 | - 'America/Jamaica' => 'America/Jamaica', |
|
| 3191 | - 'America/Martinique' => 'America/Martinique', |
|
| 3192 | - 'America/Montserrat' => 'America/Montserrat', |
|
| 3193 | - 'America/Managua' => 'America/Managua', |
|
| 3194 | - 'America/Panama' => 'America/Panama', |
|
| 3195 | - 'America/Puerto_Rico' =>'America/Puerto_Rico' , |
|
| 3196 | - 'America/St_Kitts' => 'America/St_Kitts', |
|
| 3197 | - 'America/St_Lucia' => 'America/St_Lucia', |
|
| 3198 | - 'America/Miquelon' => 'America/Miquelon', |
|
| 3199 | - 'America/St_Vincent' => 'America/St. Vincent', |
|
| 3200 | - 'America/Grand_Turk' => 'America/Grand Turk', |
|
| 3201 | - 'America/Tortola' => 'America/Tortola', |
|
| 3202 | - 'America/St_Thomas' => 'America/St. Thomas', |
|
| 3203 | - 'America/Argentina/Buenos_Aires' => 'America/Argentina/Buenos Aires', |
|
| 3204 | - 'America/Argentina/Cordoba' => 'America/Argentina/Cordoba', |
|
| 3205 | - 'America/Argentina/Tucuman' => 'America/Argentina/Tucuman', |
|
| 3206 | - 'America/Argentina/La_Rioja' => 'America/Argentina/La_Rioja', |
|
| 3207 | - 'America/Argentina/San_Juan' => 'America/Argentina/San_Juan', |
|
| 3208 | - 'America/Argentina/Jujuy' => 'America/Argentina/Jujuy', |
|
| 3209 | - 'America/Argentina/Catamarca' => 'America/Argentina/Catamarca', |
|
| 3210 | - 'America/Argentina/Mendoza' => 'America/Argentina/Mendoza', |
|
| 3211 | - 'America/Argentina/Rio_Gallegos' => 'America/Argentina/Rio Gallegos', |
|
| 3212 | - 'America/Argentina/Ushuaia' => 'America/Argentina/Ushuaia', |
|
| 3213 | - 'America/Aruba' => 'America/Aruba', |
|
| 3214 | - 'America/La_Paz' => 'America/La Paz', |
|
| 3215 | - 'America/Noronha' => 'America/Noronha', |
|
| 3216 | - 'America/Belem' => 'America/Belem', |
|
| 3217 | - 'America/Fortaleza' => 'America/Fortaleza', |
|
| 3218 | - 'America/Recife' => 'America/Recife', |
|
| 3219 | - 'America/Araguaina' => 'America/Araguaina', |
|
| 3220 | - 'America/Maceio' => 'America/Maceio', |
|
| 3221 | - 'America/Bahia' => 'America/Bahia', |
|
| 3222 | - 'America/Sao_Paulo' => 'America/Sao Paulo', |
|
| 3223 | - 'America/Campo_Grande' => 'America/Campo Grande', |
|
| 3224 | - 'America/Cuiaba' => 'America/Cuiaba', |
|
| 3225 | - 'America/Porto_Velho' => 'America/Porto_Velho', |
|
| 3226 | - 'America/Boa_Vista' => 'America/Boa Vista', |
|
| 3227 | - 'America/Manaus' => 'America/Manaus', |
|
| 3228 | - 'America/Eirunepe' => 'America/Eirunepe', |
|
| 3229 | - 'America/Rio_Branco' => 'America/Rio Branco', |
|
| 3230 | - 'America/Santiago' => 'America/Santiago', |
|
| 3231 | - 'Pacific/Easter' => 'Pacific/Easter' , |
|
| 3232 | - 'America/Bogota' => 'America/Bogota', |
|
| 3233 | - 'America/Curacao' => 'America/Curacao', |
|
| 3234 | - 'America/Guayaquil' => 'America/Guayaquil', |
|
| 3235 | - 'Pacific/Galapagos' => 'Pacific/Galapagos' , |
|
| 3236 | - 'Atlantic/Stanley' => 'Atlantic/Stanley', |
|
| 3237 | - 'America/Cayenne' => 'America/Cayenne', |
|
| 3238 | - 'America/Guyana' => 'America/Guyana', |
|
| 3239 | - 'America/Asuncion' => 'America/Asuncion', |
|
| 3240 | - 'America/Lima' => 'America/Lima', |
|
| 3241 | - 'Atlantic/South_Georgia' => 'Atlantic/South Georgia', |
|
| 3242 | - 'America/Paramaribo' => 'America/Paramaribo', |
|
| 3243 | - 'America/Port_of_Spain' => 'America/Port-of-Spain', |
|
| 3244 | - 'America/Montevideo' => 'America/Montevideo', |
|
| 3245 | - 'America/Caracas' => 'America/Caracas', |
|
| 3246 | - ); |
|
| 3247 | - |
|
| 3248 | - $app_list_strings['moduleList']['Sugar_Favorites'] = 'Favorites'; |
|
| 3249 | - $app_list_strings['eapm_list']= array( |
|
| 2867 | + ); |
|
| 2868 | + |
|
| 2869 | + $app_list_strings['timezone_dom'] = array( |
|
| 2870 | + |
|
| 2871 | + 'Africa/Algiers' => 'Africa/Algiers', |
|
| 2872 | + 'Africa/Luanda' => 'Africa/Luanda', |
|
| 2873 | + 'Africa/Porto-Novo' => 'Africa/Porto-Novo', |
|
| 2874 | + 'Africa/Gaborone' => 'Africa/Gaborone', |
|
| 2875 | + 'Africa/Ouagadougou' => 'Africa/Ouagadougou', |
|
| 2876 | + 'Africa/Bujumbura' => 'Africa/Bujumbura', |
|
| 2877 | + 'Africa/Douala' => 'Africa/Douala', |
|
| 2878 | + 'Atlantic/Cape_Verde' => 'Atlantic/Cape Verde', |
|
| 2879 | + 'Africa/Bangui' => 'Africa/Bangui', |
|
| 2880 | + 'Africa/Ndjamena' => 'Africa/Ndjamena', |
|
| 2881 | + 'Indian/Comoro' => 'Indian/Comoro', |
|
| 2882 | + 'Africa/Kinshasa' => 'Africa/Kinshasa', |
|
| 2883 | + 'Africa/Lubumbashi' => 'Africa/Lubumbashi', |
|
| 2884 | + 'Africa/Brazzaville' => 'Africa/Brazzaville', |
|
| 2885 | + 'Africa/Abidjan' => 'Africa/Abidjan', |
|
| 2886 | + 'Africa/Djibouti' => 'Africa/Djibouti', |
|
| 2887 | + 'Africa/Cairo' => 'Africa/Cairo', |
|
| 2888 | + 'Africa/Malabo' => 'Africa/Malabo', |
|
| 2889 | + 'Africa/Asmera' => 'Africa/Asmera', |
|
| 2890 | + 'Africa/Addis_Ababa' => 'Africa/Addis Ababa', |
|
| 2891 | + 'Africa/Libreville' => 'Africa/Libreville', |
|
| 2892 | + 'Africa/Banjul' => 'Africa/Banjul', |
|
| 2893 | + 'Africa/Accra' => 'Africa/Accra', |
|
| 2894 | + 'Africa/Conakry' => 'Africa/Conakry', |
|
| 2895 | + 'Africa/Bissau' => 'Africa/Bissau', |
|
| 2896 | + 'Africa/Nairobi' => 'Africa/Nairobi', |
|
| 2897 | + 'Africa/Maseru' => 'Africa/Maseru', |
|
| 2898 | + 'Africa/Monrovia' => 'Africa/Monrovia', |
|
| 2899 | + 'Africa/Tripoli' => 'Africa/Tripoli', |
|
| 2900 | + 'Indian/Antananarivo' => 'Indian/Antananarivo', |
|
| 2901 | + 'Africa/Blantyre' => 'Africa/Blantyre', |
|
| 2902 | + 'Africa/Bamako' => 'Africa/Bamako', |
|
| 2903 | + 'Africa/Nouakchott' => 'Africa/Nouakchott', |
|
| 2904 | + 'Indian/Mauritius' => 'Indian/Mauritius', |
|
| 2905 | + 'Indian/Mayotte' => 'Indian/Mayotte', |
|
| 2906 | + 'Africa/Casablanca' => 'Africa/Casablanca', |
|
| 2907 | + 'Africa/El_Aaiun' => 'Africa/El Aaiun', |
|
| 2908 | + 'Africa/Maputo' => 'Africa/Maputo', |
|
| 2909 | + 'Africa/Windhoek' => 'Africa/Windhoek', |
|
| 2910 | + 'Africa/Niamey' => 'Africa/Niamey', |
|
| 2911 | + 'Africa/Lagos' => 'Africa/Lagos', |
|
| 2912 | + 'Indian/Reunion' => 'Indian/Reunion', |
|
| 2913 | + 'Africa/Kigali' => 'Africa/Kigali', |
|
| 2914 | + 'Atlantic/St_Helena' => 'Atlantic/St. Helena', |
|
| 2915 | + 'Africa/Sao_Tome' => 'Africa/Sao Tome', |
|
| 2916 | + 'Africa/Dakar' => 'Africa/Dakar', |
|
| 2917 | + 'Indian/Mahe' => 'Indian/Mahe', |
|
| 2918 | + 'Africa/Freetown' => 'Africa/Freetown', |
|
| 2919 | + 'Africa/Mogadishu' => 'Africa/Mogadishu', |
|
| 2920 | + 'Africa/Johannesburg' => 'Africa/Johannesburg', |
|
| 2921 | + 'Africa/Khartoum' => 'Africa/Khartoum', |
|
| 2922 | + 'Africa/Mbabane' => 'Africa/Mbabane', |
|
| 2923 | + 'Africa/Dar_es_Salaam' => 'Africa/Dar es Salaam', |
|
| 2924 | + 'Africa/Lome' => 'Africa/Lome', |
|
| 2925 | + 'Africa/Tunis' => 'Africa/Tunis', |
|
| 2926 | + 'Africa/Kampala' => 'Africa/Kampala', |
|
| 2927 | + 'Africa/Lusaka' => 'Africa/Lusaka', |
|
| 2928 | + 'Africa/Harare' => 'Africa/Harare', |
|
| 2929 | + 'Antarctica/Casey' => 'Antarctica/Casey', |
|
| 2930 | + 'Antarctica/Davis' => 'Antarctica/Davis', |
|
| 2931 | + 'Antarctica/Mawson' => 'Antarctica/Mawson', |
|
| 2932 | + 'Indian/Kerguelen' => 'Indian/Kerguelen', |
|
| 2933 | + 'Antarctica/DumontDUrville' => 'Antarctica/DumontDUrville', |
|
| 2934 | + 'Antarctica/Syowa' => 'Antarctica/Syowa', |
|
| 2935 | + 'Antarctica/Vostok' => 'Antarctica/Vostok', |
|
| 2936 | + 'Antarctica/Rothera' => 'Antarctica/Rothera', |
|
| 2937 | + 'Antarctica/Palmer' => 'Antarctica/Palmer', |
|
| 2938 | + 'Antarctica/McMurdo' => 'Antarctica/McMurdo', |
|
| 2939 | + 'Asia/Kabul' => 'Asia/Kabul', |
|
| 2940 | + 'Asia/Yerevan' => 'Asia/Yerevan', |
|
| 2941 | + 'Asia/Baku' => 'Asia/Baku', |
|
| 2942 | + 'Asia/Bahrain' => 'Asia/Bahrain', |
|
| 2943 | + 'Asia/Dhaka' => 'Asia/Dhaka', |
|
| 2944 | + 'Asia/Thimphu' => 'Asia/Thimphu', |
|
| 2945 | + 'Indian/Chagos' => 'Indian/Chagos', |
|
| 2946 | + 'Asia/Brunei' => 'Asia/Brunei', |
|
| 2947 | + 'Asia/Rangoon' => 'Asia/Rangoon', |
|
| 2948 | + 'Asia/Phnom_Penh' => 'Asia/Phnom Penh', |
|
| 2949 | + 'Asia/Beijing' => 'Asia/Beijing', |
|
| 2950 | + 'Asia/Harbin' => 'Asia/Harbin', |
|
| 2951 | + 'Asia/Shanghai' => 'Asia/Shanghai', |
|
| 2952 | + 'Asia/Chongqing' => 'Asia/Chongqing', |
|
| 2953 | + 'Asia/Urumqi' => 'Asia/Urumqi', |
|
| 2954 | + 'Asia/Kashgar' => 'Asia/Kashgar', |
|
| 2955 | + 'Asia/Hong_Kong' => 'Asia/Hong Kong', |
|
| 2956 | + 'Asia/Taipei' => 'Asia/Taipei', |
|
| 2957 | + 'Asia/Macau' => 'Asia/Macau', |
|
| 2958 | + 'Asia/Nicosia' => 'Asia/Nicosia', |
|
| 2959 | + 'Asia/Tbilisi' => 'Asia/Tbilisi', |
|
| 2960 | + 'Asia/Dili' => 'Asia/Dili', |
|
| 2961 | + 'Asia/Calcutta' => 'Asia/Calcutta', |
|
| 2962 | + 'Asia/Jakarta' => 'Asia/Jakarta', |
|
| 2963 | + 'Asia/Pontianak' => 'Asia/Pontianak', |
|
| 2964 | + 'Asia/Makassar' => 'Asia/Makassar', |
|
| 2965 | + 'Asia/Jayapura' => 'Asia/Jayapura', |
|
| 2966 | + 'Asia/Tehran' => 'Asia/Tehran', |
|
| 2967 | + 'Asia/Baghdad' => 'Asia/Baghdad', |
|
| 2968 | + 'Asia/Jerusalem' => 'Asia/Jerusalem', |
|
| 2969 | + 'Asia/Tokyo' => 'Asia/Tokyo', |
|
| 2970 | + 'Asia/Amman' => 'Asia/Amman', |
|
| 2971 | + 'Asia/Almaty' => 'Asia/Almaty', |
|
| 2972 | + 'Asia/Qyzylorda' => 'Asia/Qyzylorda', |
|
| 2973 | + 'Asia/Aqtobe' => 'Asia/Aqtobe', |
|
| 2974 | + 'Asia/Aqtau' => 'Asia/Aqtau', |
|
| 2975 | + 'Asia/Oral' => 'Asia/Oral', |
|
| 2976 | + 'Asia/Bishkek' => 'Asia/Bishkek', |
|
| 2977 | + 'Asia/Seoul' => 'Asia/Seoul', |
|
| 2978 | + 'Asia/Pyongyang' => 'Asia/Pyongyang', |
|
| 2979 | + 'Asia/Kuwait' => 'Asia/Kuwait', |
|
| 2980 | + 'Asia/Vientiane' => 'Asia/Vientiane', |
|
| 2981 | + 'Asia/Beirut' => 'Asia/Beirut', |
|
| 2982 | + 'Asia/Kuala_Lumpur' => 'Asia/Kuala Lumpur', |
|
| 2983 | + 'Asia/Kuching' => 'Asia/Kuching', |
|
| 2984 | + 'Indian/Maldives' => 'Indian/Maldives', |
|
| 2985 | + 'Asia/Hovd' => 'Asia/Hovd', |
|
| 2986 | + 'Asia/Ulaanbaatar' => 'Asia/Ulaanbaatar', |
|
| 2987 | + 'Asia/Choibalsan' => 'Asia/Choibalsan', |
|
| 2988 | + 'Asia/Katmandu' => 'Asia/Katmandu', |
|
| 2989 | + 'Asia/Muscat' => 'Asia/Muscat', |
|
| 2990 | + 'Asia/Karachi' => 'Asia/Karachi', |
|
| 2991 | + 'Asia/Gaza' => 'Asia/Gaza', |
|
| 2992 | + 'Asia/Manila' => 'Asia/Manila', |
|
| 2993 | + 'Asia/Qatar' => 'Asia/Qatar', |
|
| 2994 | + 'Asia/Riyadh' => 'Asia/Riyadh', |
|
| 2995 | + 'Asia/Singapore' => 'Asia/Singapore', |
|
| 2996 | + 'Asia/Colombo' => 'Asia/Colombo', |
|
| 2997 | + 'Asia/Damascus' => 'Asia/Damascus', |
|
| 2998 | + 'Asia/Dushanbe' => 'Asia/Dushanbe', |
|
| 2999 | + 'Asia/Bangkok' => 'Asia/Bangkok', |
|
| 3000 | + 'Asia/Ashgabat' => 'Asia/Ashgabat', |
|
| 3001 | + 'Asia/Dubai' => 'Asia/Dubai', |
|
| 3002 | + 'Asia/Samarkand' => 'Asia/Samarkand', |
|
| 3003 | + 'Asia/Tashkent' => 'Asia/Tashkent', |
|
| 3004 | + 'Asia/Saigon' => 'Asia/Saigon', |
|
| 3005 | + 'Asia/Aden' => 'Asia/Aden', |
|
| 3006 | + 'Australia/Darwin' => 'Australia/Darwin', |
|
| 3007 | + 'Australia/Perth' => 'Australia/Perth', |
|
| 3008 | + 'Australia/Brisbane' => 'Australia/Brisbane', |
|
| 3009 | + 'Australia/Lindeman' => 'Australia/Lindeman', |
|
| 3010 | + 'Australia/Adelaide' => 'Australia/Adelaide', |
|
| 3011 | + 'Australia/Hobart' => 'Australia/Hobart', |
|
| 3012 | + 'Australia/Currie' => 'Australia/Currie', |
|
| 3013 | + 'Australia/Melbourne' => 'Australia/Melbourne', |
|
| 3014 | + 'Australia/Sydney' => 'Australia/Sydney', |
|
| 3015 | + 'Australia/Broken_Hill' => 'Australia/Broken Hill', |
|
| 3016 | + 'Indian/Christmas' => 'Indian/Christmas', |
|
| 3017 | + 'Pacific/Rarotonga' => 'Pacific/Rarotonga', |
|
| 3018 | + 'Indian/Cocos' => 'Indian/Cocos', |
|
| 3019 | + 'Pacific/Fiji' => 'Pacific/Fiji', |
|
| 3020 | + 'Pacific/Gambier' => 'Pacific/Gambier', |
|
| 3021 | + 'Pacific/Marquesas' => 'Pacific/Marquesas', |
|
| 3022 | + 'Pacific/Tahiti' => 'Pacific/Tahiti', |
|
| 3023 | + 'Pacific/Guam' => 'Pacific/Guam', |
|
| 3024 | + 'Pacific/Tarawa' => 'Pacific/Tarawa', |
|
| 3025 | + 'Pacific/Enderbury' => 'Pacific/Enderbury', |
|
| 3026 | + 'Pacific/Kiritimati' => 'Pacific/Kiritimati', |
|
| 3027 | + 'Pacific/Saipan' => 'Pacific/Saipan', |
|
| 3028 | + 'Pacific/Majuro' => 'Pacific/Majuro', |
|
| 3029 | + 'Pacific/Kwajalein' => 'Pacific/Kwajalein', |
|
| 3030 | + 'Pacific/Truk' => 'Pacific/Truk', |
|
| 3031 | + 'Pacific/Pohnpei' => 'Pacific/Pohnpei', |
|
| 3032 | + 'Pacific/Kosrae' => 'Pacific/Kosrae', |
|
| 3033 | + 'Pacific/Nauru' => 'Pacific/Nauru', |
|
| 3034 | + 'Pacific/Noumea' => 'Pacific/Noumea', |
|
| 3035 | + 'Pacific/Auckland' => 'Pacific/Auckland', |
|
| 3036 | + 'Pacific/Chatham' => 'Pacific/Chatham', |
|
| 3037 | + 'Pacific/Niue' => 'Pacific/Niue', |
|
| 3038 | + 'Pacific/Norfolk' => 'Pacific/Norfolk', |
|
| 3039 | + 'Pacific/Palau' => 'Pacific/Palau', |
|
| 3040 | + 'Pacific/Port_Moresby' => 'Pacific/Port Moresby', |
|
| 3041 | + 'Pacific/Pitcairn' => 'Pacific/Pitcairn', |
|
| 3042 | + 'Pacific/Pago_Pago' => 'Pacific/Pago Pago', |
|
| 3043 | + 'Pacific/Apia' => 'Pacific/Apia', |
|
| 3044 | + 'Pacific/Guadalcanal' => 'Pacific/Guadalcanal', |
|
| 3045 | + 'Pacific/Fakaofo' => 'Pacific/Fakaofo', |
|
| 3046 | + 'Pacific/Tongatapu' => 'Pacific/Tongatapu', |
|
| 3047 | + 'Pacific/Funafuti' => 'Pacific/Funafuti', |
|
| 3048 | + 'Pacific/Johnston' => 'Pacific/Johnston', |
|
| 3049 | + 'Pacific/Midway' => 'Pacific/Midway', |
|
| 3050 | + 'Pacific/Wake' => 'Pacific/Wake', |
|
| 3051 | + 'Pacific/Efate' => 'Pacific/Efate', |
|
| 3052 | + 'Pacific/Wallis' => 'Pacific/Wallis', |
|
| 3053 | + 'Europe/London' => 'Europe/London', |
|
| 3054 | + 'Europe/Dublin' => 'Europe/Dublin', |
|
| 3055 | + 'WET' => 'WET', |
|
| 3056 | + 'CET' => 'CET', |
|
| 3057 | + 'MET' => 'MET', |
|
| 3058 | + 'EET' => 'EET', |
|
| 3059 | + 'Europe/Tirane' => 'Europe/Tirane', |
|
| 3060 | + 'Europe/Andorra' => 'Europe/Andorra', |
|
| 3061 | + 'Europe/Vienna' => 'Europe/Vienna', |
|
| 3062 | + 'Europe/Minsk' => 'Europe/Minsk', |
|
| 3063 | + 'Europe/Brussels' => 'Europe/Brussels', |
|
| 3064 | + 'Europe/Sofia' => 'Europe/Sofia', |
|
| 3065 | + 'Europe/Prague' => 'Europe/Prague', |
|
| 3066 | + 'Europe/Copenhagen' => 'Europe/Copenhagen', |
|
| 3067 | + 'Atlantic/Faeroe' => 'Atlantic/Faeroe', |
|
| 3068 | + 'America/Danmarkshavn' => 'America/Danmarkshavn', |
|
| 3069 | + 'America/Scoresbysund' => 'America/Scoresbysund', |
|
| 3070 | + 'America/Godthab' => 'America/Godthab', |
|
| 3071 | + 'America/Thule' => 'America/Thule', |
|
| 3072 | + 'Europe/Tallinn' => 'Europe/Tallinn', |
|
| 3073 | + 'Europe/Helsinki' => 'Europe/Helsinki', |
|
| 3074 | + 'Europe/Paris' => 'Europe/Paris', |
|
| 3075 | + 'Europe/Berlin' => 'Europe/Berlin', |
|
| 3076 | + 'Europe/Gibraltar' => 'Europe/Gibraltar', |
|
| 3077 | + 'Europe/Athens' => 'Europe/Athens', |
|
| 3078 | + 'Europe/Budapest' => 'Europe/Budapest', |
|
| 3079 | + 'Atlantic/Reykjavik' => 'Atlantic/Reykjavik', |
|
| 3080 | + 'Europe/Rome' => 'Europe/Rome', |
|
| 3081 | + 'Europe/Riga' => 'Europe/Riga', |
|
| 3082 | + 'Europe/Vaduz' => 'Europe/Vaduz', |
|
| 3083 | + 'Europe/Vilnius' => 'Europe/Vilnius', |
|
| 3084 | + 'Europe/Luxembourg' => 'Europe/Luxembourg', |
|
| 3085 | + 'Europe/Malta' => 'Europe/Malta', |
|
| 3086 | + 'Europe/Chisinau' => 'Europe/Chisinau', |
|
| 3087 | + 'Europe/Monaco' => 'Europe/Monaco', |
|
| 3088 | + 'Europe/Amsterdam' => 'Europe/Amsterdam', |
|
| 3089 | + 'Europe/Oslo' => 'Europe/Oslo', |
|
| 3090 | + 'Europe/Warsaw' => 'Europe/Warsaw', |
|
| 3091 | + 'Europe/Lisbon' => 'Europe/Lisbon', |
|
| 3092 | + 'Atlantic/Azores' => 'Atlantic/Azores', |
|
| 3093 | + 'Atlantic/Madeira' => 'Atlantic/Madeira', |
|
| 3094 | + 'Europe/Bucharest' => 'Europe/Bucharest', |
|
| 3095 | + 'Europe/Kaliningrad' => 'Europe/Kaliningrad', |
|
| 3096 | + 'Europe/Moscow' => 'Europe/Moscow', |
|
| 3097 | + 'Europe/Samara' => 'Europe/Samara', |
|
| 3098 | + 'Asia/Yekaterinburg' => 'Asia/Yekaterinburg', |
|
| 3099 | + 'Asia/Omsk' => 'Asia/Omsk', |
|
| 3100 | + 'Asia/Novosibirsk' => 'Asia/Novosibirsk', |
|
| 3101 | + 'Asia/Krasnoyarsk' => 'Asia/Krasnoyarsk', |
|
| 3102 | + 'Asia/Irkutsk' => 'Asia/Irkutsk', |
|
| 3103 | + 'Asia/Yakutsk' => 'Asia/Yakutsk', |
|
| 3104 | + 'Asia/Vladivostok' => 'Asia/Vladivostok', |
|
| 3105 | + 'Asia/Sakhalin' => 'Asia/Sakhalin', |
|
| 3106 | + 'Asia/Magadan' => 'Asia/Magadan', |
|
| 3107 | + 'Asia/Kamchatka' => 'Asia/Kamchatka', |
|
| 3108 | + 'Asia/Anadyr' => 'Asia/Anadyr', |
|
| 3109 | + 'Europe/Belgrade' => 'Europe/Belgrade' , |
|
| 3110 | + 'Europe/Madrid' =>'Europe/Madrid' , |
|
| 3111 | + 'Africa/Ceuta' => 'Africa/Ceuta', |
|
| 3112 | + 'Atlantic/Canary' => 'Atlantic/Canary', |
|
| 3113 | + 'Europe/Stockholm' => 'Europe/Stockholm', |
|
| 3114 | + 'Europe/Zurich' => 'Europe/Zurich' , |
|
| 3115 | + 'Europe/Istanbul' => 'Europe/Istanbul', |
|
| 3116 | + 'Europe/Kiev' => 'Europe/Kiev', |
|
| 3117 | + 'Europe/Uzhgorod' => 'Europe/Uzhgorod', |
|
| 3118 | + 'Europe/Zaporozhye' => 'Europe/Zaporozhye', |
|
| 3119 | + 'Europe/Simferopol' => 'Europe/Simferopol', |
|
| 3120 | + 'America/New_York' => 'America/New York', |
|
| 3121 | + 'America/Chicago' =>'America/Chicago' , |
|
| 3122 | + 'America/North_Dakota/Center' => 'America/North Dakota/Center', |
|
| 3123 | + 'America/Denver' => 'America/Denver', |
|
| 3124 | + 'America/Los_Angeles' => 'America/Los Angeles', |
|
| 3125 | + 'America/Juneau' => 'America/Juneau', |
|
| 3126 | + 'America/Yakutat' => 'America/Yakutat', |
|
| 3127 | + 'America/Anchorage' => 'America/Anchorage', |
|
| 3128 | + 'America/Nome' =>'America/Nome' , |
|
| 3129 | + 'America/Adak' => 'America/Adak', |
|
| 3130 | + 'Pacific/Honolulu' => 'Pacific/Honolulu', |
|
| 3131 | + 'America/Phoenix' => 'America/Phoenix', |
|
| 3132 | + 'America/Boise' => 'America/Boise', |
|
| 3133 | + 'America/Indiana/Indianapolis' => 'America/Indiana/Indianapolis', |
|
| 3134 | + 'America/Indiana/Marengo' => 'America/Indiana/Marengo', |
|
| 3135 | + 'America/Indiana/Knox' => 'America/Indiana/Knox', |
|
| 3136 | + 'America/Indiana/Vevay' => 'America/Indiana/Vevay', |
|
| 3137 | + 'America/Kentucky/Louisville' =>'America/Kentucky/Louisville' , |
|
| 3138 | + 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello' , |
|
| 3139 | + 'America/Detroit' => 'America/Detroit', |
|
| 3140 | + 'America/Menominee' => 'America/Menominee', |
|
| 3141 | + 'America/St_Johns' => 'America/St. Johns', |
|
| 3142 | + 'America/Goose_Bay' => 'America/Goose_Bay' , |
|
| 3143 | + 'America/Halifax' => 'America/Halifax', |
|
| 3144 | + 'America/Glace_Bay' =>'America/Glace Bay' , |
|
| 3145 | + 'America/Montreal' => 'America/Montreal', |
|
| 3146 | + 'America/Toronto' => 'America/Toronto', |
|
| 3147 | + 'America/Thunder_Bay' => 'America/Thunder Bay' , |
|
| 3148 | + 'America/Nipigon' => 'America/Nipigon', |
|
| 3149 | + 'America/Rainy_River' => 'America/Rainy River', |
|
| 3150 | + 'America/Winnipeg' => 'America/Winnipeg', |
|
| 3151 | + 'America/Regina' => 'America/Regina', |
|
| 3152 | + 'America/Swift_Current' => 'America/Swift Current', |
|
| 3153 | + 'America/Edmonton' => 'America/Edmonton', |
|
| 3154 | + 'America/Vancouver' => 'America/Vancouver', |
|
| 3155 | + 'America/Dawson_Creek' => 'America/Dawson Creek', |
|
| 3156 | + 'America/Pangnirtung' => 'America/Pangnirtung' , |
|
| 3157 | + 'America/Iqaluit' => 'America/Iqaluit' , |
|
| 3158 | + 'America/Coral_Harbour' => 'America/Coral Harbour' , |
|
| 3159 | + 'America/Rankin_Inlet' => 'America/Rankin Inlet', |
|
| 3160 | + 'America/Cambridge_Bay' => 'America/Cambridge Bay', |
|
| 3161 | + 'America/Yellowknife' => 'America/Yellowknife', |
|
| 3162 | + 'America/Inuvik' =>'America/Inuvik' , |
|
| 3163 | + 'America/Whitehorse' => 'America/Whitehorse' , |
|
| 3164 | + 'America/Dawson' => 'America/Dawson', |
|
| 3165 | + 'America/Cancun' => 'America/Cancun', |
|
| 3166 | + 'America/Merida' => 'America/Merida', |
|
| 3167 | + 'America/Monterrey' => 'America/Monterrey', |
|
| 3168 | + 'America/Mexico_City' => 'America/Mexico City', |
|
| 3169 | + 'America/Chihuahua' => 'America/Chihuahua', |
|
| 3170 | + 'America/Hermosillo' => 'America/Hermosillo', |
|
| 3171 | + 'America/Mazatlan' => 'America/Mazatlan', |
|
| 3172 | + 'America/Tijuana' => 'America/Tijuana', |
|
| 3173 | + 'America/Anguilla' => 'America/Anguilla', |
|
| 3174 | + 'America/Antigua' => 'America/Antigua', |
|
| 3175 | + 'America/Nassau' =>'America/Nassau' , |
|
| 3176 | + 'America/Barbados' => 'America/Barbados', |
|
| 3177 | + 'America/Belize' => 'America/Belize', |
|
| 3178 | + 'Atlantic/Bermuda' => 'Atlantic/Bermuda', |
|
| 3179 | + 'America/Cayman' => 'America/Cayman', |
|
| 3180 | + 'America/Costa_Rica' => 'America/Costa Rica', |
|
| 3181 | + 'America/Havana' => 'America/Havana', |
|
| 3182 | + 'America/Dominica' => 'America/Dominica', |
|
| 3183 | + 'America/Santo_Domingo' => 'America/Santo Domingo', |
|
| 3184 | + 'America/El_Salvador' => 'America/El Salvador', |
|
| 3185 | + 'America/Grenada' => 'America/Grenada', |
|
| 3186 | + 'America/Guadeloupe' => 'America/Guadeloupe', |
|
| 3187 | + 'America/Guatemala' => 'America/Guatemala', |
|
| 3188 | + 'America/Port-au-Prince' => 'America/Port-au-Prince', |
|
| 3189 | + 'America/Tegucigalpa' => 'America/Tegucigalpa', |
|
| 3190 | + 'America/Jamaica' => 'America/Jamaica', |
|
| 3191 | + 'America/Martinique' => 'America/Martinique', |
|
| 3192 | + 'America/Montserrat' => 'America/Montserrat', |
|
| 3193 | + 'America/Managua' => 'America/Managua', |
|
| 3194 | + 'America/Panama' => 'America/Panama', |
|
| 3195 | + 'America/Puerto_Rico' =>'America/Puerto_Rico' , |
|
| 3196 | + 'America/St_Kitts' => 'America/St_Kitts', |
|
| 3197 | + 'America/St_Lucia' => 'America/St_Lucia', |
|
| 3198 | + 'America/Miquelon' => 'America/Miquelon', |
|
| 3199 | + 'America/St_Vincent' => 'America/St. Vincent', |
|
| 3200 | + 'America/Grand_Turk' => 'America/Grand Turk', |
|
| 3201 | + 'America/Tortola' => 'America/Tortola', |
|
| 3202 | + 'America/St_Thomas' => 'America/St. Thomas', |
|
| 3203 | + 'America/Argentina/Buenos_Aires' => 'America/Argentina/Buenos Aires', |
|
| 3204 | + 'America/Argentina/Cordoba' => 'America/Argentina/Cordoba', |
|
| 3205 | + 'America/Argentina/Tucuman' => 'America/Argentina/Tucuman', |
|
| 3206 | + 'America/Argentina/La_Rioja' => 'America/Argentina/La_Rioja', |
|
| 3207 | + 'America/Argentina/San_Juan' => 'America/Argentina/San_Juan', |
|
| 3208 | + 'America/Argentina/Jujuy' => 'America/Argentina/Jujuy', |
|
| 3209 | + 'America/Argentina/Catamarca' => 'America/Argentina/Catamarca', |
|
| 3210 | + 'America/Argentina/Mendoza' => 'America/Argentina/Mendoza', |
|
| 3211 | + 'America/Argentina/Rio_Gallegos' => 'America/Argentina/Rio Gallegos', |
|
| 3212 | + 'America/Argentina/Ushuaia' => 'America/Argentina/Ushuaia', |
|
| 3213 | + 'America/Aruba' => 'America/Aruba', |
|
| 3214 | + 'America/La_Paz' => 'America/La Paz', |
|
| 3215 | + 'America/Noronha' => 'America/Noronha', |
|
| 3216 | + 'America/Belem' => 'America/Belem', |
|
| 3217 | + 'America/Fortaleza' => 'America/Fortaleza', |
|
| 3218 | + 'America/Recife' => 'America/Recife', |
|
| 3219 | + 'America/Araguaina' => 'America/Araguaina', |
|
| 3220 | + 'America/Maceio' => 'America/Maceio', |
|
| 3221 | + 'America/Bahia' => 'America/Bahia', |
|
| 3222 | + 'America/Sao_Paulo' => 'America/Sao Paulo', |
|
| 3223 | + 'America/Campo_Grande' => 'America/Campo Grande', |
|
| 3224 | + 'America/Cuiaba' => 'America/Cuiaba', |
|
| 3225 | + 'America/Porto_Velho' => 'America/Porto_Velho', |
|
| 3226 | + 'America/Boa_Vista' => 'America/Boa Vista', |
|
| 3227 | + 'America/Manaus' => 'America/Manaus', |
|
| 3228 | + 'America/Eirunepe' => 'America/Eirunepe', |
|
| 3229 | + 'America/Rio_Branco' => 'America/Rio Branco', |
|
| 3230 | + 'America/Santiago' => 'America/Santiago', |
|
| 3231 | + 'Pacific/Easter' => 'Pacific/Easter' , |
|
| 3232 | + 'America/Bogota' => 'America/Bogota', |
|
| 3233 | + 'America/Curacao' => 'America/Curacao', |
|
| 3234 | + 'America/Guayaquil' => 'America/Guayaquil', |
|
| 3235 | + 'Pacific/Galapagos' => 'Pacific/Galapagos' , |
|
| 3236 | + 'Atlantic/Stanley' => 'Atlantic/Stanley', |
|
| 3237 | + 'America/Cayenne' => 'America/Cayenne', |
|
| 3238 | + 'America/Guyana' => 'America/Guyana', |
|
| 3239 | + 'America/Asuncion' => 'America/Asuncion', |
|
| 3240 | + 'America/Lima' => 'America/Lima', |
|
| 3241 | + 'Atlantic/South_Georgia' => 'Atlantic/South Georgia', |
|
| 3242 | + 'America/Paramaribo' => 'America/Paramaribo', |
|
| 3243 | + 'America/Port_of_Spain' => 'America/Port-of-Spain', |
|
| 3244 | + 'America/Montevideo' => 'America/Montevideo', |
|
| 3245 | + 'America/Caracas' => 'America/Caracas', |
|
| 3246 | + ); |
|
| 3247 | + |
|
| 3248 | + $app_list_strings['moduleList']['Sugar_Favorites'] = 'Favorites'; |
|
| 3249 | + $app_list_strings['eapm_list']= array( |
|
| 3250 | 3250 | 'Sugar'=>'SuiteCRM', |
| 3251 | 3251 | 'WebEx'=>'WebEx', |
| 3252 | 3252 | 'GoToMeeting'=>'GoToMeeting', |
@@ -3255,14 +3255,14 @@ discard block |
||
| 3255 | 3255 | 'Box' => 'Box.net', |
| 3256 | 3256 | 'Facebook'=>'Facebook', |
| 3257 | 3257 | 'Twitter'=>'Twitter', |
| 3258 | - ); |
|
| 3259 | - $app_list_strings['eapm_list_import']= array( |
|
| 3260 | - 'Google' => 'Google Contacts', |
|
| 3261 | - ); |
|
| 3258 | + ); |
|
| 3259 | + $app_list_strings['eapm_list_import']= array( |
|
| 3260 | + 'Google' => 'Google Contacts', |
|
| 3261 | + ); |
|
| 3262 | 3262 | $app_list_strings['eapm_list_documents']= array( |
| 3263 | - 'Google' => 'Google Docs', |
|
| 3264 | - ); |
|
| 3265 | - $app_list_strings['token_status'] = array( |
|
| 3263 | + 'Google' => 'Google Docs', |
|
| 3264 | + ); |
|
| 3265 | + $app_list_strings['token_status'] = array( |
|
| 3266 | 3266 | 1 => 'Request', |
| 3267 | 3267 | 2 => 'Access', |
| 3268 | 3268 | 3 => 'Invalid', |
@@ -3272,25 +3272,25 @@ discard block |
||
| 3272 | 3272 | '' => '' , |
| 3273 | 3273 | 'campaign' => 'Campaign' , |
| 3274 | 3274 | 'email' => 'Email', |
| 3275 | - ); |
|
| 3275 | + ); |
|
| 3276 | 3276 | |
| 3277 | 3277 | $app_list_strings ['emailTemplates_type_list_campaigns'] = array ( |
| 3278 | 3278 | '' => '' , |
| 3279 | 3279 | 'campaign' => 'Campaign' , |
| 3280 | - ); |
|
| 3280 | + ); |
|
| 3281 | 3281 | |
| 3282 | 3282 | $app_list_strings ['emailTemplates_type_list_no_workflow'] = array ( |
| 3283 | 3283 | '' => '' , |
| 3284 | 3284 | 'campaign' => 'Campaign' , |
| 3285 | 3285 | 'email' => 'Email', |
| 3286 | - ); |
|
| 3286 | + ); |
|
| 3287 | 3287 | $app_strings ['documentation'] = array ( |
| 3288 | 3288 | 'LBL_DOCS' => 'Documentation', |
| 3289 | 3289 | 'ULT' => '02_Sugar_Ultimate', |
| 3290 | - 'ENT' => '02_Sugar_Enterprise', |
|
| 3291 | - 'CORP' => '03_Sugar_Corporate', |
|
| 3292 | - 'PRO' => '04_Sugar_Professional', |
|
| 3293 | - 'COM' => '05_Sugar_Community_Edition' |
|
| 3290 | + 'ENT' => '02_Sugar_Enterprise', |
|
| 3291 | + 'CORP' => '03_Sugar_Corporate', |
|
| 3292 | + 'PRO' => '04_Sugar_Professional', |
|
| 3293 | + 'COM' => '05_Sugar_Community_Edition' |
|
| 3294 | 3294 | ); |
| 3295 | 3295 | |
| 3296 | 3296 | |
@@ -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. |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | //the left value is the key stored in the db and the right value is ie display value |
| 50 | 50 | //to translate, only modify the right value in each key/value pair |
| 51 | -$app_list_strings = array ( |
|
| 51 | +$app_list_strings = array( |
|
| 52 | 52 | //e.g. auf Deutsch 'Contacts'=>'Contakten', |
| 53 | 53 | 'language_pack_name' => 'US English', |
| 54 | 54 | 'moduleList' => |
| 55 | - array ( |
|
| 55 | + array( |
|
| 56 | 56 | 'Home' => 'Home', |
| 57 | 57 | 'Contacts' => 'Contacts', |
| 58 | 58 | 'Accounts' => 'Accounts', |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | ), |
| 114 | 114 | |
| 115 | 115 | 'moduleListSingular' => |
| 116 | - array ( |
|
| 116 | + array( |
|
| 117 | 117 | 'Home' => 'Home', |
| 118 | 118 | 'Dashboard' => 'Dashboard', |
| 119 | 119 | 'Contacts' => 'Contact', |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | //e.g. en fran�ais 'Analyst'=>'Analyste', |
| 155 | 155 | 'account_type_dom' => |
| 156 | - array ( |
|
| 156 | + array( |
|
| 157 | 157 | '' => '', |
| 158 | 158 | 'Analyst' => 'Analyst', |
| 159 | 159 | 'Competitor' => 'Competitor', |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ), |
| 169 | 169 | //e.g. en espa�ol 'Apparel'=>'Ropa', |
| 170 | 170 | 'industry_dom' => |
| 171 | - array ( |
|
| 171 | + array( |
|
| 172 | 172 | '' => '', |
| 173 | 173 | 'Apparel' => 'Apparel', |
| 174 | 174 | 'Banking' => 'Banking', |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ), |
| 204 | 204 | 'lead_source_default_key' => 'Self Generated', |
| 205 | 205 | 'lead_source_dom' => |
| 206 | - array ( |
|
| 206 | + array( |
|
| 207 | 207 | '' => '', |
| 208 | 208 | 'Cold Call' => 'Cold Call', |
| 209 | 209 | 'Existing Customer' => 'Existing Customer', |
@@ -221,13 +221,13 @@ discard block |
||
| 221 | 221 | 'Other' => 'Other', |
| 222 | 222 | ), |
| 223 | 223 | 'opportunity_type_dom' => |
| 224 | - array ( |
|
| 224 | + array( |
|
| 225 | 225 | '' => '', |
| 226 | 226 | 'Existing Business' => 'Existing Business', |
| 227 | 227 | 'New Business' => 'New Business', |
| 228 | 228 | ), |
| 229 | 229 | 'roi_type_dom' => |
| 230 | - array ( |
|
| 230 | + array( |
|
| 231 | 231 | 'Revenue' => 'Revenue', |
| 232 | 232 | 'Investment'=>'Investment', |
| 233 | 233 | 'Expected_Revenue'=>'Expected Revenue', |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | // it is the key for the default opportunity_relationship_type_dom value |
| 239 | 239 | 'opportunity_relationship_type_default_key' => 'Primary Decision Maker', |
| 240 | 240 | 'opportunity_relationship_type_dom' => |
| 241 | - array ( |
|
| 241 | + array( |
|
| 242 | 242 | '' => '', |
| 243 | 243 | 'Primary Decision Maker' => 'Primary Decision Maker', |
| 244 | 244 | 'Business Decision Maker' => 'Business Decision Maker', |
@@ -253,24 +253,24 @@ discard block |
||
| 253 | 253 | // it is the key for the default case_relationship_type_dom value |
| 254 | 254 | 'case_relationship_type_default_key' => 'Primary Contact', |
| 255 | 255 | 'case_relationship_type_dom' => |
| 256 | - array ( |
|
| 256 | + array( |
|
| 257 | 257 | '' => '', |
| 258 | 258 | 'Primary Contact' => 'Primary Contact', |
| 259 | 259 | 'Alternate Contact' => 'Alternate Contact', |
| 260 | 260 | ), |
| 261 | 261 | 'payment_terms' => |
| 262 | - array ( |
|
| 262 | + array( |
|
| 263 | 263 | '' => '', |
| 264 | 264 | 'Net 15' => 'Net 15', |
| 265 | 265 | 'Net 30' => 'Net 30', |
| 266 | 266 | ), |
| 267 | 267 | 'sales_stage_default_key' => 'Prospecting', |
| 268 | - 'fts_type' => array ( |
|
| 268 | + 'fts_type' => array( |
|
| 269 | 269 | '' => '', |
| 270 | 270 | 'Elastic' => 'elasticsearch' |
| 271 | 271 | ), |
| 272 | 272 | 'sales_stage_dom' => |
| 273 | - array ( |
|
| 273 | + array( |
|
| 274 | 274 | 'Prospecting' => 'Prospecting', |
| 275 | 275 | 'Qualification' => 'Qualification', |
| 276 | 276 | 'Needs Analysis' => 'Needs Analysis', |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | 'Closed Won' => 'Closed Won', |
| 283 | 283 | 'Closed Lost' => 'Closed Lost', |
| 284 | 284 | ), |
| 285 | - 'in_total_group_stages' => array ( |
|
| 285 | + 'in_total_group_stages' => array( |
|
| 286 | 286 | 'Draft' => 'Draft', |
| 287 | 287 | 'Negotiation' => 'Negotiation', |
| 288 | 288 | 'Delivered' => 'Delivered', |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | 'Closed Dead' => 'Closed Dead', |
| 294 | 294 | ), |
| 295 | 295 | 'sales_probability_dom' => // keys must be the same as sales_stage_dom |
| 296 | - array ( |
|
| 296 | + array( |
|
| 297 | 297 | 'Prospecting' => '10', |
| 298 | 298 | 'Qualification' => '20', |
| 299 | 299 | 'Needs Analysis' => '25', |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | 'Closed Lost' => '0', |
| 307 | 307 | ), |
| 308 | 308 | 'activity_dom' => |
| 309 | - array ( |
|
| 309 | + array( |
|
| 310 | 310 | 'Call' => 'Call', |
| 311 | 311 | 'Meeting' => 'Meeting', |
| 312 | 312 | 'Task' => 'Task', |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | 'Note' => 'Note', |
| 315 | 315 | ), |
| 316 | 316 | 'salutation_dom' => |
| 317 | - array ( |
|
| 317 | + array( |
|
| 318 | 318 | '' => '', |
| 319 | 319 | 'Mr.' => 'Mr.', |
| 320 | 320 | 'Ms.' => 'Ms.', |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | ), |
| 325 | 325 | //time is in seconds; the greater the time the longer it takes; |
| 326 | 326 | 'reminder_max_time' => 90000, |
| 327 | - 'reminder_time_options' => array( 60=> '1 minute prior', |
|
| 327 | + 'reminder_time_options' => array(60=> '1 minute prior', |
|
| 328 | 328 | 300=> '5 minutes prior', |
| 329 | 329 | 600=> '10 minutes prior', |
| 330 | 330 | 900=> '15 minutes prior', |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | 'task_priority_default' => 'Medium', |
| 340 | 340 | 'task_priority_dom' => |
| 341 | - array ( |
|
| 341 | + array( |
|
| 342 | 342 | 'High' => 'High', |
| 343 | 343 | 'Medium' => 'Medium', |
| 344 | 344 | 'Low' => 'Low', |
| 345 | 345 | ), |
| 346 | 346 | 'task_status_default' => 'Not Started', |
| 347 | 347 | 'task_status_dom' => |
| 348 | - array ( |
|
| 348 | + array( |
|
| 349 | 349 | 'Not Started' => 'Not Started', |
| 350 | 350 | 'In Progress' => 'In Progress', |
| 351 | 351 | 'Completed' => 'Completed', |
@@ -354,35 +354,35 @@ discard block |
||
| 354 | 354 | ), |
| 355 | 355 | 'meeting_status_default' => 'Planned', |
| 356 | 356 | 'meeting_status_dom' => |
| 357 | - array ( |
|
| 357 | + array( |
|
| 358 | 358 | 'Planned' => 'Planned', |
| 359 | 359 | 'Held' => 'Held', |
| 360 | 360 | 'Not Held' => 'Not Held', |
| 361 | 361 | ), |
| 362 | 362 | 'extapi_meeting_password' => |
| 363 | - array ( |
|
| 363 | + array( |
|
| 364 | 364 | 'WebEx' => 'WebEx', |
| 365 | 365 | ), |
| 366 | 366 | 'meeting_type_dom' => |
| 367 | - array ( |
|
| 367 | + array( |
|
| 368 | 368 | 'Other' => 'Other', |
| 369 | 369 | 'Sugar' => 'SuiteCRM', |
| 370 | 370 | ), |
| 371 | 371 | 'call_status_default' => 'Planned', |
| 372 | 372 | 'call_status_dom' => |
| 373 | - array ( |
|
| 373 | + array( |
|
| 374 | 374 | 'Planned' => 'Planned', |
| 375 | 375 | 'Held' => 'Held', |
| 376 | 376 | 'Not Held' => 'Not Held', |
| 377 | 377 | ), |
| 378 | 378 | 'call_direction_default' => 'Outbound', |
| 379 | 379 | 'call_direction_dom' => |
| 380 | - array ( |
|
| 380 | + array( |
|
| 381 | 381 | 'Inbound' => 'Inbound', |
| 382 | 382 | 'Outbound' => 'Outbound', |
| 383 | 383 | ), |
| 384 | 384 | 'lead_status_dom' => |
| 385 | - array ( |
|
| 385 | + array( |
|
| 386 | 386 | '' => '', |
| 387 | 387 | 'New' => 'New', |
| 388 | 388 | 'Assigned' => 'Assigned', |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | 'Dead' => 'Dead', |
| 393 | 393 | ), |
| 394 | 394 | 'gender_list' => |
| 395 | - array ( |
|
| 395 | + array( |
|
| 396 | 396 | 'male' => 'Male', |
| 397 | 397 | 'female' => 'Female', |
| 398 | 398 | ), |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | // it is the key for the default case_status_dom value |
| 401 | 401 | 'case_status_default_key' => 'New', |
| 402 | 402 | 'case_status_dom' => |
| 403 | - array ( |
|
| 403 | + array( |
|
| 404 | 404 | 'New' => 'New', |
| 405 | 405 | 'Assigned' => 'Assigned', |
| 406 | 406 | 'Closed' => 'Closed', |
@@ -410,49 +410,49 @@ discard block |
||
| 410 | 410 | ), |
| 411 | 411 | 'case_priority_default_key' => 'P2', |
| 412 | 412 | 'case_priority_dom' => |
| 413 | - array ( |
|
| 413 | + array( |
|
| 414 | 414 | 'P1' => 'High', |
| 415 | 415 | 'P2' => 'Medium', |
| 416 | 416 | 'P3' => 'Low', |
| 417 | 417 | ), |
| 418 | 418 | 'user_type_dom' => |
| 419 | - array ( |
|
| 419 | + array( |
|
| 420 | 420 | 'RegularUser' => 'Regular User', |
| 421 | 421 | 'Administrator' => 'Administrator', |
| 422 | 422 | ), |
| 423 | 423 | 'user_status_dom' => |
| 424 | - array ( |
|
| 424 | + array( |
|
| 425 | 425 | 'Active' => 'Active', |
| 426 | 426 | 'Inactive' => 'Inactive', |
| 427 | 427 | ), |
| 428 | 428 | 'employee_status_dom' => |
| 429 | - array ( |
|
| 429 | + array( |
|
| 430 | 430 | 'Active' => 'Active', |
| 431 | 431 | 'Terminated' => 'Terminated', |
| 432 | 432 | 'Leave of Absence' => 'Leave of Absence', |
| 433 | 433 | ), |
| 434 | 434 | 'messenger_type_dom' => |
| 435 | - array ( |
|
| 435 | + array( |
|
| 436 | 436 | '' => '', |
| 437 | 437 | 'MSN' => 'MSN', |
| 438 | 438 | 'Yahoo!' => 'Yahoo!', |
| 439 | 439 | 'AOL' => 'AOL', |
| 440 | 440 | ), |
| 441 | - 'project_task_priority_options' => array ( |
|
| 441 | + 'project_task_priority_options' => array( |
|
| 442 | 442 | 'High' => 'High', |
| 443 | 443 | 'Medium' => 'Medium', |
| 444 | 444 | 'Low' => 'Low', |
| 445 | 445 | ), |
| 446 | 446 | 'project_task_priority_default' => 'Medium', |
| 447 | 447 | |
| 448 | - 'project_task_status_options' => array ( |
|
| 448 | + 'project_task_status_options' => array( |
|
| 449 | 449 | 'Not Started' => 'Not Started', |
| 450 | 450 | 'In Progress' => 'In Progress', |
| 451 | 451 | 'Completed' => 'Completed', |
| 452 | 452 | 'Pending Input' => 'Pending Input', |
| 453 | 453 | 'Deferred' => 'Deferred', |
| 454 | 454 | ), |
| 455 | - 'project_task_utilization_options' => array ( |
|
| 455 | + 'project_task_utilization_options' => array( |
|
| 456 | 456 | '0' => 'none', |
| 457 | 457 | '25' => '25', |
| 458 | 458 | '50' => '50', |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | '100' => '100', |
| 461 | 461 | ), |
| 462 | 462 | |
| 463 | - 'project_status_dom' => array ( |
|
| 463 | + 'project_status_dom' => array( |
|
| 464 | 464 | 'Draft' => 'Draft', |
| 465 | 465 | 'In Review' => 'In Review', |
| 466 | 466 | 'Underway' => 'Underway', |
@@ -469,12 +469,12 @@ discard block |
||
| 469 | 469 | ), |
| 470 | 470 | 'project_status_default' => 'Draft', |
| 471 | 471 | |
| 472 | - 'project_duration_units_dom' => array ( |
|
| 472 | + 'project_duration_units_dom' => array( |
|
| 473 | 473 | 'Days' => 'Days', |
| 474 | 474 | 'Hours' => 'Hours', |
| 475 | 475 | ), |
| 476 | 476 | |
| 477 | - 'project_priority_options' => array ( |
|
| 477 | + 'project_priority_options' => array( |
|
| 478 | 478 | 'High' => 'High', |
| 479 | 479 | 'Medium' => 'Medium', |
| 480 | 480 | 'Low' => 'Low', |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | // it is the key for the default record_type_module value |
| 485 | 485 | 'record_type_default_key' => 'Accounts', |
| 486 | 486 | 'record_type_display' => |
| 487 | - array ( |
|
| 487 | + array( |
|
| 488 | 488 | '' => '', |
| 489 | 489 | 'Accounts' => 'Account', |
| 490 | 490 | 'Opportunities' => 'Opportunity', |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | ), |
| 506 | 506 | |
| 507 | 507 | 'record_type_display_notes' => |
| 508 | - array ( |
|
| 508 | + array( |
|
| 509 | 509 | 'Accounts' => 'Account', |
| 510 | 510 | 'Contacts' => 'Contact', |
| 511 | 511 | 'Opportunities' => 'Opportunity', |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | ), |
| 525 | 525 | |
| 526 | 526 | 'parent_type_display' => |
| 527 | - array ( |
|
| 527 | + array( |
|
| 528 | 528 | 'Accounts' => 'Account', |
| 529 | 529 | 'Contacts' => 'Contact', |
| 530 | 530 | 'Tasks' => 'Task', |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | 'issue_priority_default_key' => 'Medium', |
| 547 | 547 | 'issue_priority_dom' => |
| 548 | - array ( |
|
| 548 | + array( |
|
| 549 | 549 | 'Urgent' => 'Urgent', |
| 550 | 550 | 'High' => 'High', |
| 551 | 551 | 'Medium' => 'Medium', |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | ), |
| 554 | 554 | 'issue_resolution_default_key' => '', |
| 555 | 555 | 'issue_resolution_dom' => |
| 556 | - array ( |
|
| 556 | + array( |
|
| 557 | 557 | '' => '', |
| 558 | 558 | 'Accepted' => 'Accepted', |
| 559 | 559 | 'Duplicate' => 'Duplicate', |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | 'issue_status_default_key' => 'New', |
| 566 | 566 | 'issue_status_dom' => |
| 567 | - array ( |
|
| 567 | + array( |
|
| 568 | 568 | 'New' => 'New', |
| 569 | 569 | 'Assigned' => 'Assigned', |
| 570 | 570 | 'Closed' => 'Closed', |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | 'bug_priority_default_key' => 'Medium', |
| 576 | 576 | 'bug_priority_dom' => |
| 577 | - array ( |
|
| 577 | + array( |
|
| 578 | 578 | 'Urgent' => 'Urgent', |
| 579 | 579 | 'High' => 'High', |
| 580 | 580 | 'Medium' => 'Medium', |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | ), |
| 583 | 583 | 'bug_resolution_default_key' => '', |
| 584 | 584 | 'bug_resolution_dom' => |
| 585 | - array ( |
|
| 585 | + array( |
|
| 586 | 586 | '' => '', |
| 587 | 587 | 'Accepted' => 'Accepted', |
| 588 | 588 | 'Duplicate' => 'Duplicate', |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | ), |
| 594 | 594 | 'bug_status_default_key' => 'New', |
| 595 | 595 | 'bug_status_dom' => |
| 596 | - array ( |
|
| 596 | + array( |
|
| 597 | 597 | 'New' => 'New', |
| 598 | 598 | 'Assigned' => 'Assigned', |
| 599 | 599 | 'Closed' => 'Closed', |
@@ -602,12 +602,12 @@ discard block |
||
| 602 | 602 | ), |
| 603 | 603 | 'bug_type_default_key' => 'Bug', |
| 604 | 604 | 'bug_type_dom' => |
| 605 | - array ( |
|
| 605 | + array( |
|
| 606 | 606 | 'Defect' => 'Defect', |
| 607 | 607 | 'Feature' => 'Feature', |
| 608 | 608 | ), |
| 609 | 609 | 'case_type_dom' => |
| 610 | - array ( |
|
| 610 | + array( |
|
| 611 | 611 | 'Administration' => 'Administration', |
| 612 | 612 | 'Product' => 'Product', |
| 613 | 613 | 'User' => 'User', |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | |
| 616 | 616 | 'source_default_key' => '', |
| 617 | 617 | 'source_dom' => |
| 618 | - array ( |
|
| 618 | + array( |
|
| 619 | 619 | '' => '', |
| 620 | 620 | 'Internal' => 'Internal', |
| 621 | 621 | 'Forum' => 'Forum', |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | 'product_category_default_key' => '', |
| 627 | 627 | 'product_category_dom' => |
| 628 | - array ( |
|
| 628 | + array( |
|
| 629 | 629 | '' => '', |
| 630 | 630 | 'Accounts' => 'Accounts', |
| 631 | 631 | 'Activities' => 'Activities', |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | ), |
| 659 | 659 | /*Added entries 'Queued' and 'Sending' for 4.0 release..*/ |
| 660 | 660 | 'campaign_status_dom' => |
| 661 | - array ( |
|
| 661 | + array( |
|
| 662 | 662 | '' => '', |
| 663 | 663 | 'Planning' => 'Planning', |
| 664 | 664 | 'Active' => 'Active', |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | 'Sending'=> 'Sending', |
| 669 | 669 | ), |
| 670 | 670 | 'campaign_type_dom' => |
| 671 | - array ( |
|
| 671 | + array( |
|
| 672 | 672 | '' => '', |
| 673 | 673 | 'Telesales' => 'Telesales', |
| 674 | 674 | 'Mail' => 'Mail', |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | ), |
| 682 | 682 | |
| 683 | 683 | 'newsletter_frequency_dom' => |
| 684 | - array ( |
|
| 684 | + array( |
|
| 685 | 685 | '' => '', |
| 686 | 686 | 'Weekly' => 'Weekly', |
| 687 | 687 | 'Monthly' => 'Monthly', |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | ), |
| 691 | 691 | |
| 692 | 692 | 'notifymail_sendtype' => |
| 693 | - array ( |
|
| 693 | + array( |
|
| 694 | 694 | 'SMTP' => 'SMTP', |
| 695 | 695 | ), |
| 696 | 696 | 'dom_cal_month_long'=>array( |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | 'inbound' => 'Inbound', |
| 768 | 768 | 'campaign' => 'Campaign' |
| 769 | 769 | ), |
| 770 | - 'dom_email_status' => array ( |
|
| 770 | + 'dom_email_status' => array( |
|
| 771 | 771 | 'archived' => 'Archived', |
| 772 | 772 | 'closed' => 'Closed', |
| 773 | 773 | 'draft' => 'In Draft', |
@@ -777,11 +777,11 @@ discard block |
||
| 777 | 777 | 'send_error'=> 'Send Error', |
| 778 | 778 | 'unread' => 'Unread', |
| 779 | 779 | ), |
| 780 | - 'dom_email_archived_status' => array ( |
|
| 780 | + 'dom_email_archived_status' => array( |
|
| 781 | 781 | 'archived' => 'Archived', |
| 782 | 782 | ), |
| 783 | 783 | |
| 784 | - 'dom_email_server_type' => array( '' => '--None--', |
|
| 784 | + 'dom_email_server_type' => array('' => '--None--', |
|
| 785 | 785 | 'imap' => 'IMAP', |
| 786 | 786 | ), |
| 787 | 787 | 'dom_mailbox_type' => array(/*'' => '--None Specified--',*/ |
@@ -806,19 +806,19 @@ discard block |
||
| 806 | 806 | 'dom_int_bool' => array(1 => 'Yes', |
| 807 | 807 | 0 => 'No', |
| 808 | 808 | ), |
| 809 | - 'dom_switch_bool' => array ('on' => 'Yes', |
|
| 809 | + 'dom_switch_bool' => array('on' => 'Yes', |
|
| 810 | 810 | 'off' => 'No', |
| 811 | - '' => 'No', ), |
|
| 811 | + '' => 'No',), |
|
| 812 | 812 | |
| 813 | - 'dom_email_link_type' => array( 'sugar' => 'SuiteCRM Email Client', |
|
| 813 | + 'dom_email_link_type' => array('sugar' => 'SuiteCRM Email Client', |
|
| 814 | 814 | 'mailto' => 'External Email Client'), |
| 815 | 815 | |
| 816 | 816 | |
| 817 | - 'dom_email_editor_option'=> array( '' => 'Default Email Format', |
|
| 817 | + 'dom_email_editor_option'=> array('' => 'Default Email Format', |
|
| 818 | 818 | 'html' => 'HTML Email', |
| 819 | 819 | 'plain' => 'Plain Text Email'), |
| 820 | 820 | |
| 821 | - 'schedulers_times_dom' => array( 'not run' => 'Past Run Time, Not Executed', |
|
| 821 | + 'schedulers_times_dom' => array('not run' => 'Past Run Time, Not Executed', |
|
| 822 | 822 | 'ready' => 'Ready', |
| 823 | 823 | 'in progress' => 'In Progress', |
| 824 | 824 | 'failed' => 'Failed', |
@@ -827,28 +827,28 @@ discard block |
||
| 827 | 827 | ), |
| 828 | 828 | |
| 829 | 829 | 'scheduler_status_dom' => |
| 830 | - array ( |
|
| 830 | + array( |
|
| 831 | 831 | 'Active' => 'Active', |
| 832 | 832 | 'Inactive' => 'Inactive', |
| 833 | 833 | ), |
| 834 | 834 | |
| 835 | 835 | 'scheduler_period_dom' => |
| 836 | - array ( |
|
| 836 | + array( |
|
| 837 | 837 | 'min' => 'Minutes', |
| 838 | 838 | 'hour' => 'Hours', |
| 839 | 839 | ), |
| 840 | 840 | 'forecast_schedule_status_dom' => |
| 841 | - array ( |
|
| 841 | + array( |
|
| 842 | 842 | 'Active' => 'Active', |
| 843 | 843 | 'Inactive' => 'Inactive', |
| 844 | 844 | ), |
| 845 | 845 | 'forecast_type_dom' => |
| 846 | - array ( |
|
| 846 | + array( |
|
| 847 | 847 | 'Direct' => 'Direct', |
| 848 | 848 | 'Rollup' => 'Rollup', |
| 849 | 849 | ), |
| 850 | 850 | 'document_category_dom' => |
| 851 | - array ( |
|
| 851 | + array( |
|
| 852 | 852 | '' => '', |
| 853 | 853 | 'Marketing' => 'Marketing', |
| 854 | 854 | 'Knowledege Base' => 'Knowledge Base', |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | ), |
| 857 | 857 | |
| 858 | 858 | 'document_subcategory_dom' => |
| 859 | - array ( |
|
| 859 | + array( |
|
| 860 | 860 | '' => '', |
| 861 | 861 | 'Marketing Collateral' => 'Marketing Collateral', |
| 862 | 862 | 'Product Brochures' => 'Product Brochures', |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | ), |
| 865 | 865 | |
| 866 | 866 | 'document_status_dom' => |
| 867 | - array ( |
|
| 867 | + array( |
|
| 868 | 868 | 'Active' => 'Active', |
| 869 | 869 | 'Draft' => 'Draft', |
| 870 | 870 | 'FAQ' => 'FAQ', |
@@ -881,13 +881,13 @@ discard block |
||
| 881 | 881 | 'license'=>'License Agreement', |
| 882 | 882 | ), |
| 883 | 883 | 'dom_meeting_accept_options' => |
| 884 | - array ( |
|
| 884 | + array( |
|
| 885 | 885 | 'accept' => 'Accept', |
| 886 | 886 | 'decline' => 'Decline', |
| 887 | 887 | 'tentative' => 'Tentative', |
| 888 | 888 | ), |
| 889 | 889 | 'dom_meeting_accept_status' => |
| 890 | - array ( |
|
| 890 | + array( |
|
| 891 | 891 | 'accept' => 'Accepted', |
| 892 | 892 | 'decline' => 'Declined', |
| 893 | 893 | 'tentative' => 'Tentative', |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | */ |
| 940 | 940 | //prospect list type dom |
| 941 | 941 | 'prospect_list_type_dom' => |
| 942 | - array ( |
|
| 942 | + array( |
|
| 943 | 943 | 'default' => 'Default', |
| 944 | 944 | 'seed' => 'Seed', |
| 945 | 945 | 'exempt_domain' => 'Suppression List - By Domain', |
@@ -955,14 +955,14 @@ discard block |
||
| 955 | 955 | '50' => '50' |
| 956 | 956 | ), |
| 957 | 957 | 'email_marketing_status_dom' => |
| 958 | - array ( |
|
| 958 | + array( |
|
| 959 | 959 | '' => '', |
| 960 | 960 | 'active'=>'Active', |
| 961 | 961 | 'inactive'=>'Inactive' |
| 962 | 962 | ), |
| 963 | 963 | |
| 964 | 964 | 'campainglog_activity_type_dom' => |
| 965 | - array ( |
|
| 965 | + array( |
|
| 966 | 966 | ''=>'', |
| 967 | 967 | 'targeted' => 'Message Sent/Attempted', |
| 968 | 968 | 'send error'=>'Bounced Messages,Other', |
@@ -976,33 +976,33 @@ discard block |
||
| 976 | 976 | ), |
| 977 | 977 | |
| 978 | 978 | 'campainglog_target_type_dom' => |
| 979 | - array ( |
|
| 979 | + array( |
|
| 980 | 980 | 'Contacts' => 'Contacts', |
| 981 | 981 | 'Users'=>'Users', |
| 982 | 982 | 'Prospects'=>'Targets', |
| 983 | 983 | 'Leads'=>'Leads', |
| 984 | 984 | 'Accounts'=>'Accounts', |
| 985 | 985 | ), |
| 986 | - 'merge_operators_dom' => array ( |
|
| 986 | + 'merge_operators_dom' => array( |
|
| 987 | 987 | 'like'=>'Contains', |
| 988 | 988 | 'exact'=>'Exactly', |
| 989 | 989 | 'start'=>'Starts With', |
| 990 | 990 | ), |
| 991 | 991 | |
| 992 | - 'custom_fields_importable_dom' => array ( |
|
| 992 | + 'custom_fields_importable_dom' => array( |
|
| 993 | 993 | 'true'=>'Yes', |
| 994 | 994 | 'false'=>'No', |
| 995 | 995 | 'required'=>'Required', |
| 996 | 996 | ), |
| 997 | 997 | |
| 998 | - 'Elastic_boost_options' => array ( |
|
| 998 | + 'Elastic_boost_options' => array( |
|
| 999 | 999 | '0' =>'Disabled', |
| 1000 | 1000 | '1'=>'Low Boost', |
| 1001 | 1001 | '2'=>'Medium Boost', |
| 1002 | 1002 | '3'=>'High Boost', |
| 1003 | 1003 | ), |
| 1004 | 1004 | |
| 1005 | - 'custom_fields_merge_dup_dom'=> array ( |
|
| 1005 | + 'custom_fields_merge_dup_dom'=> array( |
|
| 1006 | 1006 | 0=>'Disabled', |
| 1007 | 1007 | 1=>'Enabled', |
| 1008 | 1008 | ), |
@@ -1013,19 +1013,19 @@ discard block |
||
| 1013 | 1013 | ), |
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | - 'projects_priority_options' => array ( |
|
| 1016 | + 'projects_priority_options' => array( |
|
| 1017 | 1017 | 'high' => 'High', |
| 1018 | 1018 | 'medium' => 'Medium', |
| 1019 | 1019 | 'low' => 'Low', |
| 1020 | 1020 | ), |
| 1021 | 1021 | |
| 1022 | - 'projects_status_options' => array ( |
|
| 1022 | + 'projects_status_options' => array( |
|
| 1023 | 1023 | 'notstarted' => 'Not Started', |
| 1024 | 1024 | 'inprogress' => 'In Progress', |
| 1025 | 1025 | 'completed' => 'Completed', |
| 1026 | 1026 | ), |
| 1027 | 1027 | // strings to pass to Flash charts |
| 1028 | - 'chart_strings' => array ( |
|
| 1028 | + 'chart_strings' => array( |
|
| 1029 | 1029 | 'expandlegend' => 'Expand Legend', |
| 1030 | 1030 | 'collapselegend' => 'Collapse Legend', |
| 1031 | 1031 | 'clickfordrilldown' => 'Click for Drilldown', |
@@ -1042,25 +1042,25 @@ discard block |
||
| 1042 | 1042 | 'pieWedgeName' => 'sections', |
| 1043 | 1043 | ), |
| 1044 | 1044 | 'release_status_dom' => |
| 1045 | - array ( |
|
| 1045 | + array( |
|
| 1046 | 1046 | 'Active' => 'Active', |
| 1047 | 1047 | 'Inactive' => 'Inactive', |
| 1048 | 1048 | ), |
| 1049 | 1049 | 'email_settings_for_ssl' => |
| 1050 | - array ( |
|
| 1050 | + array( |
|
| 1051 | 1051 | '0' => '', |
| 1052 | 1052 | '1' => 'SSL', |
| 1053 | 1053 | '2' => 'TLS', |
| 1054 | 1054 | ), |
| 1055 | 1055 | 'import_enclosure_options' => |
| 1056 | - array ( |
|
| 1056 | + array( |
|
| 1057 | 1057 | '\'' => 'Single Quote (\')', |
| 1058 | 1058 | '"' => 'Double Quote (")', |
| 1059 | 1059 | '' => 'None', |
| 1060 | 1060 | 'other' => 'Other:', |
| 1061 | 1061 | ), |
| 1062 | 1062 | 'import_delimeter_options' => |
| 1063 | - array ( |
|
| 1063 | + array( |
|
| 1064 | 1064 | ',' => ',', |
| 1065 | 1065 | ';' => ';', |
| 1066 | 1066 | '\t' => '\t', |
@@ -1070,12 +1070,12 @@ discard block |
||
| 1070 | 1070 | 'other' => 'Other:', |
| 1071 | 1071 | ), |
| 1072 | 1072 | 'link_target_dom' => |
| 1073 | - array ( |
|
| 1073 | + array( |
|
| 1074 | 1074 | '_blank' => 'New Window', |
| 1075 | 1075 | '_self' => 'Same Window', |
| 1076 | 1076 | ), |
| 1077 | 1077 | 'dashlet_auto_refresh_options' => |
| 1078 | - array ( |
|
| 1078 | + array( |
|
| 1079 | 1079 | '-1' => 'Do not auto-refresh', |
| 1080 | 1080 | '30' => 'Every 30 seconds', |
| 1081 | 1081 | '60' => 'Every 1 minute', |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | '600' => 'Every 10 minutes', |
| 1085 | 1085 | ), |
| 1086 | 1086 | 'dashlet_auto_refresh_options_admin' => |
| 1087 | - array ( |
|
| 1087 | + array( |
|
| 1088 | 1088 | '-1' => 'Never', |
| 1089 | 1089 | '30' => 'Every 30 seconds', |
| 1090 | 1090 | '60' => 'Every 1 minute', |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | ), |
| 1129 | 1129 | ); |
| 1130 | 1130 | |
| 1131 | -$app_strings = array ( |
|
| 1131 | +$app_strings = array( |
|
| 1132 | 1132 | 'LBL_TOUR_NEXT' => 'Next', |
| 1133 | 1133 | 'LBL_TOUR_SKIP' => 'Skip', |
| 1134 | 1134 | 'LBL_TOUR_BACK' => 'Back', |
@@ -2255,7 +2255,7 @@ discard block |
||
| 2255 | 2255 | 'LBL_COPY_ADDRESS_FROM_LEFT' => 'Copy address from left:', |
| 2256 | 2256 | 'LBL_SAVE_AND_CONTINUE' => 'Save and Continue', |
| 2257 | 2257 | |
| 2258 | - 'LBL_SEARCH_HELP_TEXT' => '<p><br /><strong>Multiselect controls</strong></p><ul><li>Click on the values to select an attribute.</li><li>Ctrl-click to select multiple. Mac users use CMD-click.</li><li>To select all values between two attributes, click first value and then shift-click last value.</li></ul><p><strong>Advanced Search & Layout Options</strong><br><br>Using the <b>Saved Search & Layout</b> option, you can save a set of search parameters and/or a custom List View layout in order to quickly obtain the desired search results in the future. You can save an unlimited number of custom searches and layouts. All saved searches appear by name in the Saved Searches list, with the last loaded saved search appearing at the top of the list.<br><br>To customize the List View layout, use the Hide Columns and Display Columns boxes to select which fields to display in the search results. For example, you can view or hide details such as the record name, and assigned user, and assigned team in the search results. To add a column to List View, select the field from the Hide Columns list and use the left arrow to move it to the Display Columns list. To remove a column from List View, select it from the Display Columns list and use the right arrow to move it to the Hide Columns list.<br><br>If you save layout settings, you will be able to load them at any time to view the search results in the custom layout.<br><br>To save and update a search and/or layout:<ol><li>Enter a name for the search results in the <b>Save this search as</b> field and click <b>Save</b>.The name now displays in the Saved Searches list adjacent to the <b>Clear</b> button.</li><li>To view a saved search, select it from the Saved Searches list. The search results are displayed in the List View.</li><li>To update the properties of a saved search, select the saved search from the list, enter the new search criteria and/or layout options in the Advanced Search area, and click <b>Update</b> next to <b>Modify Current Search</b>.</li><li>To delete a saved search, select it in the Saved Searches list, click <b>Delete</b> next to <b>Modify Current Search</b>, and then click <b>OK</b> to confirm the deletion.</li></ol><p><strong>Tips</strong><br><br>By using the % as a wildcard operator you can make your search more broad. For example instead of just searching for results that equal "Apples" you could change your search to "Apples%" which would match all results that start with the word Apples but could contain other characters as well.</p>' , |
|
| 2258 | + 'LBL_SEARCH_HELP_TEXT' => '<p><br /><strong>Multiselect controls</strong></p><ul><li>Click on the values to select an attribute.</li><li>Ctrl-click to select multiple. Mac users use CMD-click.</li><li>To select all values between two attributes, click first value and then shift-click last value.</li></ul><p><strong>Advanced Search & Layout Options</strong><br><br>Using the <b>Saved Search & Layout</b> option, you can save a set of search parameters and/or a custom List View layout in order to quickly obtain the desired search results in the future. You can save an unlimited number of custom searches and layouts. All saved searches appear by name in the Saved Searches list, with the last loaded saved search appearing at the top of the list.<br><br>To customize the List View layout, use the Hide Columns and Display Columns boxes to select which fields to display in the search results. For example, you can view or hide details such as the record name, and assigned user, and assigned team in the search results. To add a column to List View, select the field from the Hide Columns list and use the left arrow to move it to the Display Columns list. To remove a column from List View, select it from the Display Columns list and use the right arrow to move it to the Hide Columns list.<br><br>If you save layout settings, you will be able to load them at any time to view the search results in the custom layout.<br><br>To save and update a search and/or layout:<ol><li>Enter a name for the search results in the <b>Save this search as</b> field and click <b>Save</b>.The name now displays in the Saved Searches list adjacent to the <b>Clear</b> button.</li><li>To view a saved search, select it from the Saved Searches list. The search results are displayed in the List View.</li><li>To update the properties of a saved search, select the saved search from the list, enter the new search criteria and/or layout options in the Advanced Search area, and click <b>Update</b> next to <b>Modify Current Search</b>.</li><li>To delete a saved search, select it in the Saved Searches list, click <b>Delete</b> next to <b>Modify Current Search</b>, and then click <b>OK</b> to confirm the deletion.</li></ol><p><strong>Tips</strong><br><br>By using the % as a wildcard operator you can make your search more broad. For example instead of just searching for results that equal "Apples" you could change your search to "Apples%" which would match all results that start with the word Apples but could contain other characters as well.</p>', |
|
| 2259 | 2259 | |
| 2260 | 2260 | //resource management |
| 2261 | 2261 | 'ERR_QUERY_LIMIT' => 'Error: Query limit of $limit reached for $module module.', |
@@ -2496,7 +2496,7 @@ discard block |
||
| 2496 | 2496 | 'LBL_FIRST_INPUT_SEARCH_KEY' => '9', |
| 2497 | 2497 | 'LBL_GLOBAL_SEARCH_LNK_KEY' => '0', |
| 2498 | 2498 | 'LBL_KEYBOARD_SHORTCUTS_HELP_TITLE' => 'Keyboard Shortcuts', |
| 2499 | - 'LBL_KEYBOARD_SHORTCUTS_HELP' => '<p><strong>Form Functionality - Alt+</strong><br/> I = ed<b>I</b>t (detailview)<br/> U = d<b>U</b>plicate (detailview)<br/> D = <b>D</b>elete (detailview)<br/> A = s<b>A</b>ve (editview)<br/> L = cance<b>L</b> (editview) <br/><br/></p><p><strong>Search and Navigation - Alt+</strong><br/> 7 = first input on Edit form<br/> 8 = Advanced Search link<br/> 9 = First Search Form input<br/> 0 = Unified search input<br></p>' , |
|
| 2499 | + 'LBL_KEYBOARD_SHORTCUTS_HELP' => '<p><strong>Form Functionality - Alt+</strong><br/> I = ed<b>I</b>t (detailview)<br/> U = d<b>U</b>plicate (detailview)<br/> D = <b>D</b>elete (detailview)<br/> A = s<b>A</b>ve (editview)<br/> L = cance<b>L</b> (editview) <br/><br/></p><p><strong>Search and Navigation - Alt+</strong><br/> 7 = first input on Edit form<br/> 8 = Advanced Search link<br/> 9 = First Search Form input<br/> 0 = Unified search input<br></p>', |
|
| 2500 | 2500 | |
| 2501 | 2501 | 'ERR_CONNECTOR_NOT_ARRAY' => 'connector array in {0} been defined incorrectly or is empty and could not be used.', |
| 2502 | 2502 | 'ERR_SUHOSIN' => 'Upload stream is blocked by Suhosin, please add "upload" to suhosin.executor.include.whitelist (See suitecrm.log for more information)', |
@@ -2521,13 +2521,13 @@ discard block |
||
| 2521 | 2521 | $app_list_strings['library_type'] = array('Books'=>'Book', 'Music'=>'Music', 'DVD'=>'DVD', 'Magazines'=>'Magazines'); |
| 2522 | 2522 | $app_list_strings['moduleList']['EmailAddresses'] = 'Email Address'; |
| 2523 | 2523 | $app_list_strings['project_priority_default'] = 'Medium'; |
| 2524 | -$app_list_strings['project_priority_options'] = array ( |
|
| 2524 | +$app_list_strings['project_priority_options'] = array( |
|
| 2525 | 2525 | 'High' => 'High', |
| 2526 | 2526 | 'Medium' => 'Medium', |
| 2527 | 2527 | 'Low' => 'Low', |
| 2528 | 2528 | ); |
| 2529 | 2529 | |
| 2530 | -$app_list_strings['kbdocument_status_dom'] = array ( |
|
| 2530 | +$app_list_strings['kbdocument_status_dom'] = array( |
|
| 2531 | 2531 | 'Draft' => 'Draft', |
| 2532 | 2532 | 'Expired' => 'Expired', |
| 2533 | 2533 | 'In Review' => 'In Review', |
@@ -2535,7 +2535,7 @@ discard block |
||
| 2535 | 2535 | ); |
| 2536 | 2536 | |
| 2537 | 2537 | $app_list_strings['kbadmin_actions_dom'] = |
| 2538 | - array ( |
|
| 2538 | + array( |
|
| 2539 | 2539 | '' => '--Admin Actions--', |
| 2540 | 2540 | 'Create New Tag' => 'Create New Tag', |
| 2541 | 2541 | 'Delete Tag'=>'Delete Tag', |
@@ -3106,26 +3106,26 @@ discard block |
||
| 3106 | 3106 | 'Asia/Magadan' => 'Asia/Magadan', |
| 3107 | 3107 | 'Asia/Kamchatka' => 'Asia/Kamchatka', |
| 3108 | 3108 | 'Asia/Anadyr' => 'Asia/Anadyr', |
| 3109 | - 'Europe/Belgrade' => 'Europe/Belgrade' , |
|
| 3110 | - 'Europe/Madrid' =>'Europe/Madrid' , |
|
| 3109 | + 'Europe/Belgrade' => 'Europe/Belgrade', |
|
| 3110 | + 'Europe/Madrid' =>'Europe/Madrid', |
|
| 3111 | 3111 | 'Africa/Ceuta' => 'Africa/Ceuta', |
| 3112 | 3112 | 'Atlantic/Canary' => 'Atlantic/Canary', |
| 3113 | 3113 | 'Europe/Stockholm' => 'Europe/Stockholm', |
| 3114 | - 'Europe/Zurich' => 'Europe/Zurich' , |
|
| 3114 | + 'Europe/Zurich' => 'Europe/Zurich', |
|
| 3115 | 3115 | 'Europe/Istanbul' => 'Europe/Istanbul', |
| 3116 | 3116 | 'Europe/Kiev' => 'Europe/Kiev', |
| 3117 | 3117 | 'Europe/Uzhgorod' => 'Europe/Uzhgorod', |
| 3118 | 3118 | 'Europe/Zaporozhye' => 'Europe/Zaporozhye', |
| 3119 | 3119 | 'Europe/Simferopol' => 'Europe/Simferopol', |
| 3120 | 3120 | 'America/New_York' => 'America/New York', |
| 3121 | - 'America/Chicago' =>'America/Chicago' , |
|
| 3121 | + 'America/Chicago' =>'America/Chicago', |
|
| 3122 | 3122 | 'America/North_Dakota/Center' => 'America/North Dakota/Center', |
| 3123 | 3123 | 'America/Denver' => 'America/Denver', |
| 3124 | 3124 | 'America/Los_Angeles' => 'America/Los Angeles', |
| 3125 | 3125 | 'America/Juneau' => 'America/Juneau', |
| 3126 | 3126 | 'America/Yakutat' => 'America/Yakutat', |
| 3127 | 3127 | 'America/Anchorage' => 'America/Anchorage', |
| 3128 | - 'America/Nome' =>'America/Nome' , |
|
| 3128 | + 'America/Nome' =>'America/Nome', |
|
| 3129 | 3129 | 'America/Adak' => 'America/Adak', |
| 3130 | 3130 | 'Pacific/Honolulu' => 'Pacific/Honolulu', |
| 3131 | 3131 | 'America/Phoenix' => 'America/Phoenix', |
@@ -3134,17 +3134,17 @@ discard block |
||
| 3134 | 3134 | 'America/Indiana/Marengo' => 'America/Indiana/Marengo', |
| 3135 | 3135 | 'America/Indiana/Knox' => 'America/Indiana/Knox', |
| 3136 | 3136 | 'America/Indiana/Vevay' => 'America/Indiana/Vevay', |
| 3137 | - 'America/Kentucky/Louisville' =>'America/Kentucky/Louisville' , |
|
| 3138 | - 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello' , |
|
| 3137 | + 'America/Kentucky/Louisville' =>'America/Kentucky/Louisville', |
|
| 3138 | + 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello', |
|
| 3139 | 3139 | 'America/Detroit' => 'America/Detroit', |
| 3140 | 3140 | 'America/Menominee' => 'America/Menominee', |
| 3141 | 3141 | 'America/St_Johns' => 'America/St. Johns', |
| 3142 | - 'America/Goose_Bay' => 'America/Goose_Bay' , |
|
| 3142 | + 'America/Goose_Bay' => 'America/Goose_Bay', |
|
| 3143 | 3143 | 'America/Halifax' => 'America/Halifax', |
| 3144 | - 'America/Glace_Bay' =>'America/Glace Bay' , |
|
| 3144 | + 'America/Glace_Bay' =>'America/Glace Bay', |
|
| 3145 | 3145 | 'America/Montreal' => 'America/Montreal', |
| 3146 | 3146 | 'America/Toronto' => 'America/Toronto', |
| 3147 | - 'America/Thunder_Bay' => 'America/Thunder Bay' , |
|
| 3147 | + 'America/Thunder_Bay' => 'America/Thunder Bay', |
|
| 3148 | 3148 | 'America/Nipigon' => 'America/Nipigon', |
| 3149 | 3149 | 'America/Rainy_River' => 'America/Rainy River', |
| 3150 | 3150 | 'America/Winnipeg' => 'America/Winnipeg', |
@@ -3153,14 +3153,14 @@ discard block |
||
| 3153 | 3153 | 'America/Edmonton' => 'America/Edmonton', |
| 3154 | 3154 | 'America/Vancouver' => 'America/Vancouver', |
| 3155 | 3155 | 'America/Dawson_Creek' => 'America/Dawson Creek', |
| 3156 | - 'America/Pangnirtung' => 'America/Pangnirtung' , |
|
| 3157 | - 'America/Iqaluit' => 'America/Iqaluit' , |
|
| 3158 | - 'America/Coral_Harbour' => 'America/Coral Harbour' , |
|
| 3156 | + 'America/Pangnirtung' => 'America/Pangnirtung', |
|
| 3157 | + 'America/Iqaluit' => 'America/Iqaluit', |
|
| 3158 | + 'America/Coral_Harbour' => 'America/Coral Harbour', |
|
| 3159 | 3159 | 'America/Rankin_Inlet' => 'America/Rankin Inlet', |
| 3160 | 3160 | 'America/Cambridge_Bay' => 'America/Cambridge Bay', |
| 3161 | 3161 | 'America/Yellowknife' => 'America/Yellowknife', |
| 3162 | - 'America/Inuvik' =>'America/Inuvik' , |
|
| 3163 | - 'America/Whitehorse' => 'America/Whitehorse' , |
|
| 3162 | + 'America/Inuvik' =>'America/Inuvik', |
|
| 3163 | + 'America/Whitehorse' => 'America/Whitehorse', |
|
| 3164 | 3164 | 'America/Dawson' => 'America/Dawson', |
| 3165 | 3165 | 'America/Cancun' => 'America/Cancun', |
| 3166 | 3166 | 'America/Merida' => 'America/Merida', |
@@ -3172,7 +3172,7 @@ discard block |
||
| 3172 | 3172 | 'America/Tijuana' => 'America/Tijuana', |
| 3173 | 3173 | 'America/Anguilla' => 'America/Anguilla', |
| 3174 | 3174 | 'America/Antigua' => 'America/Antigua', |
| 3175 | - 'America/Nassau' =>'America/Nassau' , |
|
| 3175 | + 'America/Nassau' =>'America/Nassau', |
|
| 3176 | 3176 | 'America/Barbados' => 'America/Barbados', |
| 3177 | 3177 | 'America/Belize' => 'America/Belize', |
| 3178 | 3178 | 'Atlantic/Bermuda' => 'Atlantic/Bermuda', |
@@ -3192,7 +3192,7 @@ discard block |
||
| 3192 | 3192 | 'America/Montserrat' => 'America/Montserrat', |
| 3193 | 3193 | 'America/Managua' => 'America/Managua', |
| 3194 | 3194 | 'America/Panama' => 'America/Panama', |
| 3195 | - 'America/Puerto_Rico' =>'America/Puerto_Rico' , |
|
| 3195 | + 'America/Puerto_Rico' =>'America/Puerto_Rico', |
|
| 3196 | 3196 | 'America/St_Kitts' => 'America/St_Kitts', |
| 3197 | 3197 | 'America/St_Lucia' => 'America/St_Lucia', |
| 3198 | 3198 | 'America/Miquelon' => 'America/Miquelon', |
@@ -3228,11 +3228,11 @@ discard block |
||
| 3228 | 3228 | 'America/Eirunepe' => 'America/Eirunepe', |
| 3229 | 3229 | 'America/Rio_Branco' => 'America/Rio Branco', |
| 3230 | 3230 | 'America/Santiago' => 'America/Santiago', |
| 3231 | - 'Pacific/Easter' => 'Pacific/Easter' , |
|
| 3231 | + 'Pacific/Easter' => 'Pacific/Easter', |
|
| 3232 | 3232 | 'America/Bogota' => 'America/Bogota', |
| 3233 | 3233 | 'America/Curacao' => 'America/Curacao', |
| 3234 | 3234 | 'America/Guayaquil' => 'America/Guayaquil', |
| 3235 | - 'Pacific/Galapagos' => 'Pacific/Galapagos' , |
|
| 3235 | + 'Pacific/Galapagos' => 'Pacific/Galapagos', |
|
| 3236 | 3236 | 'Atlantic/Stanley' => 'Atlantic/Stanley', |
| 3237 | 3237 | 'America/Cayenne' => 'America/Cayenne', |
| 3238 | 3238 | 'America/Guyana' => 'America/Guyana', |
@@ -3246,7 +3246,7 @@ discard block |
||
| 3246 | 3246 | ); |
| 3247 | 3247 | |
| 3248 | 3248 | $app_list_strings['moduleList']['Sugar_Favorites'] = 'Favorites'; |
| 3249 | - $app_list_strings['eapm_list']= array( |
|
| 3249 | + $app_list_strings['eapm_list'] = array( |
|
| 3250 | 3250 | 'Sugar'=>'SuiteCRM', |
| 3251 | 3251 | 'WebEx'=>'WebEx', |
| 3252 | 3252 | 'GoToMeeting'=>'GoToMeeting', |
@@ -3256,10 +3256,10 @@ discard block |
||
| 3256 | 3256 | 'Facebook'=>'Facebook', |
| 3257 | 3257 | 'Twitter'=>'Twitter', |
| 3258 | 3258 | ); |
| 3259 | - $app_list_strings['eapm_list_import']= array( |
|
| 3259 | + $app_list_strings['eapm_list_import'] = array( |
|
| 3260 | 3260 | 'Google' => 'Google Contacts', |
| 3261 | 3261 | ); |
| 3262 | -$app_list_strings['eapm_list_documents']= array( |
|
| 3262 | +$app_list_strings['eapm_list_documents'] = array( |
|
| 3263 | 3263 | 'Google' => 'Google Docs', |
| 3264 | 3264 | ); |
| 3265 | 3265 | $app_list_strings['token_status'] = array( |
@@ -3268,23 +3268,23 @@ discard block |
||
| 3268 | 3268 | 3 => 'Invalid', |
| 3269 | 3269 | ); |
| 3270 | 3270 | |
| 3271 | -$app_list_strings ['emailTemplates_type_list'] = array ( |
|
| 3272 | - '' => '' , |
|
| 3273 | - 'campaign' => 'Campaign' , |
|
| 3271 | +$app_list_strings ['emailTemplates_type_list'] = array( |
|
| 3272 | + '' => '', |
|
| 3273 | + 'campaign' => 'Campaign', |
|
| 3274 | 3274 | 'email' => 'Email', |
| 3275 | 3275 | ); |
| 3276 | 3276 | |
| 3277 | -$app_list_strings ['emailTemplates_type_list_campaigns'] = array ( |
|
| 3278 | - '' => '' , |
|
| 3279 | - 'campaign' => 'Campaign' , |
|
| 3277 | +$app_list_strings ['emailTemplates_type_list_campaigns'] = array( |
|
| 3278 | + '' => '', |
|
| 3279 | + 'campaign' => 'Campaign', |
|
| 3280 | 3280 | ); |
| 3281 | 3281 | |
| 3282 | -$app_list_strings ['emailTemplates_type_list_no_workflow'] = array ( |
|
| 3283 | - '' => '' , |
|
| 3284 | - 'campaign' => 'Campaign' , |
|
| 3282 | +$app_list_strings ['emailTemplates_type_list_no_workflow'] = array( |
|
| 3283 | + '' => '', |
|
| 3284 | + 'campaign' => 'Campaign', |
|
| 3285 | 3285 | 'email' => 'Email', |
| 3286 | 3286 | ); |
| 3287 | -$app_strings ['documentation'] = array ( |
|
| 3287 | +$app_strings ['documentation'] = array( |
|
| 3288 | 3288 | 'LBL_DOCS' => 'Documentation', |
| 3289 | 3289 | 'ULT' => '02_Sugar_Ultimate', |
| 3290 | 3290 | 'ENT' => '02_Sugar_Enterprise', |
@@ -3342,14 +3342,14 @@ discard block |
||
| 3342 | 3342 | |
| 3343 | 3343 | //aop |
| 3344 | 3344 | $app_list_strings['case_state_dom'] = |
| 3345 | - array ( |
|
| 3345 | + array( |
|
| 3346 | 3346 | 'Open' => 'Open', |
| 3347 | 3347 | 'Closed' => 'Closed', |
| 3348 | 3348 | ); |
| 3349 | 3349 | $app_list_strings['case_state_default_key'] = 'Open'; |
| 3350 | 3350 | $app_list_strings['case_status_default_key'] = 'Open_New'; |
| 3351 | 3351 | $app_list_strings['case_status_dom'] = |
| 3352 | - array ( |
|
| 3352 | + array( |
|
| 3353 | 3353 | 'Open_New' => 'New', |
| 3354 | 3354 | 'Open_Assigned' => 'Assigned', |
| 3355 | 3355 | 'Closed_Closed' => 'Closed', |
@@ -3358,11 +3358,11 @@ discard block |
||
| 3358 | 3358 | 'Closed_Duplicate' => 'Duplicate', |
| 3359 | 3359 | ); |
| 3360 | 3360 | $app_list_strings['contact_portal_user_type_dom'] = |
| 3361 | - array ( |
|
| 3361 | + array( |
|
| 3362 | 3362 | 'Single' => 'Single user', |
| 3363 | 3363 | 'Account' => 'Account user', |
| 3364 | 3364 | ); |
| 3365 | -$app_list_strings['dom_email_distribution_for_auto_create']=array ( |
|
| 3365 | +$app_list_strings['dom_email_distribution_for_auto_create'] = array( |
|
| 3366 | 3366 | 'AOPDefault' => 'Use AOP Default', |
| 3367 | 3367 | 'singleUser' => 'Single User', |
| 3368 | 3368 | 'roundRobin' => 'Round-Robin', |
@@ -3990,6 +3990,6 @@ discard block |
||
| 3990 | 3990 | |
| 3991 | 3991 | $app_strings['LBL_DISCOVER_SUITECRM'] = 'Discover SuiteCRM'; |
| 3992 | 3992 | |
| 3993 | -$app_list_strings['collection_temp_list'] = array ( 'Tasks' => 'Tasks', 'Meetings' => 'Meetings', 'Calls' => 'Calls', 'Notes' => 'Notes', 'Emails' => 'Emails' ); |
|
| 3993 | +$app_list_strings['collection_temp_list'] = array('Tasks' => 'Tasks', 'Meetings' => 'Meetings', 'Calls' => 'Calls', 'Notes' => 'Notes', 'Emails' => 'Emails'); |
|
| 3994 | 3994 | |
| 3995 | 3995 | ?> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Vardefs management |
| 43 | 43 | * @api |
| 44 | 44 | */ |
| 45 | -class VardefManager{ |
|
| 45 | +class VardefManager { |
|
| 46 | 46 | static $custom_disabled_modules = array(); |
| 47 | 47 | static $linkFields; |
| 48 | 48 | |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | if (isset(VardefManager::$custom_disabled_modules[$module])) |
| 68 | 68 | { |
| 69 | 69 | $vardef_paths = array( |
| 70 | - 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', |
|
| 71 | - 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php' |
|
| 70 | + 'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php', |
|
| 71 | + 'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php' |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | //search a predefined set of locations for the vardef files |
@@ -95,41 +95,41 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - static function addTemplate($module, $object, $template, $object_name=false){ |
|
| 99 | - if($template == 'default')$template = 'basic'; |
|
| 98 | + static function addTemplate($module, $object, $template, $object_name = false) { |
|
| 99 | + if ($template == 'default')$template = 'basic'; |
|
| 100 | 100 | $templates = array(); |
| 101 | 101 | $fields = array(); |
| 102 | - if(empty($object_name))$object_name = $object; |
|
| 102 | + if (empty($object_name))$object_name = $object; |
|
| 103 | 103 | $_object_name = strtolower($object_name); |
| 104 | - if(!empty($GLOBALS['dictionary'][$object]['table'])){ |
|
| 104 | + if (!empty($GLOBALS['dictionary'][$object]['table'])) { |
|
| 105 | 105 | $table_name = $GLOBALS['dictionary'][$object]['table']; |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | $table_name = strtolower($module); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(empty($templates[$template])){ |
|
| 111 | - $path = 'include/SugarObjects/templates/' . $template . '/vardefs.php'; |
|
| 112 | - if(file_exists($path)){ |
|
| 110 | + if (empty($templates[$template])) { |
|
| 111 | + $path = 'include/SugarObjects/templates/'.$template.'/vardefs.php'; |
|
| 112 | + if (file_exists($path)) { |
|
| 113 | 113 | require($path); |
| 114 | 114 | $templates[$template] = $vardefs; |
| 115 | - }else{ |
|
| 116 | - $path = 'include/SugarObjects/implements/' . $template . '/vardefs.php'; |
|
| 117 | - if(file_exists($path)){ |
|
| 115 | + } else { |
|
| 116 | + $path = 'include/SugarObjects/implements/'.$template.'/vardefs.php'; |
|
| 117 | + if (file_exists($path)) { |
|
| 118 | 118 | require($path); |
| 119 | 119 | $templates[$template] = $vardefs; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if(!empty($templates[$template])){ |
|
| 125 | - if(empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 126 | - if(empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 127 | - if(empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 124 | + if (!empty($templates[$template])) { |
|
| 125 | + if (empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 126 | + if (empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 127 | + if (empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 128 | 128 | $GLOBALS['dictionary'][$object]['fields'] = array_merge($templates[$template]['fields'], $GLOBALS['dictionary'][$object]['fields']); |
| 129 | - if(!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 130 | - if(!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 129 | + if (!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 130 | + if (!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 131 | 131 | // maintain a record of this objects inheritance from the SugarObject templates... |
| 132 | - $GLOBALS['dictionary'][$object]['templates'][ $template ] = $template ; |
|
| 132 | + $GLOBALS['dictionary'][$object]['templates'][$template] = $template; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | static function cleanVardefs($fieldDefs) |
| 144 | 144 | { |
| 145 | - if(isset($fieldDefs['fields'])) { |
|
| 145 | + if (isset($fieldDefs['fields'])) { |
|
| 146 | 146 | foreach ($fieldDefs['fields'] as $field => $defs) { |
| 147 | 147 | if (empty($defs['name']) || empty($defs['type'])) { |
| 148 | 148 | unset($fieldDefs['fields'][$field]); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param string $module the name of the module |
| 159 | 159 | * @param string $object the name of the object |
| 160 | 160 | */ |
| 161 | - static function saveCache($module,$object, $additonal_objects= array()){ |
|
| 161 | + static function saveCache($module, $object, $additonal_objects = array()) { |
|
| 162 | 162 | |
| 163 | 163 | if (empty($GLOBALS['dictionary'][$object])) |
| 164 | 164 | $object = BeanFactory::getObjectName($module); |
@@ -166,17 +166,17 @@ discard block |
||
| 166 | 166 | //Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those. |
| 167 | 167 | $data = self::cleanVardefs($GLOBALS['dictionary'][$object]); |
| 168 | 168 | |
| 169 | - $file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php'); |
|
| 169 | + $file = create_cache_directory('modules/'.$module.'/'.$object.'vardefs.php'); |
|
| 170 | 170 | |
| 171 | - $out="<?php \n \$GLOBALS[\"dictionary\"][\"". $object . "\"]=" . var_export($data, true) .";"; |
|
| 171 | + $out = "<?php \n \$GLOBALS[\"dictionary\"][\"".$object."\"]=".var_export($data, true).";"; |
|
| 172 | 172 | sugar_file_put_contents_atomic($file, $out); |
| 173 | - if ( sugar_is_file($file) && is_readable($file)) { |
|
| 173 | + if (sugar_is_file($file) && is_readable($file)) { |
|
| 174 | 174 | include($file); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // put the item in the sugar cache. |
| 178 | 178 | $key = "VardefManager.$module.$object"; |
| 179 | - sugar_cache_put($key,$data); |
|
| 179 | + sugar_cache_put($key, $data); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | * clear vardef cache for all modules. |
| 187 | 187 | * @param string object_name the name of the object we are clearing this is for sugar_cache |
| 188 | 188 | */ |
| 189 | - static function clearVardef($module_dir = '', $object_name = ''){ |
|
| 189 | + static function clearVardef($module_dir = '', $object_name = '') { |
|
| 190 | 190 | //if we have a module name specified then just remove that vardef file |
| 191 | 191 | //otherwise go through each module and remove the vardefs.php |
| 192 | - if(!empty($module_dir) && !empty($object_name)){ |
|
| 192 | + if (!empty($module_dir) && !empty($object_name)) { |
|
| 193 | 193 | VardefManager::_clearCache($module_dir, $object_name); |
| 194 | - }else{ |
|
| 194 | + } else { |
|
| 195 | 195 | global $beanList; |
| 196 | - foreach($beanList as $module_dir => $object_name){ |
|
| 196 | + foreach ($beanList as $module_dir => $object_name) { |
|
| 197 | 197 | VardefManager::_clearCache($module_dir, $object_name); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | * @param string module_dir the module_dir to clear |
| 205 | 205 | * @param string object_name the name of the object we are clearing this is for sugar_cache |
| 206 | 206 | */ |
| 207 | - static function _clearCache($module_dir = '', $object_name = ''){ |
|
| 208 | - if(!empty($module_dir) && !empty($object_name)){ |
|
| 207 | + static function _clearCache($module_dir = '', $object_name = '') { |
|
| 208 | + if (!empty($module_dir) && !empty($object_name)) { |
|
| 209 | 209 | |
| 210 | 210 | //Some modules like cases have a bean name that doesn't match the object name |
| 211 | 211 | if (empty($GLOBALS['dictionary'][$object_name])) { |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | $object_name = $newName != false ? $newName : $object_name; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $file = sugar_cached('modules/').$module_dir.'/' . $object_name . 'vardefs.php'; |
|
| 216 | + $file = sugar_cached('modules/').$module_dir.'/'.$object_name.'vardefs.php'; |
|
| 217 | 217 | |
| 218 | - if(file_exists($file)){ |
|
| 218 | + if (file_exists($file)) { |
|
| 219 | 219 | unlink($file); |
| 220 | 220 | $key = "VardefManager.$module_dir.$object_name"; |
| 221 | 221 | sugar_cache_clear($key); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param string $object the given object we wish to load the vardefs for |
| 232 | 232 | * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
| 233 | 233 | */ |
| 234 | - static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array()){ |
|
| 234 | + static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array()) { |
|
| 235 | 235 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 236 | 236 | global $dictionary, $beanList; |
| 237 | 237 | $vardef_paths = array( |
@@ -241,20 +241,20 @@ discard block |
||
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | // Add in additional search paths if they were provided. |
| 244 | - if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 244 | + if (!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 245 | 245 | { |
| 246 | 246 | $vardef_paths = array_merge($vardef_paths, $additional_search_paths); |
| 247 | 247 | } |
| 248 | 248 | $found = false; |
| 249 | 249 | //search a predefined set of locations for the vardef files |
| 250 | - foreach($vardef_paths as $path){ |
|
| 251 | - if(file_exists($path)){ |
|
| 250 | + foreach ($vardef_paths as $path) { |
|
| 251 | + if (file_exists($path)) { |
|
| 252 | 252 | require($path); |
| 253 | 253 | $found = true; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | //Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name |
| 257 | - if(!$found){ |
|
| 257 | + if (!$found) { |
|
| 258 | 258 | $temp = BeanFactory::newBean($module); |
| 259 | 259 | if ($temp) |
| 260 | 260 | { |
@@ -273,15 +273,15 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | //load custom fields into the vardef cache |
| 276 | - if($cacheCustom){ |
|
| 276 | + if ($cacheCustom) { |
|
| 277 | 277 | require_once("modules/DynamicFields/DynamicField.php"); |
| 278 | - $df = new DynamicField ($module) ; |
|
| 278 | + $df = new DynamicField($module); |
|
| 279 | 279 | $df->buildCache($module, false); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | //great! now that we have loaded all of our vardefs. |
| 283 | 283 | //let's go save them to the cache file. |
| 284 | - if(!empty($dictionary[$object])) { |
|
| 284 | + if (!empty($dictionary[$object])) { |
|
| 285 | 285 | VardefManager::saveCache($module, $object); |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | $vardef = $dictionary[$object]; |
| 320 | 320 | $links = array(); |
| 321 | - foreach($vardef['fields'] as $name => $def) |
|
| 321 | + foreach ($vardef['fields'] as $name => $def) |
|
| 322 | 322 | { |
| 323 | 323 | //Look through all link fields for related modules that have calculated fields that use that relationship |
| 324 | - if(!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) |
|
| 324 | + if (!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) |
|
| 325 | 325 | { |
| 326 | 326 | $links[$name] = $def; |
| 327 | 327 | } |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | { |
| 338 | 338 | $cacheKey = "LFR{$module}{$object}{$relName}"; |
| 339 | 339 | $cacheValue = sugar_cache_retrieve($cacheKey); |
| 340 | - if(!empty($cacheValue)) |
|
| 340 | + if (!empty($cacheValue)) |
|
| 341 | 341 | return $cacheValue; |
| 342 | 342 | |
| 343 | 343 | $relLinkFields = self::getLinkFieldsForModule($module, $object); |
| 344 | 344 | $matches = array(); |
| 345 | 345 | if (!empty($relLinkFields)) |
| 346 | 346 | { |
| 347 | - foreach($relLinkFields as $rfName => $rfDef) |
|
| 347 | + foreach ($relLinkFields as $rfName => $rfDef) |
|
| 348 | 348 | { |
| 349 | 349 | if ($rfDef['relationship'] == $relName) |
| 350 | 350 | { |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $results = $matches; |
| 362 | 362 | |
| 363 | 363 | sugar_cache_put($cacheKey, $results); |
| 364 | - return $results ; |
|
| 364 | + return $results; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
@@ -400,22 +400,22 @@ discard block |
||
| 400 | 400 | * @param string $object the given object we wish to load the vardefs for |
| 401 | 401 | * @param bool $refresh whether or not we wish to refresh the cache file. |
| 402 | 402 | */ |
| 403 | - static function loadVardef($module, $object, $refresh=false, $params = array()){ |
|
| 403 | + static function loadVardef($module, $object, $refresh = false, $params = array()) { |
|
| 404 | 404 | //here check if the cache file exists, if it does then load it, if it doesn't |
| 405 | 405 | //then call refreshVardef |
| 406 | 406 | //if either our session or the system is set to developerMode then refresh is set to true |
| 407 | - if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
| 407 | + if (inDeveloperMode() || !empty($_SESSION['developerMode'])) { |
|
| 408 | 408 | $refresh = true; |
| 409 | 409 | } |
| 410 | 410 | // Retrieve the vardefs from cache. |
| 411 | 411 | $key = "VardefManager.$module.$object"; |
| 412 | 412 | |
| 413 | - if(!$refresh) |
|
| 413 | + if (!$refresh) |
|
| 414 | 414 | { |
| 415 | 415 | $return_result = sugar_cache_retrieve($key); |
| 416 | 416 | $return_result = self::applyGlobalAccountRequirements($return_result); |
| 417 | 417 | |
| 418 | - if(!empty($return_result)) |
|
| 418 | + if (!empty($return_result)) |
|
| 419 | 419 | { |
| 420 | 420 | $GLOBALS['dictionary'][$object] = $return_result; |
| 421 | 421 | return; |
@@ -424,28 +424,28 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 426 | 426 | global $dictionary; |
| 427 | - if(empty($GLOBALS['dictionary'][$object]) || $refresh){ |
|
| 427 | + if (empty($GLOBALS['dictionary'][$object]) || $refresh) { |
|
| 428 | 428 | //if the consumer has demanded a refresh or the cache/modules... file |
| 429 | 429 | //does not exist, then we should do out and try to reload things |
| 430 | 430 | |
| 431 | - $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
| 432 | - if($refresh || !file_exists($cachedfile)){ |
|
| 431 | + $cachedfile = sugar_cached('modules/').$module.'/'.$object.'vardefs.php'; |
|
| 432 | + if ($refresh || !file_exists($cachedfile)) { |
|
| 433 | 433 | VardefManager::refreshVardefs($module, $object, null, true, $params); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | //at this point we should have the cache/modules/... file |
| 437 | 437 | //which was created from the refreshVardefs so let's try to load it. |
| 438 | - if(file_exists($cachedfile)) |
|
| 438 | + if (file_exists($cachedfile)) |
|
| 439 | 439 | { |
| 440 | 440 | if (is_readable($cachedfile)) |
| 441 | 441 | { |
| 442 | 442 | include($cachedfile); |
| 443 | 443 | } |
| 444 | 444 | // now that we hae loaded the data from disk, put it in the cache. |
| 445 | - if(!empty($GLOBALS['dictionary'][$object])) |
|
| 445 | + if (!empty($GLOBALS['dictionary'][$object])) |
|
| 446 | 446 | { |
| 447 | 447 | $GLOBALS['dictionary'][$object] = self::applyGlobalAccountRequirements($GLOBALS['dictionary'][$object]); |
| 448 | - sugar_cache_put($key,$GLOBALS['dictionary'][$object]); |
|
| 448 | + sugar_cache_put($key, $GLOBALS['dictionary'][$object]); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | } |
@@ -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. |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | ini_set('mssql.datetimeconvert', '0'); |
| 176 | 176 | |
| 177 | 177 | //set the text size and textlimit to max number so that blob columns are not truncated |
| 178 | - ini_set('mssql.textlimit','2147483647'); |
|
| 179 | - ini_set('mssql.textsize','2147483647'); |
|
| 180 | - ini_set('mssql.charset','UTF-8'); |
|
| 178 | + ini_set('mssql.textlimit', '2147483647'); |
|
| 179 | + ini_set('mssql.textsize', '2147483647'); |
|
| 180 | + ini_set('mssql.charset', 'UTF-8'); |
|
| 181 | 181 | |
| 182 | - if(!empty($configOptions['db_host_instance'])) { |
|
| 182 | + if (!empty($configOptions['db_host_instance'])) { |
|
| 183 | 183 | $configOptions['db_host_instance'] = trim($configOptions['db_host_instance']); |
| 184 | 184 | } |
| 185 | 185 | //set the connections parameters |
@@ -191,37 +191,37 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | //create persistent connection |
| 193 | 193 | if ($this->getOption('persistent')) { |
| 194 | - $this->database =@mssql_pconnect( |
|
| 195 | - $connect_param , |
|
| 194 | + $this->database = @mssql_pconnect( |
|
| 195 | + $connect_param, |
|
| 196 | 196 | $configOptions['db_user_name'], |
| 197 | 197 | $configOptions['db_password'] |
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | //if no persistent connection created, then create regular connection |
| 201 | - if(!$this->database){ |
|
| 201 | + if (!$this->database) { |
|
| 202 | 202 | $this->database = mssql_connect( |
| 203 | - $connect_param , |
|
| 203 | + $connect_param, |
|
| 204 | 204 | $configOptions['db_user_name'], |
| 205 | 205 | $configOptions['db_password'] |
| 206 | 206 | ); |
| 207 | - if(!$this->database){ |
|
| 207 | + if (!$this->database) { |
|
| 208 | 208 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']. |
| 209 | 209 | " as ".$configOptions['db_user_name']."."); |
| 210 | - if($dieOnError) { |
|
| 210 | + if ($dieOnError) { |
|
| 211 | 211 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 212 | 212 | } else { |
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - if($this->database && $this->getOption('persistent')){ |
|
| 216 | + if ($this->database && $this->getOption('persistent')) { |
|
| 217 | 217 | $_SESSION['administrator_error'] = "<B>Severe Performance Degradation: Persistent Database Connections " |
| 218 | 218 | . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false in your " |
| 219 | 219 | . "config.php file</B>"; |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | //make sure connection exists |
| 223 | - if(!$this->database) { |
|
| 224 | - if($dieOnError) { |
|
| 223 | + if (!$this->database) { |
|
| 224 | + if ($dieOnError) { |
|
| 225 | 225 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 226 | 226 | } else { |
| 227 | 227 | return false; |
@@ -235,19 +235,19 @@ discard block |
||
| 235 | 235 | //mssql db maximum number of 5 times at the interval of .2 second. If can not connect |
| 236 | 236 | //it will throw an Unable to select database message. |
| 237 | 237 | |
| 238 | - if(!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
| 238 | + if (!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
| 239 | 239 | $connected = false; |
| 240 | - for($i=0;$i<5;$i++){ |
|
| 240 | + for ($i = 0; $i < 5; $i++) { |
|
| 241 | 241 | usleep(200000); |
| 242 | - if(@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
| 242 | + if (@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
| 243 | 243 | $connected = true; |
| 244 | 244 | break; |
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | - if(!$connected){ |
|
| 248 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}"); |
|
| 249 | - if($dieOnError) { |
|
| 250 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 247 | + if (!$connected) { |
|
| 248 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}"); |
|
| 249 | + if ($dieOnError) { |
|
| 250 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 251 | 251 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 252 | 252 | } else { |
| 253 | 253 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if(!$this->checkError('Could Not Connect', $dieOnError)) |
|
| 261 | + if (!$this->checkError('Could Not Connect', $dieOnError)) |
|
| 262 | 262 | $GLOBALS['log']->info("connected to db"); |
| 263 | 263 | |
| 264 | 264 | $this->connectOptions = $configOptions; |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
| 282 | 282 | { |
| 283 | - if(is_array($sql)) { |
|
| 283 | + if (is_array($sql)) { |
|
| 284 | 284 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
| 285 | 285 | } |
| 286 | 286 | // Flag if there are odd number of single quotes |
| 287 | 287 | if ((substr_count($sql, "'") & 1)) |
| 288 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
| 288 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
| 289 | 289 | |
| 290 | 290 | $sql = $this->_appendN($sql); |
| 291 | 291 | |
| 292 | - $GLOBALS['log']->info('Query:' . $sql); |
|
| 292 | + $GLOBALS['log']->info('Query:'.$sql); |
|
| 293 | 293 | $this->checkConnection(); |
| 294 | 294 | $this->countQuery($sql); |
| 295 | 295 | $this->query_time = microtime(true); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | // Bug 34892 - Clear out previous error message by checking the @@ERROR global variable |
| 298 | 298 | @mssql_query("SELECT @@ERROR", $this->database); |
| 299 | 299 | |
| 300 | - $result = $suppress?@mssql_query($sql, $this->database):mssql_query($sql, $this->database); |
|
| 300 | + $result = $suppress ? @mssql_query($sql, $this->database) : mssql_query($sql, $this->database); |
|
| 301 | 301 | |
| 302 | 302 | if (!$result) { |
| 303 | 303 | // awu Bug 10657: ignoring mssql error message 'Changed database context to' - an intermittent |
@@ -309,13 +309,13 @@ discard block |
||
| 309 | 309 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
| 310 | 310 | |
| 311 | 311 | if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
| 312 | - $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
|
| 312 | + $GLOBALS['log']->debug($sqlmsg.": ".$sql); |
|
| 313 | 313 | else { |
| 314 | - $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
|
| 315 | - if($dieOnError) |
|
| 316 | - sugar_die('SQL Error : ' . $sqlmsg); |
|
| 314 | + $GLOBALS['log']->fatal($sqlmsg.": ".$sql); |
|
| 315 | + if ($dieOnError) |
|
| 316 | + sugar_die('SQL Error : '.$sqlmsg); |
|
| 317 | 317 | else |
| 318 | - echo 'SQL Error : ' . $sqlmsg; |
|
| 318 | + echo 'SQL Error : '.$sqlmsg; |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
| 324 | 324 | |
| 325 | 325 | |
| 326 | - $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
| 326 | + $this->checkError($msg.' Query Failed: '.$sql, $dieOnError); |
|
| 327 | 327 | |
| 328 | 328 | return $result; |
| 329 | 329 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | { |
| 342 | 342 | //set the start to 0, no negs |
| 343 | 343 | if ($start < 0) |
| 344 | - $start=0; |
|
| 344 | + $start = 0; |
|
| 345 | 345 | |
| 346 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
| 346 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
| 347 | 347 | |
| 348 | 348 | $this->lastsql = $sql; |
| 349 | 349 | |
| 350 | 350 | //change the casing to lower for easier string comparison, and trim whitespaces |
| 351 | - $sql = strtolower(trim($sql)) ; |
|
| 351 | + $sql = strtolower(trim($sql)); |
|
| 352 | 352 | |
| 353 | 353 | //set default sql |
| 354 | 354 | $limitUnionSQL = $sql; |
@@ -364,16 +364,16 @@ discard block |
||
| 364 | 364 | $arr_count = 0; |
| 365 | 365 | |
| 366 | 366 | //process if there are elements |
| 367 | - if ($unionOrderByCount){ |
|
| 367 | + if ($unionOrderByCount) { |
|
| 368 | 368 | //we really want the last order by, so reconstruct string |
| 369 | 369 | //adding a 1 to count, as we dont wish to process the last element |
| 370 | 370 | $unionsql = ''; |
| 371 | - while ($unionOrderByCount>$arr_count+1) { |
|
| 371 | + while ($unionOrderByCount > $arr_count + 1) { |
|
| 372 | 372 | $unionsql .= $orderByArray[$arr_count]; |
| 373 | - $arr_count = $arr_count+1; |
|
| 373 | + $arr_count = $arr_count + 1; |
|
| 374 | 374 | //add an "order by" string back if we are coming into loop again |
| 375 | 375 | //remember they were taken out when array was created |
| 376 | - if ($unionOrderByCount>$arr_count+1) { |
|
| 376 | + if ($unionOrderByCount > $arr_count + 1) { |
|
| 377 | 377 | $unionsql .= "order by"; |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | //so we do not want to strip the alias like in other queries. Just add the "order by" string and |
| 404 | 404 | //pass column name as is |
| 405 | 405 | if ($unionOrderBy != '') { |
| 406 | - $unionOrderBy = ' order by ' . $unionOrderBy; |
|
| 406 | + $unionOrderBy = ' order by '.$unionOrderBy; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | //Bug 56560, use top query in conjunction with rownumber() function |
@@ -412,13 +412,13 @@ discard block |
||
| 412 | 412 | //If not for paging, no need to use rownumber() function |
| 413 | 413 | if ($count == 1 && $start == 0) |
| 414 | 414 | { |
| 415 | - $limitUnionSQL = "SELECT TOP $count * FROM (" .$unionsql .") as top_count ".$unionOrderBy; |
|
| 415 | + $limitUnionSQL = "SELECT TOP $count * FROM (".$unionsql.") as top_count ".$unionOrderBy; |
|
| 416 | 416 | } |
| 417 | 417 | else |
| 418 | 418 | { |
| 419 | 419 | $limitUnionSQL = "SELECT TOP $count * FROM( select ROW_NUMBER() OVER ( order by " |
| 420 | 420 | .$rowNumOrderBy.") AS row_number, * FROM (" |
| 421 | - .$unionsql .") As numbered) " |
|
| 421 | + .$unionsql.") As numbered) " |
|
| 422 | 422 | . "As top_count_limit WHERE row_number > $start " |
| 423 | 423 | .$unionOrderBy; |
| 424 | 424 | } |
@@ -437,64 +437,64 @@ discard block |
||
| 437 | 437 | $newSQL = $sql; |
| 438 | 438 | $distinctSQLARRAY = array(); |
| 439 | 439 | if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) |
| 440 | - $newSQL = $this->handleUnionLimitQuery($sql,$start,$count); |
|
| 440 | + $newSQL = $this->handleUnionLimitQuery($sql, $start, $count); |
|
| 441 | 441 | else { |
| 442 | 442 | if ($start < 0) |
| 443 | 443 | $start = 0; |
| 444 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
| 444 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
| 445 | 445 | $this->lastsql = $sql; |
| 446 | 446 | $matches = array(); |
| 447 | - preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU',$sql, $matches); |
|
| 447 | + preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU', $sql, $matches); |
|
| 448 | 448 | if (!empty($matches[3])) { |
| 449 | 449 | if ($start == 0) { |
| 450 | 450 | $match_two = strtolower($matches[2]); |
| 451 | - if (!strpos($match_two, "distinct")> 0 && strpos($match_two, "distinct") !==0) { |
|
| 451 | + if (!strpos($match_two, "distinct") > 0 && strpos($match_two, "distinct") !== 0) { |
|
| 452 | 452 | $orderByMatch = array(); |
| 453 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
| 453 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
| 454 | 454 | if (!empty($orderByMatch[3])) { |
| 455 | 455 | $selectPart = array(); |
| 456 | 456 | preg_match('/^(.*)(\bFROM\b.*)$/isU', $matches[2], $selectPart); |
| 457 | 457 | $newSQL = "SELECT TOP $count * FROM |
| 458 | 458 | ( |
| 459 | - " . $matches[1] . $selectPart[1] . ", ROW_NUMBER() |
|
| 460 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number |
|
| 461 | - " . $selectPart[2] . $orderByMatch[1]. " |
|
| 459 | + ".$matches[1].$selectPart[1].", ROW_NUMBER() |
|
| 460 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number |
|
| 461 | + " . $selectPart[2].$orderByMatch[1]." |
|
| 462 | 462 | ) AS a |
| 463 | 463 | WHERE row_number > $start"; |
| 464 | 464 | } |
| 465 | 465 | else { |
| 466 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
| 466 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | else { |
| 470 | 470 | $distinct_o = strpos($match_two, "distinct"); |
| 471 | 471 | $up_to_distinct_str = substr($match_two, 0, $distinct_o); |
| 472 | 472 | //check to see if the distinct is within a function, if so, then proceed as normal |
| 473 | - if (strpos($up_to_distinct_str,"(")) { |
|
| 473 | + if (strpos($up_to_distinct_str, "(")) { |
|
| 474 | 474 | //proceed as normal |
| 475 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
| 475 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
| 476 | 476 | } |
| 477 | 477 | else { |
| 478 | 478 | //if distinct is not within a function, then parse |
| 479 | 479 | //string contains distinct clause, "TOP needs to come after Distinct" |
| 480 | 480 | //get position of distinct |
| 481 | 481 | $match_zero = strtolower($matches[0]); |
| 482 | - $distinct_pos = strpos($match_zero , "distinct"); |
|
| 482 | + $distinct_pos = strpos($match_zero, "distinct"); |
|
| 483 | 483 | //get position of where |
| 484 | 484 | $where_pos = strpos($match_zero, "where"); |
| 485 | 485 | //parse through string |
| 486 | - $beg = substr($matches[0], 0, $distinct_pos+9 ); |
|
| 487 | - $mid = substr($matches[0], strlen($beg), ($where_pos+5) - (strlen($beg))); |
|
| 488 | - $end = substr($matches[0], strlen($beg) + strlen($mid) ); |
|
| 486 | + $beg = substr($matches[0], 0, $distinct_pos + 9); |
|
| 487 | + $mid = substr($matches[0], strlen($beg), ($where_pos + 5) - (strlen($beg))); |
|
| 488 | + $end = substr($matches[0], strlen($beg) + strlen($mid)); |
|
| 489 | 489 | //repopulate matches array |
| 490 | 490 | $matches[1] = $beg; $matches[2] = $mid; $matches[3] = $end; |
| 491 | 491 | |
| 492 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
| 492 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | } else { |
| 496 | 496 | $orderByMatch = array(); |
| 497 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
| 497 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
| 498 | 498 | |
| 499 | 499 | //if there is a distinct clause, parse sql string as we will have to insert the rownumber |
| 500 | 500 | //for paging, AFTER the distinct clause |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | //take out the select and distinct from string so we can reuse in group by |
| 514 | 514 | $dist_str = 'distinct'; |
| 515 | - preg_match('/\b' . $dist_str . '\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
| 516 | - $matches_sql = trim(substr($matches_sql,$matchesPartSQL[0][1] + strlen($dist_str))); |
|
| 515 | + preg_match('/\b'.$dist_str.'\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
| 516 | + $matches_sql = trim(substr($matches_sql, $matchesPartSQL[0][1] + strlen($dist_str))); |
|
| 517 | 517 | //get the position of where and from for further processing |
| 518 | 518 | preg_match('/\bfrom\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
| 519 | 519 | $from_pos = $matchesPartSQL[0][1]; |
@@ -521,17 +521,17 @@ discard block |
||
| 521 | 521 | $where_pos = $matchesPartSQL[0][1]; |
| 522 | 522 | //split the sql into a string before and after the from clause |
| 523 | 523 | //we will use the columns being selected to construct the group by clause |
| 524 | - if ($from_pos>0 ) { |
|
| 524 | + if ($from_pos > 0) { |
|
| 525 | 525 | $distinctSQLARRAY[0] = substr($matches_sql, 0, $from_pos); |
| 526 | 526 | $distinctSQLARRAY[1] = substr($matches_sql, $from_pos); |
| 527 | 527 | //get position of order by (if it exists) so we can strip it from the string |
| 528 | 528 | $ob_pos = strpos($distinctSQLARRAY[1], "order by"); |
| 529 | 529 | if ($ob_pos) { |
| 530 | - $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1],0,$ob_pos); |
|
| 530 | + $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1], 0, $ob_pos); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | // strip off last closing parentheses from the where clause |
| 534 | - $distinctSQLARRAY[1] = preg_replace('/\)\s$/',' ',$distinctSQLARRAY[1]); |
|
| 534 | + $distinctSQLARRAY[1] = preg_replace('/\)\s$/', ' ', $distinctSQLARRAY[1]); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | $grpByStr = array(); |
@@ -550,30 +550,30 @@ discard block |
||
| 550 | 550 | $newSQL = "SELECT TOP $count * FROM |
| 551 | 551 | ( |
| 552 | 552 | SELECT ROW_NUMBER() |
| 553 | - OVER (ORDER BY " . preg_replace('/^' . $dist_str . '\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])) . ") AS row_number, |
|
| 554 | - count(*) counter, " . $distinctSQLARRAY[0] . " |
|
| 555 | - " . $distinctSQLARRAY[1] . " |
|
| 556 | - group by " . $grpByStr . " |
|
| 553 | + OVER (ORDER BY ".preg_replace('/^'.$dist_str.'\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])).") AS row_number, |
|
| 554 | + count(*) counter, " . $distinctSQLARRAY[0]." |
|
| 555 | + " . $distinctSQLARRAY[1]." |
|
| 556 | + group by " . $grpByStr." |
|
| 557 | 557 | ) AS a |
| 558 | 558 | WHERE row_number > $start"; |
| 559 | 559 | } |
| 560 | 560 | else { |
| 561 | 561 | $newSQL = "SELECT TOP $count * FROM |
| 562 | 562 | ( |
| 563 | - " . $matches[1] . " ROW_NUMBER() |
|
| 564 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number, |
|
| 565 | - " . $matches[2] . $orderByMatch[1]. " |
|
| 563 | + ".$matches[1]." ROW_NUMBER() |
|
| 564 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number, |
|
| 565 | + " . $matches[2].$orderByMatch[1]." |
|
| 566 | 566 | ) AS a |
| 567 | 567 | WHERE row_number > $start"; |
| 568 | 568 | } |
| 569 | - }else{ |
|
| 569 | + } else { |
|
| 570 | 570 | //if there is a distinct clause, form query with rownumber after distinct |
| 571 | 571 | if ($hasDistinct) { |
| 572 | 572 | $newSQL = "SELECT TOP $count * FROM |
| 573 | 573 | ( |
| 574 | - SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, " . $distinctSQLARRAY[0] . " |
|
| 575 | - " . $distinctSQLARRAY[1] . " |
|
| 576 | - group by " . $grpByStr . " |
|
| 574 | + SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, ".$distinctSQLARRAY[0]." |
|
| 575 | + " . $distinctSQLARRAY[1]." |
|
| 576 | + group by " . $grpByStr." |
|
| 577 | 577 | ) |
| 578 | 578 | AS a |
| 579 | 579 | WHERE row_number > $start"; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | else { |
| 582 | 582 | $newSQL = "SELECT TOP $count * FROM |
| 583 | 583 | ( |
| 584 | - " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. " |
|
| 584 | + ".$matches[1]." ROW_NUMBER() OVER (ORDER BY ".$sqlArray['FROM'][0]['alias'].".id) AS row_number, ".$matches[2].$matches[3]." |
|
| 585 | 585 | ) |
| 586 | 586 | AS a |
| 587 | 587 | WHERE row_number > $start"; |
@@ -591,9 +591,9 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $GLOBALS['log']->debug('Limit Query: ' . $newSQL); |
|
| 595 | - if($execute) { |
|
| 596 | - $result = $this->query($newSQL, $dieOnError, $msg); |
|
| 594 | + $GLOBALS['log']->debug('Limit Query: '.$newSQL); |
|
| 595 | + if ($execute) { |
|
| 596 | + $result = $this->query($newSQL, $dieOnError, $msg); |
|
| 597 | 597 | $this->dump_slow_queries($newSQL); |
| 598 | 598 | return $result; |
| 599 | 599 | } else { |
@@ -615,15 +615,15 @@ discard block |
||
| 615 | 615 | private function removePatternFromSQL($p_sql, $strip_beg, $strip_end, $patt = 'patt') |
| 616 | 616 | { |
| 617 | 617 | //strip all single quotes out |
| 618 | - $count = substr_count ( $p_sql, $strip_beg); |
|
| 618 | + $count = substr_count($p_sql, $strip_beg); |
|
| 619 | 619 | $increment = 1; |
| 620 | 620 | if ($strip_beg != $strip_end) |
| 621 | 621 | $increment = 2; |
| 622 | 622 | |
| 623 | - $i=0; |
|
| 623 | + $i = 0; |
|
| 624 | 624 | $offset = 0; |
| 625 | 625 | $strip_array = array(); |
| 626 | - while ($i<$count && $offset<strlen($p_sql)) { |
|
| 626 | + while ($i < $count && $offset < strlen($p_sql)) { |
|
| 627 | 627 | if ($offset > strlen($p_sql)) |
| 628 | 628 | { |
| 629 | 629 | break; |
@@ -634,23 +634,23 @@ discard block |
||
| 634 | 634 | { |
| 635 | 635 | break; |
| 636 | 636 | } |
| 637 | - $sec_sin = strpos($p_sql, $strip_end, $beg_sin+1); |
|
| 638 | - $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin +1); |
|
| 637 | + $sec_sin = strpos($p_sql, $strip_end, $beg_sin + 1); |
|
| 638 | + $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin + 1); |
|
| 639 | 639 | if ($increment > 1) { |
| 640 | 640 | //we are in here because beginning and end patterns are not identical, so search for nesting |
| 641 | - $exists = strpos($strip_array[$patt.$i], $strip_beg ); |
|
| 642 | - if ($exists>=0) { |
|
| 643 | - $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg )); |
|
| 644 | - $strip_array[$patt.$i] = substr($p_sql,$nested_pos+$beg_sin,$sec_sin - ($nested_pos+$beg_sin)+1); |
|
| 645 | - $p_sql = substr($p_sql, 0, $nested_pos+$beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
| 641 | + $exists = strpos($strip_array[$patt.$i], $strip_beg); |
|
| 642 | + if ($exists >= 0) { |
|
| 643 | + $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg)); |
|
| 644 | + $strip_array[$patt.$i] = substr($p_sql, $nested_pos + $beg_sin, $sec_sin - ($nested_pos + $beg_sin) + 1); |
|
| 645 | + $p_sql = substr($p_sql, 0, $nested_pos + $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
| 646 | 646 | $i = $i + 1; |
| 647 | 647 | continue; |
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | - $p_len = strlen("##". $patt.$i."##"); |
|
| 651 | - $p_sql = substr($p_sql, 0, $beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
| 650 | + $p_len = strlen("##".$patt.$i."##"); |
|
| 651 | + $p_sql = substr($p_sql, 0, $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
| 652 | 652 | //move the marker up |
| 653 | - $offset = ($sec_sin-($sec_sin-$beg_sin))+$p_len+1; // Adjusting the starting point of the marker |
|
| 653 | + $offset = ($sec_sin - ($sec_sin - $beg_sin)) + $p_len + 1; // Adjusting the starting point of the marker |
|
| 654 | 654 | |
| 655 | 655 | $i = $i + 1; |
| 656 | 656 | } |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $pattern_array = array_reverse($pattern_array); |
| 673 | 673 | |
| 674 | 674 | foreach ($pattern_array as $key => $replace) { |
| 675 | - $token = str_replace( " ##".$key."## ", $replace,$token); |
|
| 675 | + $token = str_replace(" ##".$key."## ", $replace, $token); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | return $token; |
@@ -688,11 +688,11 @@ discard block |
||
| 688 | 688 | private function getAliasFromSQL($sql, $alias) |
| 689 | 689 | { |
| 690 | 690 | $matches = array(); |
| 691 | - preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU',$sql, $matches); |
|
| 691 | + preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU', $sql, $matches); |
|
| 692 | 692 | //parse all single and double quotes out of array |
| 693 | - $sin_array = $this->removePatternFromSQL($matches[2], "'", "'","sin_"); |
|
| 693 | + $sin_array = $this->removePatternFromSQL($matches[2], "'", "'", "sin_"); |
|
| 694 | 694 | $new_sql = array_pop($sin_array); |
| 695 | - $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"","dub_"); |
|
| 695 | + $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"", "dub_"); |
|
| 696 | 696 | $new_sql = array_pop($dub_array); |
| 697 | 697 | |
| 698 | 698 | //search for parenthesis |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | //all functions should be removed now, so split the array on commas |
| 703 | 703 | $mstr_sql_array = explode(",", $new_sql); |
| 704 | - foreach($mstr_sql_array as $token ) { |
|
| 704 | + foreach ($mstr_sql_array as $token) { |
|
| 705 | 705 | if (strpos($token, $alias)) { |
| 706 | 706 | //found token, add back comments |
| 707 | 707 | $token = $this->addPatternToSQL($token, $paren_array); |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | $found = $found_in_sql; |
| 740 | 740 | |
| 741 | 741 | //if still no match found, then we need to parse through the string |
| 742 | - if (!$found_in_sql){ |
|
| 742 | + if (!$found_in_sql) { |
|
| 743 | 743 | //get count of how many times the match exists in string |
| 744 | 744 | $found_count = substr_count($sql, $orderMatch); |
| 745 | 745 | $i = 0; |
@@ -748,21 +748,21 @@ discard block |
||
| 748 | 748 | //loop through string as many times as there is a match |
| 749 | 749 | while ($found_count > $i) { |
| 750 | 750 | //get the first match |
| 751 | - $found_in_sql = strpos($sql, $orderMatch,$first_); |
|
| 751 | + $found_in_sql = strpos($sql, $orderMatch, $first_); |
|
| 752 | 752 | //make sure there was a match |
| 753 | - if($found_in_sql){ |
|
| 753 | + if ($found_in_sql) { |
|
| 754 | 754 | //grab the next 2 individual characters |
| 755 | - $str_plusone = substr($sql,$found_in_sql + $len,1); |
|
| 756 | - $str_plustwo = substr($sql,$found_in_sql + $len+1,1); |
|
| 755 | + $str_plusone = substr($sql, $found_in_sql + $len, 1); |
|
| 756 | + $str_plustwo = substr($sql, $found_in_sql + $len + 1, 1); |
|
| 757 | 757 | //if one of those characters is a comma, then we have our alias |
| 758 | - if ($str_plusone === "," || $str_plustwo === ","){ |
|
| 758 | + if ($str_plusone === "," || $str_plustwo === ",") { |
|
| 759 | 759 | //keep track of this position |
| 760 | 760 | $found = $found_in_sql; |
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | //set the offset and increase the iteration counter |
| 764 | - $first_ = $found_in_sql+$len; |
|
| 765 | - $i = $i+1; |
|
| 764 | + $first_ = $found_in_sql + $len; |
|
| 765 | + $i = $i + 1; |
|
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | //return $found, defaults have been set, so if no match was found it will be a negative number |
@@ -794,8 +794,8 @@ discard block |
||
| 794 | 794 | $firstSpace = strpos($orig_order_match, " "); |
| 795 | 795 | |
| 796 | 796 | //split order by into column name and ascending/descending |
| 797 | - $orderMatch = " " . strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
| 798 | - $asc_desc = trim(substr($orig_order_match,$firstSpace)); |
|
| 797 | + $orderMatch = " ".strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
| 798 | + $asc_desc = trim(substr($orig_order_match, $firstSpace)); |
|
| 799 | 799 | |
| 800 | 800 | //look for column name as an alias in sql string |
| 801 | 801 | $found_in_sql = $this->findColumnByAlias($sql, $orderMatch); |
@@ -806,18 +806,18 @@ discard block |
||
| 806 | 806 | $colMatchPos = strpos($sql, $orderMatch); |
| 807 | 807 | if ($colMatchPos !== false) { |
| 808 | 808 | //grab sub string up to column name |
| 809 | - $containsColStr = substr($sql,0, $colMatchPos); |
|
| 809 | + $containsColStr = substr($sql, 0, $colMatchPos); |
|
| 810 | 810 | //get position of first space, so we can grab table name |
| 811 | 811 | $lastSpacePos = strrpos($containsColStr, " "); |
| 812 | 812 | //use positions of column name, space before name, and length of column to find the correct column name |
| 813 | - $col_name = substr($sql, $lastSpacePos, $colMatchPos-$lastSpacePos+strlen($orderMatch)); |
|
| 813 | + $col_name = substr($sql, $lastSpacePos, $colMatchPos - $lastSpacePos + strlen($orderMatch)); |
|
| 814 | 814 | //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error |
| 815 | 815 | $containsCommaPos = strpos($col_name, ","); |
| 816 | - if($containsCommaPos !== false) { |
|
| 817 | - $col_name = substr($col_name, $containsCommaPos+1); |
|
| 816 | + if ($containsCommaPos !== false) { |
|
| 817 | + $col_name = substr($col_name, $containsCommaPos + 1); |
|
| 818 | 818 | } |
| 819 | 819 | //add the "asc/desc" order back |
| 820 | - $col_name = $col_name. " ". $asc_desc; |
|
| 820 | + $col_name = $col_name." ".$asc_desc; |
|
| 821 | 821 | |
| 822 | 822 | //return column name |
| 823 | 823 | return $col_name; |
@@ -831,22 +831,22 @@ discard block |
||
| 831 | 831 | //grab string up to the aliased column |
| 832 | 832 | $GLOBALS['log']->debug("order by found, process sql string"); |
| 833 | 833 | |
| 834 | - $psql = (trim($this->getAliasFromSQL($sql, $orderMatch ))); |
|
| 834 | + $psql = (trim($this->getAliasFromSQL($sql, $orderMatch))); |
|
| 835 | 835 | if (empty($psql)) |
| 836 | 836 | $psql = trim(substr($sql, 0, $found_in_sql)); |
| 837 | 837 | |
| 838 | 838 | //grab the last comma before the alias |
| 839 | - preg_match('/\s+' . trim($orderMatch). '/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
| 839 | + preg_match('/\s+'.trim($orderMatch).'/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
| 840 | 840 | $comma_pos = $match[0][1]; |
| 841 | 841 | //substring between the comma and the alias to find the joined_table alias and column name |
| 842 | - $col_name = substr($psql,0, $comma_pos); |
|
| 842 | + $col_name = substr($psql, 0, $comma_pos); |
|
| 843 | 843 | |
| 844 | 844 | //make sure the string does not have an end parenthesis |
| 845 | 845 | //and is not part of a function (i.e. "ISNULL(leads.last_name,'') as name" ) |
| 846 | 846 | //this is especially true for unified search from home screen |
| 847 | 847 | |
| 848 | 848 | $alias_beg_pos = 0; |
| 849 | - if(strpos($psql, " as ")) |
|
| 849 | + if (strpos($psql, " as ")) |
|
| 850 | 850 | $alias_beg_pos = strpos($psql, " as "); |
| 851 | 851 | |
| 852 | 852 | // Bug # 44923 - This breaks the query and does not properly filter isnull |
@@ -855,13 +855,13 @@ discard block |
||
| 855 | 855 | $alias_beg_pos = strpos($psql, " "); */ |
| 856 | 856 | |
| 857 | 857 | if ($alias_beg_pos > 0) { |
| 858 | - $col_name = substr($psql,0, $alias_beg_pos ); |
|
| 858 | + $col_name = substr($psql, 0, $alias_beg_pos); |
|
| 859 | 859 | } |
| 860 | 860 | //add the "asc/desc" order back |
| 861 | - $col_name = $col_name. " ". $asc_desc; |
|
| 861 | + $col_name = $col_name." ".$asc_desc; |
|
| 862 | 862 | |
| 863 | 863 | //pass in new order by |
| 864 | - $GLOBALS['log']->debug("order by being returned is " . $col_name); |
|
| 864 | + $GLOBALS['log']->debug("order by being returned is ".$col_name); |
|
| 865 | 865 | return $col_name; |
| 866 | 866 | } |
| 867 | 867 | } |
@@ -877,12 +877,12 @@ discard block |
||
| 877 | 877 | { |
| 878 | 878 | |
| 879 | 879 | global $beanList, $beanFiles; |
| 880 | - $GLOBALS['log']->debug("Module being processed is " . $module_str); |
|
| 880 | + $GLOBALS['log']->debug("Module being processed is ".$module_str); |
|
| 881 | 881 | //get the right module files |
| 882 | 882 | //the module string exists in bean list, then process bean for correct table name |
| 883 | 883 | //note that we exempt the reports module from this, as queries from reporting module should be parsed for |
| 884 | 884 | //correct table name. |
| 885 | - if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])){ |
|
| 885 | + if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])) { |
|
| 886 | 886 | //if the class is not already loaded, then load files |
| 887 | 887 | if (!class_exists($beanList[$module_str])) |
| 888 | 888 | require_once($beanFiles[$beanList[$module_str]]); |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | //make sure table name is not just a blank space, or empty |
| 895 | 895 | $tbl_name = trim($tbl_name); |
| 896 | 896 | |
| 897 | - if(empty($tbl_name)){ |
|
| 897 | + if (empty($tbl_name)) { |
|
| 898 | 898 | $GLOBALS['log']->debug("Could not find table name for module $module_str. "); |
| 899 | 899 | $tbl_name = $module_str; |
| 900 | 900 | } |
@@ -911,20 +911,20 @@ discard block |
||
| 911 | 911 | $sql = str_replace(array("\n", "\r"), " ", $sql); |
| 912 | 912 | |
| 913 | 913 | //look for the location of the "from" in sql string |
| 914 | - $fromLoc = strpos($sql," from " ); |
|
| 915 | - if ($fromLoc>0){ |
|
| 914 | + $fromLoc = strpos($sql, " from "); |
|
| 915 | + if ($fromLoc > 0) { |
|
| 916 | 916 | //found from, substring from the " FROM " string in sql to end |
| 917 | - $tableEnd = substr($sql, $fromLoc+6); |
|
| 917 | + $tableEnd = substr($sql, $fromLoc + 6); |
|
| 918 | 918 | //We know that tablename will be next parameter after from, so |
| 919 | 919 | //grab the next space after table name. |
| 920 | 920 | // MFH BUG #14009: Also check to see if there are any carriage returns before the next space so that we don't grab any arbitrary joins or other tables. |
| 921 | - $carriage_ret = strpos($tableEnd,"\n"); |
|
| 922 | - $next_space = strpos($tableEnd," " ); |
|
| 921 | + $carriage_ret = strpos($tableEnd, "\n"); |
|
| 922 | + $next_space = strpos($tableEnd, " "); |
|
| 923 | 923 | if ($carriage_ret < $next_space) |
| 924 | 924 | $next_space = $carriage_ret; |
| 925 | 925 | if ($next_space > 0) { |
| 926 | - $tbl_name= substr($tableEnd,0, $next_space); |
|
| 927 | - if(empty($tbl_name)){ |
|
| 926 | + $tbl_name = substr($tableEnd, 0, $next_space); |
|
| 927 | + if (empty($tbl_name)) { |
|
| 928 | 928 | $GLOBALS['log']->debug("Could not find table name sql either, return $module_str. "); |
| 929 | 929 | $tbl_name = $module_str; |
| 930 | 930 | } |
@@ -932,11 +932,11 @@ discard block |
||
| 932 | 932 | |
| 933 | 933 | //grab the table, to see if it is aliased |
| 934 | 934 | $aliasTableEnd = trim(substr($tableEnd, $next_space)); |
| 935 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
| 936 | - if ($alias_space > 0){ |
|
| 937 | - $alias_tbl_name= substr($aliasTableEnd,0, $alias_space); |
|
| 935 | + $alias_space = strpos($aliasTableEnd, " "); |
|
| 936 | + if ($alias_space > 0) { |
|
| 937 | + $alias_tbl_name = substr($aliasTableEnd, 0, $alias_space); |
|
| 938 | 938 | strtolower($alias_tbl_name); |
| 939 | - if(empty($alias_tbl_name) |
|
| 939 | + if (empty($alias_tbl_name) |
|
| 940 | 940 | || $alias_tbl_name == "where" |
| 941 | 941 | || $alias_tbl_name == "inner" |
| 942 | 942 | || $alias_tbl_name == "left" |
@@ -948,9 +948,9 @@ discard block |
||
| 948 | 948 | elseif ($alias_tbl_name == "as") { |
| 949 | 949 | //the next word is the table name |
| 950 | 950 | $aliasTableEnd = trim(substr($aliasTableEnd, $alias_space)); |
| 951 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
| 951 | + $alias_space = strpos($aliasTableEnd, " "); |
|
| 952 | 952 | if ($alias_space > 0) { |
| 953 | - $alias_tbl_name= trim(substr($aliasTableEnd,0, $alias_space)); |
|
| 953 | + $alias_tbl_name = trim(substr($aliasTableEnd, 0, $alias_space)); |
|
| 954 | 954 | if (!empty($alias_tbl_name)) |
| 955 | 955 | $tbl_name = $alias_tbl_name; |
| 956 | 956 | } |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | { |
| 976 | 976 | $field_array = array(); |
| 977 | 977 | |
| 978 | - if(! isset($result) || empty($result)) |
|
| 978 | + if (!isset($result) || empty($result)) |
|
| 979 | 979 | return 0; |
| 980 | 980 | |
| 981 | 981 | $i = 0; |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | $meta = mssql_fetch_field($result, $i); |
| 984 | 984 | if (!$meta) |
| 985 | 985 | return 0; |
| 986 | - if($make_lower_case==true) |
|
| 986 | + if ($make_lower_case == true) |
|
| 987 | 987 | $meta->name = strtolower($meta->name); |
| 988 | 988 | |
| 989 | 989 | $field_array[] = $meta->name; |
@@ -1012,11 +1012,11 @@ discard block |
||
| 1012 | 1012 | $row = mssql_fetch_assoc($result); |
| 1013 | 1013 | //MSSQL returns a space " " when a varchar column is empty ("") and not null. |
| 1014 | 1014 | //We need to iterate through the returned row array and strip empty spaces |
| 1015 | - if(!empty($row)){ |
|
| 1016 | - foreach($row as $key => $column) { |
|
| 1015 | + if (!empty($row)) { |
|
| 1016 | + foreach ($row as $key => $column) { |
|
| 1017 | 1017 | //notice we only strip if one space is returned. we do not want to strip |
| 1018 | 1018 | //strings with intentional spaces (" foo ") |
| 1019 | - if (!empty($column) && $column ==" ") { |
|
| 1019 | + if (!empty($column) && $column == " ") { |
|
| 1020 | 1020 | $row[$key] = ''; |
| 1021 | 1021 | } |
| 1022 | 1022 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
| 1029 | 1029 | */ |
| 1030 | 1030 | public function quote($string) |
| 1031 | 1031 | { |
| 1032 | - if(is_array($string)) { |
|
| 1032 | + if (is_array($string)) { |
|
| 1033 | 1033 | return $this->arrayQuote($string); |
| 1034 | 1034 | } |
| 1035 | - return str_replace("'","''", $this->quoteInternal($string)); |
|
| 1035 | + return str_replace("'", "''", $this->quoteInternal($string)); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | if (!empty($r)) { |
| 1071 | 1071 | while ($a = $this->fetchByAssoc($r)) { |
| 1072 | 1072 | $row = array_values($a); |
| 1073 | - $tables[]=$row[0]; |
|
| 1073 | + $tables[] = $row[0]; |
|
| 1074 | 1074 | } |
| 1075 | 1075 | return $tables; |
| 1076 | 1076 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
| 1085 | 1085 | { |
| 1086 | 1086 | $GLOBALS['log']->debug('MSSQL fetching table list'); |
| 1087 | 1087 | |
| 1088 | - if($this->getDatabase()) { |
|
| 1088 | + if ($this->getDatabase()) { |
|
| 1089 | 1089 | $tables = array(); |
| 1090 | 1090 | $r = $this->query('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES'); |
| 1091 | 1091 | if (is_resource($r)) { |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | { |
| 1110 | 1110 | $GLOBALS['log']->debug('MSSQL about to wakeup FTS'); |
| 1111 | 1111 | |
| 1112 | - if($this->getDatabase()) { |
|
| 1112 | + if ($this->getDatabase()) { |
|
| 1113 | 1113 | //create wakeup catalog |
| 1114 | 1114 | $FTSqry[] = "if not exists( select * from sys.fulltext_catalogs where name ='wakeup_catalog' ) |
| 1115 | 1115 | CREATE FULLTEXT CATALOG wakeup_catalog |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup START FULL POPULATION'; |
| 1150 | 1150 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup SET CHANGE_TRACKING AUTO'; |
| 1151 | 1151 | |
| 1152 | - foreach($FTSqry as $q){ |
|
| 1152 | + foreach ($FTSqry as $q) { |
|
| 1153 | 1153 | sleep(3); |
| 1154 | 1154 | $this->query($q); |
| 1155 | 1155 | } |
@@ -1172,12 +1172,12 @@ discard block |
||
| 1172 | 1172 | { |
| 1173 | 1173 | // convert the parameters array into a comma delimited string |
| 1174 | 1174 | if (!empty($additional_parameters)) { |
| 1175 | - $additional_parameters_string = ','.implode(',',$additional_parameters); |
|
| 1175 | + $additional_parameters_string = ','.implode(',', $additional_parameters); |
|
| 1176 | 1176 | } else { |
| 1177 | 1177 | $additional_parameters_string = ''; |
| 1178 | 1178 | } |
| 1179 | 1179 | $all_parameters = $additional_parameters; |
| 1180 | - if(is_array($string)) { |
|
| 1180 | + if (is_array($string)) { |
|
| 1181 | 1181 | $all_parameters = array_merge($string, $all_parameters); |
| 1182 | 1182 | } elseif (!is_null($string)) { |
| 1183 | 1183 | array_unshift($all_parameters, $string); |
@@ -1189,22 +1189,22 @@ discard block |
||
| 1189 | 1189 | case 'left': |
| 1190 | 1190 | return "LEFT($string$additional_parameters_string)"; |
| 1191 | 1191 | case 'date_format': |
| 1192 | - if(!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
| 1192 | + if (!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
| 1193 | 1193 | $additional_parameters[0] = trim($additional_parameters[0], "'"); |
| 1194 | 1194 | } |
| 1195 | - if(!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
| 1195 | + if (!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
| 1196 | 1196 | $len = $this->date_formats[$additional_parameters[0]]; |
| 1197 | - return "LEFT(CONVERT(varchar($len),". $string . ",120),$len)"; |
|
| 1197 | + return "LEFT(CONVERT(varchar($len),".$string.",120),$len)"; |
|
| 1198 | 1198 | } else { |
| 1199 | - return "LEFT(CONVERT(varchar(10),". $string . ",120),10)"; |
|
| 1199 | + return "LEFT(CONVERT(varchar(10),".$string.",120),10)"; |
|
| 1200 | 1200 | } |
| 1201 | 1201 | case 'ifnull': |
| 1202 | - if(empty($additional_parameters_string)) { |
|
| 1202 | + if (empty($additional_parameters_string)) { |
|
| 1203 | 1203 | $additional_parameters_string = ",''"; |
| 1204 | 1204 | } |
| 1205 | 1205 | return "ISNULL($string$additional_parameters_string)"; |
| 1206 | 1206 | case 'concat': |
| 1207 | - return implode("+",$all_parameters); |
|
| 1207 | + return implode("+", $all_parameters); |
|
| 1208 | 1208 | case 'text2char': |
| 1209 | 1209 | return "CAST($string AS varchar(8000))"; |
| 1210 | 1210 | case 'quarter': |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | case 'add_tz_offset' : |
| 1221 | 1221 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
| 1222 | 1222 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
| 1223 | - return 'DATEADD(minute, ' . $operation . abs($getUserUTCOffset) . ', ' . $string. ')'; |
|
| 1223 | + return 'DATEADD(minute, '.$operation.abs($getUserUTCOffset).', '.$string.')'; |
|
| 1224 | 1224 | case 'avg': |
| 1225 | 1225 | return "avg($string)"; |
| 1226 | 1226 | } |
@@ -1233,9 +1233,9 @@ discard block |
||
| 1233 | 1233 | */ |
| 1234 | 1234 | public function fromConvert($string, $type) |
| 1235 | 1235 | { |
| 1236 | - switch($type) { |
|
| 1236 | + switch ($type) { |
|
| 1237 | 1237 | case 'datetimecombo': |
| 1238 | - case 'datetime': return substr($string, 0,19); |
|
| 1238 | + case 'datetime': return substr($string, 0, 19); |
|
| 1239 | 1239 | case 'date': return substr($string, 0, 10); |
| 1240 | 1240 | case 'time': return substr($string, 11); |
| 1241 | 1241 | } |
@@ -1264,8 +1264,8 @@ discard block |
||
| 1264 | 1264 | public function isTextType($type) |
| 1265 | 1265 | { |
| 1266 | 1266 | $type = strtolower($type); |
| 1267 | - if(!isset($this->type_map[$type])) return false; |
|
| 1268 | - return in_array($this->type_map[$type], array('ntext','text','image', 'nvarchar(max)')); |
|
| 1267 | + if (!isset($this->type_map[$type])) return false; |
|
| 1268 | + return in_array($this->type_map[$type], array('ntext', 'text', 'image', 'nvarchar(max)')); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | 1271 | /** |
@@ -1275,13 +1275,13 @@ discard block |
||
| 1275 | 1275 | public function emptyValue($type) |
| 1276 | 1276 | { |
| 1277 | 1277 | $ctype = $this->getColumnType($type); |
| 1278 | - if($ctype == "datetime") { |
|
| 1278 | + if ($ctype == "datetime") { |
|
| 1279 | 1279 | return $this->convert($this->quoted("1970-01-01 00:00:00"), "datetime"); |
| 1280 | 1280 | } |
| 1281 | - if($ctype == "date") { |
|
| 1281 | + if ($ctype == "date") { |
|
| 1282 | 1282 | return $this->convert($this->quoted("1970-01-01"), "datetime"); |
| 1283 | 1283 | } |
| 1284 | - if($ctype == "time") { |
|
| 1284 | + if ($ctype == "time") { |
|
| 1285 | 1285 | return $this->convert($this->quoted("00:00:00"), "time"); |
| 1286 | 1286 | } |
| 1287 | 1287 | return parent::emptyValue($type); |
@@ -1304,21 +1304,21 @@ discard block |
||
| 1304 | 1304 | */ |
| 1305 | 1305 | protected function alterSQLRep($action, array $def, $ignoreRequired, $tablename) |
| 1306 | 1306 | { |
| 1307 | - switch($action){ |
|
| 1307 | + switch ($action) { |
|
| 1308 | 1308 | case 'add': |
| 1309 | - $f_def=$this->oneColumnSQLRep($def, $ignoreRequired,$tablename,false); |
|
| 1310 | - return "ADD " . $f_def; |
|
| 1309 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, false); |
|
| 1310 | + return "ADD ".$f_def; |
|
| 1311 | 1311 | break; |
| 1312 | 1312 | case 'drop': |
| 1313 | - return "DROP COLUMN " . $def['name']; |
|
| 1313 | + return "DROP COLUMN ".$def['name']; |
|
| 1314 | 1314 | break; |
| 1315 | 1315 | case 'modify': |
| 1316 | 1316 | //You cannot specify a default value for a column for MSSQL |
| 1317 | - $f_def = $this->oneColumnSQLRep($def, $ignoreRequired,$tablename, true); |
|
| 1317 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, true); |
|
| 1318 | 1318 | $f_stmt = "ALTER COLUMN ".$f_def['name'].' '.$f_def['colType'].' '. |
| 1319 | 1319 | $f_def['required'].' '.$f_def['auto_increment']."\n"; |
| 1320 | - if (!empty( $f_def['default'])) |
|
| 1321 | - $f_stmt .= " ALTER TABLE " . $tablename . " ADD ". $f_def['default'] . " FOR " . $def['name']; |
|
| 1320 | + if (!empty($f_def['default'])) |
|
| 1321 | + $f_stmt .= " ALTER TABLE ".$tablename." ADD ".$f_def['default']." FOR ".$def['name']; |
|
| 1322 | 1322 | return $f_stmt; |
| 1323 | 1323 | break; |
| 1324 | 1324 | default: |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | */ |
| 1335 | 1335 | protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
| 1336 | 1336 | { |
| 1337 | - $sql=$sql2=''; |
|
| 1337 | + $sql = $sql2 = ''; |
|
| 1338 | 1338 | $constraints = $this->get_field_default_constraint_name($tablename); |
| 1339 | 1339 | $columns = array(); |
| 1340 | 1340 | if ($this->isFieldArray($fieldDefs)) { |
@@ -1343,41 +1343,41 @@ discard block |
||
| 1343 | 1343 | //if the column is being modified drop the default value |
| 1344 | 1344 | //constraint if it exists. alterSQLRep will add the constraint back |
| 1345 | 1345 | if (!empty($constraints[$def['name']])) { |
| 1346 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']]; |
|
| 1346 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$def['name']]; |
|
| 1347 | 1347 | } |
| 1348 | 1348 | //check to see if we need to drop related indexes before the alter |
| 1349 | 1349 | $indices = $this->get_indices($tablename); |
| 1350 | - foreach ( $indices as $index ) { |
|
| 1351 | - if ( in_array($def['name'],$index['fields']) ) { |
|
| 1352 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
| 1353 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
| 1350 | + foreach ($indices as $index) { |
|
| 1351 | + if (in_array($def['name'], $index['fields'])) { |
|
| 1352 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
| 1353 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | - $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
|
| 1357 | + $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired, $tablename); |
|
| 1358 | 1358 | } |
| 1359 | 1359 | } |
| 1360 | 1360 | else { |
| 1361 | 1361 | //if the column is being modified drop the default value |
| 1362 | 1362 | //constraint if it exists. alterSQLRep will add the constraint back |
| 1363 | 1363 | if (!empty($constraints[$fieldDefs['name']])) { |
| 1364 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']]; |
|
| 1364 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$fieldDefs['name']]; |
|
| 1365 | 1365 | } |
| 1366 | 1366 | //check to see if we need to drop related indexes before the alter |
| 1367 | 1367 | $indices = $this->get_indices($tablename); |
| 1368 | - foreach ( $indices as $index ) { |
|
| 1369 | - if ( in_array($fieldDefs['name'],$index['fields']) ) { |
|
| 1370 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
| 1371 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
| 1368 | + foreach ($indices as $index) { |
|
| 1369 | + if (in_array($fieldDefs['name'], $index['fields'])) { |
|
| 1370 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
| 1371 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | |
| 1376 | - $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename); |
|
| 1376 | + $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired, $tablename); |
|
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | 1379 | $columns = implode(", ", $columns); |
| 1380 | - $sql .= " ALTER TABLE $tablename $columns " . $sql2; |
|
| 1380 | + $sql .= " ALTER TABLE $tablename $columns ".$sql2; |
|
| 1381 | 1381 | |
| 1382 | 1382 | return $sql; |
| 1383 | 1383 | } |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | */ |
| 1393 | 1393 | public function setAutoIncrementStart($table, $field_name, $start_value) |
| 1394 | 1394 | { |
| 1395 | - if($start_value > 1) |
|
| 1395 | + if ($start_value > 1) |
|
| 1396 | 1396 | $start_value -= 1; |
| 1397 | 1397 | $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
| 1398 | 1398 | return true; |
@@ -1427,11 +1427,11 @@ discard block |
||
| 1427 | 1427 | $result = $this->query($query); |
| 1428 | 1428 | |
| 1429 | 1429 | $indices = array(); |
| 1430 | - while (($row=$this->fetchByAssoc($result)) != null) { |
|
| 1430 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
| 1431 | 1431 | $index_type = 'index'; |
| 1432 | 1432 | if ($row['is_primary_key'] == '1') |
| 1433 | 1433 | $index_type = 'primary'; |
| 1434 | - elseif ($row['is_unique'] == 1 ) |
|
| 1434 | + elseif ($row['is_unique'] == 1) |
|
| 1435 | 1435 | $index_type = 'unique'; |
| 1436 | 1436 | $name = strtolower($row['index_name']); |
| 1437 | 1437 | $indices[$name]['name'] = $name; |
@@ -1450,36 +1450,36 @@ discard block |
||
| 1450 | 1450 | $result = $this->query("sp_columns $tablename"); |
| 1451 | 1451 | |
| 1452 | 1452 | $columns = array(); |
| 1453 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
| 1453 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
| 1454 | 1454 | $column_name = strtolower($row['COLUMN_NAME']); |
| 1455 | - $columns[$column_name]['name']=$column_name; |
|
| 1456 | - $columns[$column_name]['type']=strtolower($row['TYPE_NAME']); |
|
| 1457 | - if ( $row['TYPE_NAME'] == 'decimal' ) { |
|
| 1458 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 1459 | - $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
|
| 1455 | + $columns[$column_name]['name'] = $column_name; |
|
| 1456 | + $columns[$column_name]['type'] = strtolower($row['TYPE_NAME']); |
|
| 1457 | + if ($row['TYPE_NAME'] == 'decimal') { |
|
| 1458 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
| 1459 | + $columns[$column_name]['len'] .= ','.strtolower($row['SCALE']); |
|
| 1460 | 1460 | } |
| 1461 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
| 1462 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 1463 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) |
|
| 1464 | - $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
| 1465 | - if ( stristr($row['TYPE_NAME'],'identity') ) { |
|
| 1461 | + elseif (in_array($row['TYPE_NAME'], array('nchar', 'nvarchar'))) |
|
| 1462 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
| 1463 | + elseif (!in_array($row['TYPE_NAME'], array('datetime', 'text'))) |
|
| 1464 | + $columns[$column_name]['len'] = strtolower($row['LENGTH']); |
|
| 1465 | + if (stristr($row['TYPE_NAME'], 'identity')) { |
|
| 1466 | 1466 | $columns[$column_name]['auto_increment'] = '1'; |
| 1467 | - $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
|
| 1467 | + $columns[$column_name]['type'] = str_replace(' identity', '', strtolower($row['TYPE_NAME'])); |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
| 1470 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'], 'PRI'))) |
|
| 1471 | 1471 | $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
| 1472 | 1472 | |
| 1473 | 1473 | $column_def = 1; |
| 1474 | - if ( strtolower($tablename) == 'relationships' ) { |
|
| 1474 | + if (strtolower($tablename) == 'relationships') { |
|
| 1475 | 1475 | $column_def = $this->getOne("select cdefault from syscolumns where id = object_id('relationships') and name = '$column_name'"); |
| 1476 | 1476 | } |
| 1477 | - if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
| 1477 | + if ($column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
| 1478 | 1478 | $matches = array(); |
| 1479 | - $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
|
| 1480 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 1479 | + $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'], ENT_QUOTES); |
|
| 1480 | + if (preg_match('/\([\(|\'](.*)[\)|\']\)/i', $row['COLUMN_DEF'], $matches)) |
|
| 1481 | 1481 | $columns[$column_name]['default'] = $matches[1]; |
| 1482 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 1482 | + elseif (preg_match('/\(N\'(.*)\'\)/i', $row['COLUMN_DEF'], $matches)) |
|
| 1483 | 1483 | $columns[$column_name]['default'] = $matches[1]; |
| 1484 | 1484 | else |
| 1485 | 1485 | $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | */ |
| 1495 | 1495 | protected function ftsCatalogName() |
| 1496 | 1496 | { |
| 1497 | - if(isset($this->connectOptions['db_name'])) { |
|
| 1497 | + if (isset($this->connectOptions['db_name'])) { |
|
| 1498 | 1498 | return $this->connectOptions['db_name']."_fts_catalog"; |
| 1499 | 1499 | } |
| 1500 | 1500 | return 'sugar_fts_catalog'; |
@@ -1506,11 +1506,11 @@ discard block |
||
| 1506 | 1506 | public function add_drop_constraint($table, $definition, $drop = false) |
| 1507 | 1507 | { |
| 1508 | 1508 | $type = $definition['type']; |
| 1509 | - $fields = is_array($definition['fields'])?implode(',',$definition['fields']):$definition['fields']; |
|
| 1509 | + $fields = is_array($definition['fields']) ? implode(',', $definition['fields']) : $definition['fields']; |
|
| 1510 | 1510 | $name = $definition['name']; |
| 1511 | 1511 | $sql = ''; |
| 1512 | 1512 | |
| 1513 | - switch ($type){ |
|
| 1513 | + switch ($type) { |
|
| 1514 | 1514 | // generic indices |
| 1515 | 1515 | case 'index': |
| 1516 | 1516 | case 'alternate_key': |
@@ -1548,13 +1548,13 @@ discard block |
||
| 1548 | 1548 | if ($this->full_text_indexing_enabled() && $drop) { |
| 1549 | 1549 | $sql = "DROP FULLTEXT INDEX ON {$table}"; |
| 1550 | 1550 | } elseif ($this->full_text_indexing_enabled()) { |
| 1551 | - $catalog_name=$this->ftsCatalogName(); |
|
| 1552 | - if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
| 1551 | + $catalog_name = $this->ftsCatalogName(); |
|
| 1552 | + if (isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
| 1553 | 1553 | $catalog_name = $definition['catalog_name']; |
| 1554 | 1554 | |
| 1555 | 1555 | $language = "Language 1033"; |
| 1556 | 1556 | if (isset($definition['language']) && !empty($definition['language'])) |
| 1557 | - $language = "Language " . $definition['language']; |
|
| 1557 | + $language = "Language ".$definition['language']; |
|
| 1558 | 1558 | |
| 1559 | 1559 | $key_index = $definition['key_index']; |
| 1560 | 1560 | |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) |
| 1563 | 1563 | $change_tracking = $definition['change_tracking']; |
| 1564 | 1564 | |
| 1565 | - $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking" ; |
|
| 1565 | + $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking"; |
|
| 1566 | 1566 | } |
| 1567 | 1567 | break; |
| 1568 | 1568 | } |
@@ -1586,11 +1586,11 @@ discard block |
||
| 1586 | 1586 | protected function full_text_indexing_enabled($dbname = null) |
| 1587 | 1587 | { |
| 1588 | 1588 | // check to see if we already have install setting in session |
| 1589 | - if(!isset($_SESSION['IsFulltextInstalled'])) |
|
| 1589 | + if (!isset($_SESSION['IsFulltextInstalled'])) |
|
| 1590 | 1590 | $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
| 1591 | 1591 | |
| 1592 | 1592 | // check to see if FTS Indexing service is installed |
| 1593 | - if(empty($_SESSION['IsFulltextInstalled'])) |
|
| 1593 | + if (empty($_SESSION['IsFulltextInstalled'])) |
|
| 1594 | 1594 | return false; |
| 1595 | 1595 | |
| 1596 | 1596 | // grab the dbname if it was not passed through |
@@ -1640,7 +1640,7 @@ discard block |
||
| 1640 | 1640 | { |
| 1641 | 1641 | static $results = array(); |
| 1642 | 1642 | |
| 1643 | - if ( empty($column) && isset($results[$table]) ) |
|
| 1643 | + if (empty($column) && isset($results[$table])) |
|
| 1644 | 1644 | return $results[$table]; |
| 1645 | 1645 | |
| 1646 | 1646 | $query = <<<EOQ |
@@ -1654,17 +1654,17 @@ discard block |
||
| 1654 | 1654 | on s.schema_id = o.schema_id |
| 1655 | 1655 | where o.name = '$table' |
| 1656 | 1656 | EOQ; |
| 1657 | - if ( !empty($column) ) |
|
| 1657 | + if (!empty($column)) |
|
| 1658 | 1658 | $query .= " and c.name = '$column'"; |
| 1659 | 1659 | $res = $this->query($query); |
| 1660 | - if ( !empty($column) ) { |
|
| 1660 | + if (!empty($column)) { |
|
| 1661 | 1661 | $row = $this->fetchByAssoc($res); |
| 1662 | 1662 | if (!empty($row)) |
| 1663 | 1663 | return $row['ctrt']; |
| 1664 | 1664 | } |
| 1665 | 1665 | else { |
| 1666 | 1666 | $returnResult = array(); |
| 1667 | - while ( $row = $this->fetchByAssoc($res) ) |
|
| 1667 | + while ($row = $this->fetchByAssoc($res)) |
|
| 1668 | 1668 | $returnResult[$row['dtrt']] = $row['ctrt']; |
| 1669 | 1669 | $results[$table] = $returnResult; |
| 1670 | 1670 | return $returnResult; |
@@ -1678,14 +1678,14 @@ discard block |
||
| 1678 | 1678 | */ |
| 1679 | 1679 | public function massageFieldDef(&$fieldDef, $tablename) |
| 1680 | 1680 | { |
| 1681 | - parent::massageFieldDef($fieldDef,$tablename); |
|
| 1681 | + parent::massageFieldDef($fieldDef, $tablename); |
|
| 1682 | 1682 | |
| 1683 | 1683 | if ($fieldDef['type'] == 'int') |
| 1684 | 1684 | $fieldDef['len'] = '4'; |
| 1685 | 1685 | |
| 1686 | - if(empty($fieldDef['len'])) |
|
| 1686 | + if (empty($fieldDef['len'])) |
|
| 1687 | 1687 | { |
| 1688 | - switch($fieldDef['type']) { |
|
| 1688 | + switch ($fieldDef['type']) { |
|
| 1689 | 1689 | case 'bit' : |
| 1690 | 1690 | case 'bool' : $fieldDef['len'] = '1'; break; |
| 1691 | 1691 | case 'smallint' : $fieldDef['len'] = '2'; break; |
@@ -1695,22 +1695,22 @@ discard block |
||
| 1695 | 1695 | $fieldDef['len'] = $this->isTextType($fieldDef['dbType']) ? 'max' : '255'; |
| 1696 | 1696 | break; |
| 1697 | 1697 | case 'image' : $fieldDef['len'] = '2147483647'; break; |
| 1698 | - case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
| 1698 | + case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
| 1699 | 1699 | } |
| 1700 | 1700 | } |
| 1701 | - if($fieldDef['type'] == 'decimal' |
|
| 1701 | + if ($fieldDef['type'] == 'decimal' |
|
| 1702 | 1702 | && empty($fieldDef['precision']) |
| 1703 | 1703 | && !strpos($fieldDef['len'], ',')) |
| 1704 | 1704 | { |
| 1705 | 1705 | $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified |
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | - if(empty($fieldDef['default']) |
|
| 1709 | - && in_array($fieldDef['type'],array('bit','bool'))) |
|
| 1708 | + if (empty($fieldDef['default']) |
|
| 1709 | + && in_array($fieldDef['type'], array('bit', 'bool'))) |
|
| 1710 | 1710 | { |
| 1711 | 1711 | $fieldDef['default'] = '0'; |
| 1712 | 1712 | } |
| 1713 | - if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
| 1713 | + if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default'])) |
|
| 1714 | 1714 | $fieldDef['default'] = ''; |
| 1715 | 1715 | // if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
| 1716 | 1716 | // $fieldDef['len'] = '1'; |
@@ -1741,13 +1741,13 @@ discard block |
||
| 1741 | 1741 | protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
| 1742 | 1742 | { |
| 1743 | 1743 | //Bug 25814 |
| 1744 | - if(isset($fieldDef['name'])){ |
|
| 1744 | + if (isset($fieldDef['name'])) { |
|
| 1745 | 1745 | $colType = $this->getFieldType($fieldDef); |
| 1746 | - if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){ |
|
| 1747 | - $fieldDef['len'] = min($fieldDef['len'],38); |
|
| 1746 | + if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { |
|
| 1747 | + $fieldDef['len'] = min($fieldDef['len'], 38); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair |
| 1750 | - if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){ |
|
| 1750 | + if (stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8) { |
|
| 1751 | 1751 | unset($fieldDef['len']); |
| 1752 | 1752 | } |
| 1753 | 1753 | } |
@@ -1756,10 +1756,10 @@ discard block |
||
| 1756 | 1756 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
| 1757 | 1757 | |
| 1758 | 1758 | // Bug 24307 - Don't add precision for float fields. |
| 1759 | - if ( stristr($ref['colType'],'float') ) |
|
| 1760 | - $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
| 1759 | + if (stristr($ref['colType'], 'float')) |
|
| 1760 | + $ref['colType'] = preg_replace('/(,\d+)/', '', $ref['colType']); |
|
| 1761 | 1761 | |
| 1762 | - if ( $return_as_array ) |
|
| 1762 | + if ($return_as_array) |
|
| 1763 | 1763 | return $ref; |
| 1764 | 1764 | else |
| 1765 | 1765 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
@@ -1774,10 +1774,10 @@ discard block |
||
| 1774 | 1774 | public function save_audit_records(SugarBean $bean, $changes) |
| 1775 | 1775 | { |
| 1776 | 1776 | //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00" |
| 1777 | - if($changes['data_type'] == 'date'){ |
|
| 1778 | - $changes['before'] = str_replace(' 00:00:00','',$changes['before']); |
|
| 1777 | + if ($changes['data_type'] == 'date') { |
|
| 1778 | + $changes['before'] = str_replace(' 00:00:00', '', $changes['before']); |
|
| 1779 | 1779 | } |
| 1780 | - parent::save_audit_records($bean,$changes); |
|
| 1780 | + parent::save_audit_records($bean, $changes); |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | /** |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | public function disconnect() |
| 1789 | 1789 | { |
| 1790 | 1790 | $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
| 1791 | - if(!empty($this->database)){ |
|
| 1791 | + if (!empty($this->database)) { |
|
| 1792 | 1792 | $this->freeResult(); |
| 1793 | 1793 | mssql_close($this->database); |
| 1794 | 1794 | $this->database = null; |
@@ -1800,7 +1800,7 @@ discard block |
||
| 1800 | 1800 | */ |
| 1801 | 1801 | protected function freeDbResult($dbResult) |
| 1802 | 1802 | { |
| 1803 | - if(!empty($dbResult)) |
|
| 1803 | + if (!empty($dbResult)) |
|
| 1804 | 1804 | mssql_free_result($dbResult); |
| 1805 | 1805 | } |
| 1806 | 1806 | |
@@ -1811,11 +1811,11 @@ discard block |
||
| 1811 | 1811 | public function lastDbError() |
| 1812 | 1812 | { |
| 1813 | 1813 | $sqlmsg = mssql_get_last_message(); |
| 1814 | - if(empty($sqlmsg)) return false; |
|
| 1814 | + if (empty($sqlmsg)) return false; |
|
| 1815 | 1815 | global $app_strings; |
| 1816 | 1816 | if (empty($app_strings) |
| 1817 | 1817 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
| 1818 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
| 1818 | + or !isset($app_strings['ERR_MSSQL_WARNING'])) { |
|
| 1819 | 1819 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
| 1820 | 1820 | //only if connection if made before language is set. |
| 1821 | 1821 | return false; |
@@ -1824,7 +1824,7 @@ discard block |
||
| 1824 | 1824 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
| 1825 | 1825 | $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
| 1826 | 1826 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
| 1827 | - if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) { |
|
| 1827 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { |
|
| 1828 | 1828 | return false; |
| 1829 | 1829 | } else { |
| 1830 | 1830 | global $app_strings; |
@@ -1832,18 +1832,18 @@ discard block |
||
| 1832 | 1832 | if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { |
| 1833 | 1833 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
| 1834 | 1834 | //only if connection if made before languge is set. |
| 1835 | - $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); |
|
| 1835 | + $GLOBALS['log']->debug("Ignoring this database message: ".$sqlmsg); |
|
| 1836 | 1836 | return false; |
| 1837 | 1837 | } |
| 1838 | 1838 | else { |
| 1839 | 1839 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
| 1840 | - if ( $sqlpos !== false ) |
|
| 1840 | + if ($sqlpos !== false) |
|
| 1841 | 1841 | return false; |
| 1842 | 1842 | } |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | - if ( strlen($sqlmsg) > 2 ) { |
|
| 1846 | - return "SQL Server error: " . $sqlmsg; |
|
| 1845 | + if (strlen($sqlmsg) > 2) { |
|
| 1846 | + return "SQL Server error: ".$sqlmsg; |
|
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | return false; |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | */ |
| 1865 | 1865 | public function validateQuery($query) |
| 1866 | 1866 | { |
| 1867 | - if(!$this->isSelect($query)) { |
|
| 1867 | + if (!$this->isSelect($query)) { |
|
| 1868 | 1868 | return false; |
| 1869 | 1869 | } |
| 1870 | 1870 | $this->query("SET SHOWPLAN_TEXT ON"); |
@@ -1888,7 +1888,7 @@ discard block |
||
| 1888 | 1888 | |
| 1889 | 1889 | // Flag if there are odd number of single quotes, just continue without trying to append N |
| 1890 | 1890 | if ((substr_count($sql, "'") & 1)) { |
| 1891 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
| 1891 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
| 1892 | 1892 | return $sql; |
| 1893 | 1893 | } |
| 1894 | 1894 | |
@@ -1918,7 +1918,7 @@ discard block |
||
| 1918 | 1918 | // We are assuming that all nvarchar columns are no more than 200 characters in length |
| 1919 | 1919 | // One problem we face is the image column type in reports which cannot accept nvarchar data |
| 1920 | 1920 | if (!empty($value) && !is_numeric(trim(str_replace(array("'", ","), "", $value))) && !preg_match('/^\'[\,]\'$/', $value)) { |
| 1921 | - $replace[$value] = 'N' . trim($value, "N"); |
|
| 1921 | + $replace[$value] = 'N'.trim($value, "N"); |
|
| 1922 | 1922 | } |
| 1923 | 1923 | } |
| 1924 | 1924 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
| 1929 | 1929 | if (!empty($pairs)) |
| 1930 | 1930 | $sql = str_replace(array_keys($pairs), $pairs, $sql); |
| 1931 | 1931 | |
| 1932 | - if(strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
| 1932 | + if (strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
| 1933 | 1933 | $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql); |
| 1934 | 1934 | |
| 1935 | 1935 | return $sql; |
@@ -1956,22 +1956,22 @@ discard block |
||
| 1956 | 1956 | public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
| 1957 | 1957 | { |
| 1958 | 1958 | $condition = $or_condition = array(); |
| 1959 | - foreach($must_terms as $term) { |
|
| 1959 | + foreach ($must_terms as $term) { |
|
| 1960 | 1960 | $condition[] = $this->quoteTerm($term); |
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | - foreach($terms as $term) { |
|
| 1963 | + foreach ($terms as $term) { |
|
| 1964 | 1964 | $or_condition[] = $this->quoteTerm($term); |
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | - if(!empty($or_condition)) { |
|
| 1967 | + if (!empty($or_condition)) { |
|
| 1968 | 1968 | $condition[] = "(".join(" | ", $or_condition).")"; |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | - foreach($exclude_terms as $term) { |
|
| 1971 | + foreach ($exclude_terms as $term) { |
|
| 1972 | 1972 | $condition[] = " NOT ".$this->quoteTerm($term); |
| 1973 | 1973 | } |
| 1974 | - $condition = $this->quoted(join(" AND ",$condition)); |
|
| 1974 | + $condition = $this->quoted(join(" AND ", $condition)); |
|
| 1975 | 1975 | return "CONTAINS($field, $condition)"; |
| 1976 | 1976 | } |
| 1977 | 1977 | |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | public function isDatabaseNameValid($name) |
| 2061 | 2061 | { |
| 2062 | 2062 | // No funny chars, does not begin with number |
| 2063 | - return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name)==0; |
|
| 2063 | + return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name) == 0; |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | public function installConfig() |
@@ -97,389 +97,389 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | abstract class DBManager |
| 99 | 99 | { |
| 100 | - /** |
|
| 101 | - * Name of database |
|
| 102 | - * @var resource |
|
| 103 | - */ |
|
| 104 | - public $database = null; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Indicates whether we should die when we get an error from the DB |
|
| 108 | - */ |
|
| 109 | - protected $dieOnError = false; |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Indicates whether we should html encode the results from a query by default |
|
| 113 | - */ |
|
| 114 | - protected $encode = true; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Records the execution time of the last query |
|
| 118 | - */ |
|
| 119 | - protected $query_time = 0; |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Last error message from the DB backend |
|
| 123 | - */ |
|
| 124 | - protected $last_error = false; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Registry of available result sets |
|
| 128 | - */ |
|
| 129 | - protected $lastResult; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Current query count |
|
| 133 | - */ |
|
| 134 | - private static $queryCount = 0; |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Query threshold limit |
|
| 138 | - */ |
|
| 139 | - private static $queryLimit = 0; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Array of prepared statements and their correspoding parsed tokens |
|
| 143 | - */ |
|
| 144 | - protected $preparedTokens = array(); |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * TimeDate instance |
|
| 148 | - * @var TimeDate |
|
| 149 | - */ |
|
| 150 | - protected $timedate; |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * PHP Logger |
|
| 154 | - * @var Logger |
|
| 155 | - */ |
|
| 156 | - protected $log; |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Table descriptions |
|
| 160 | - * @var array |
|
| 161 | - */ |
|
| 162 | - protected static $table_descriptions = array(); |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Index descriptions |
|
| 166 | - * @var array |
|
| 167 | - */ |
|
| 168 | - protected static $index_descriptions = array(); |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Maximum length of identifiers |
|
| 172 | - * @abstract |
|
| 173 | - * @var array |
|
| 174 | - */ |
|
| 175 | - protected $maxNameLengths = array( |
|
| 176 | - 'table' => 64, |
|
| 177 | - 'column' => 64, |
|
| 178 | - 'index' => 64, |
|
| 179 | - 'alias' => 64 |
|
| 180 | - ); |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * DB driver priority |
|
| 184 | - * Higher priority drivers override lower priority ones |
|
| 185 | - * @var int |
|
| 186 | - */ |
|
| 187 | - public $priority = 0; |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Driver name label, for install |
|
| 191 | - * @absrtact |
|
| 192 | - * @var string |
|
| 193 | - */ |
|
| 194 | - public $label = ''; |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Type names map |
|
| 198 | - * @abstract |
|
| 199 | - * @var array |
|
| 200 | - */ |
|
| 201 | - protected $type_map = array(); |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Type classification into: |
|
| 205 | - * - int |
|
| 206 | - * - bool |
|
| 207 | - * - float |
|
| 208 | - * - date |
|
| 209 | - * @abstract |
|
| 210 | - * @var array |
|
| 211 | - */ |
|
| 212 | - protected $type_class = array( |
|
| 213 | - 'int' => 'int', |
|
| 214 | - 'double' => 'float', |
|
| 215 | - 'float' => 'float', |
|
| 216 | - 'uint' => 'int', |
|
| 217 | - 'ulong' => 'bigint', |
|
| 218 | - 'long' => 'bigint', |
|
| 219 | - 'short' => 'int', |
|
| 220 | - 'date' => 'date', |
|
| 221 | - 'datetime' => 'date', |
|
| 222 | - 'datetimecombo' => 'date', |
|
| 223 | - 'time' => 'time', |
|
| 224 | - 'bool' => 'bool', |
|
| 225 | - 'tinyint' => 'int', |
|
| 226 | - 'currency' => 'float', |
|
| 227 | - 'decimal' => 'float', |
|
| 228 | - 'decimal2' => 'float', |
|
| 229 | - ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Capabilities this DB supports. Supported list: |
|
| 233 | - * affected_rows Can report query affected rows for UPDATE/DELETE |
|
| 234 | - * implement getAffectedRowCount() |
|
| 235 | - * select_rows Can report row count for SELECT |
|
| 236 | - * implement getRowCount() |
|
| 237 | - * case_sensitive Supports case-sensitive text columns |
|
| 238 | - * fulltext Supports fulltext search indexes |
|
| 239 | - * inline_keys Supports defining keys together with the table |
|
| 240 | - * auto_increment_sequence Autoincrement support implemented as sequence |
|
| 241 | - * limit_subquery Supports LIMIT clauses in subqueries |
|
| 242 | - * create_user Can create users for Sugar |
|
| 243 | - * create_db Can create databases |
|
| 244 | - * collation Supports setting collations |
|
| 245 | - * disable_keys Supports temporarily disabling keys (for upgrades, etc.) |
|
| 246 | - * |
|
| 247 | - * @abstract |
|
| 248 | - * Special cases: |
|
| 249 | - * fix:expandDatabase - needs expandDatabase fix, see expandDatabase.php |
|
| 250 | - * TODO: verify if we need these cases |
|
| 251 | - */ |
|
| 252 | - protected $capabilities = array(); |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Database options |
|
| 256 | - * @var array |
|
| 257 | - */ |
|
| 258 | - protected $options = array(); |
|
| 100 | + /** |
|
| 101 | + * Name of database |
|
| 102 | + * @var resource |
|
| 103 | + */ |
|
| 104 | + public $database = null; |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Indicates whether we should die when we get an error from the DB |
|
| 108 | + */ |
|
| 109 | + protected $dieOnError = false; |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Indicates whether we should html encode the results from a query by default |
|
| 113 | + */ |
|
| 114 | + protected $encode = true; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Records the execution time of the last query |
|
| 118 | + */ |
|
| 119 | + protected $query_time = 0; |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Last error message from the DB backend |
|
| 123 | + */ |
|
| 124 | + protected $last_error = false; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Registry of available result sets |
|
| 128 | + */ |
|
| 129 | + protected $lastResult; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Current query count |
|
| 133 | + */ |
|
| 134 | + private static $queryCount = 0; |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Query threshold limit |
|
| 138 | + */ |
|
| 139 | + private static $queryLimit = 0; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Array of prepared statements and their correspoding parsed tokens |
|
| 143 | + */ |
|
| 144 | + protected $preparedTokens = array(); |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * TimeDate instance |
|
| 148 | + * @var TimeDate |
|
| 149 | + */ |
|
| 150 | + protected $timedate; |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * PHP Logger |
|
| 154 | + * @var Logger |
|
| 155 | + */ |
|
| 156 | + protected $log; |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Table descriptions |
|
| 160 | + * @var array |
|
| 161 | + */ |
|
| 162 | + protected static $table_descriptions = array(); |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Index descriptions |
|
| 166 | + * @var array |
|
| 167 | + */ |
|
| 168 | + protected static $index_descriptions = array(); |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Maximum length of identifiers |
|
| 172 | + * @abstract |
|
| 173 | + * @var array |
|
| 174 | + */ |
|
| 175 | + protected $maxNameLengths = array( |
|
| 176 | + 'table' => 64, |
|
| 177 | + 'column' => 64, |
|
| 178 | + 'index' => 64, |
|
| 179 | + 'alias' => 64 |
|
| 180 | + ); |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * DB driver priority |
|
| 184 | + * Higher priority drivers override lower priority ones |
|
| 185 | + * @var int |
|
| 186 | + */ |
|
| 187 | + public $priority = 0; |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Driver name label, for install |
|
| 191 | + * @absrtact |
|
| 192 | + * @var string |
|
| 193 | + */ |
|
| 194 | + public $label = ''; |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Type names map |
|
| 198 | + * @abstract |
|
| 199 | + * @var array |
|
| 200 | + */ |
|
| 201 | + protected $type_map = array(); |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Type classification into: |
|
| 205 | + * - int |
|
| 206 | + * - bool |
|
| 207 | + * - float |
|
| 208 | + * - date |
|
| 209 | + * @abstract |
|
| 210 | + * @var array |
|
| 211 | + */ |
|
| 212 | + protected $type_class = array( |
|
| 213 | + 'int' => 'int', |
|
| 214 | + 'double' => 'float', |
|
| 215 | + 'float' => 'float', |
|
| 216 | + 'uint' => 'int', |
|
| 217 | + 'ulong' => 'bigint', |
|
| 218 | + 'long' => 'bigint', |
|
| 219 | + 'short' => 'int', |
|
| 220 | + 'date' => 'date', |
|
| 221 | + 'datetime' => 'date', |
|
| 222 | + 'datetimecombo' => 'date', |
|
| 223 | + 'time' => 'time', |
|
| 224 | + 'bool' => 'bool', |
|
| 225 | + 'tinyint' => 'int', |
|
| 226 | + 'currency' => 'float', |
|
| 227 | + 'decimal' => 'float', |
|
| 228 | + 'decimal2' => 'float', |
|
| 229 | + ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Capabilities this DB supports. Supported list: |
|
| 233 | + * affected_rows Can report query affected rows for UPDATE/DELETE |
|
| 234 | + * implement getAffectedRowCount() |
|
| 235 | + * select_rows Can report row count for SELECT |
|
| 236 | + * implement getRowCount() |
|
| 237 | + * case_sensitive Supports case-sensitive text columns |
|
| 238 | + * fulltext Supports fulltext search indexes |
|
| 239 | + * inline_keys Supports defining keys together with the table |
|
| 240 | + * auto_increment_sequence Autoincrement support implemented as sequence |
|
| 241 | + * limit_subquery Supports LIMIT clauses in subqueries |
|
| 242 | + * create_user Can create users for Sugar |
|
| 243 | + * create_db Can create databases |
|
| 244 | + * collation Supports setting collations |
|
| 245 | + * disable_keys Supports temporarily disabling keys (for upgrades, etc.) |
|
| 246 | + * |
|
| 247 | + * @abstract |
|
| 248 | + * Special cases: |
|
| 249 | + * fix:expandDatabase - needs expandDatabase fix, see expandDatabase.php |
|
| 250 | + * TODO: verify if we need these cases |
|
| 251 | + */ |
|
| 252 | + protected $capabilities = array(); |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Database options |
|
| 256 | + * @var array |
|
| 257 | + */ |
|
| 258 | + protected $options = array(); |
|
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Create DB Driver |
| 262 | 262 | */ |
| 263 | - public function __construct() |
|
| 264 | - { |
|
| 265 | - $this->timedate = TimeDate::getInstance(); |
|
| 266 | - $this->log = isset($GLOBALS['log']) ? $GLOBALS['log'] : null; |
|
| 267 | - $this->helper = $this; // compatibility |
|
| 268 | - } |
|
| 263 | + public function __construct() |
|
| 264 | + { |
|
| 265 | + $this->timedate = TimeDate::getInstance(); |
|
| 266 | + $this->log = isset($GLOBALS['log']) ? $GLOBALS['log'] : null; |
|
| 267 | + $this->helper = $this; // compatibility |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * Wrapper for those trying to access the private and protected class members directly |
| 272 | 272 | * @param string $p var name |
| 273 | 273 | * @return mixed |
| 274 | 274 | */ |
| 275 | - public function __get($p) |
|
| 276 | - { |
|
| 277 | - $this->log->info('Call to DBManager::$'.$p.' is deprecated'); |
|
| 278 | - return $this->$p; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Returns the current database handle |
|
| 283 | - * @return resource |
|
| 284 | - */ |
|
| 285 | - public function getDatabase() |
|
| 286 | - { |
|
| 287 | - $this->checkConnection(); |
|
| 288 | - return $this->database; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Returns this instance's DBHelper |
|
| 293 | - * Actually now returns $this |
|
| 294 | - * @deprecated |
|
| 295 | - * @return DBManager |
|
| 296 | - */ |
|
| 297 | - public function getHelper() |
|
| 298 | - { |
|
| 299 | - return $this; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * Checks for error happening in the database |
|
| 304 | - * |
|
| 305 | - * @param string $msg message to prepend to the error message |
|
| 306 | - * @param bool $dieOnError true if we want to die immediately on error |
|
| 307 | - * @return bool True if there was an error |
|
| 308 | - */ |
|
| 309 | - public function checkError($msg = '', $dieOnError = false) |
|
| 310 | - { |
|
| 311 | - if (empty($this->database)) { |
|
| 312 | - $this->registerError($msg, "Database Is Not Connected", $dieOnError); |
|
| 313 | - return true; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - $dberror = $this->lastDbError(); |
|
| 317 | - if($dberror === false) { |
|
| 318 | - $this->last_error = false; |
|
| 319 | - return false; |
|
| 320 | - } |
|
| 321 | - $this->registerError($msg, $dberror, $dieOnError); |
|
| 275 | + public function __get($p) |
|
| 276 | + { |
|
| 277 | + $this->log->info('Call to DBManager::$'.$p.' is deprecated'); |
|
| 278 | + return $this->$p; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * Returns the current database handle |
|
| 283 | + * @return resource |
|
| 284 | + */ |
|
| 285 | + public function getDatabase() |
|
| 286 | + { |
|
| 287 | + $this->checkConnection(); |
|
| 288 | + return $this->database; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Returns this instance's DBHelper |
|
| 293 | + * Actually now returns $this |
|
| 294 | + * @deprecated |
|
| 295 | + * @return DBManager |
|
| 296 | + */ |
|
| 297 | + public function getHelper() |
|
| 298 | + { |
|
| 299 | + return $this; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * Checks for error happening in the database |
|
| 304 | + * |
|
| 305 | + * @param string $msg message to prepend to the error message |
|
| 306 | + * @param bool $dieOnError true if we want to die immediately on error |
|
| 307 | + * @return bool True if there was an error |
|
| 308 | + */ |
|
| 309 | + public function checkError($msg = '', $dieOnError = false) |
|
| 310 | + { |
|
| 311 | + if (empty($this->database)) { |
|
| 312 | + $this->registerError($msg, "Database Is Not Connected", $dieOnError); |
|
| 313 | + return true; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + $dberror = $this->lastDbError(); |
|
| 317 | + if($dberror === false) { |
|
| 318 | + $this->last_error = false; |
|
| 319 | + return false; |
|
| 320 | + } |
|
| 321 | + $this->registerError($msg, $dberror, $dieOnError); |
|
| 322 | 322 | return true; |
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Register database error |
|
| 327 | - * If die-on-error flag is set, logs the message and dies, |
|
| 328 | - * otherwise sets last_error to the message |
|
| 329 | - * @param string $userMessage Message from function user |
|
| 330 | - * @param string $message Message from SQL driver |
|
| 331 | - * @param bool $dieOnError |
|
| 332 | - */ |
|
| 333 | - protected function registerError($userMessage, $message, $dieOnError = false) |
|
| 334 | - { |
|
| 335 | - if(!empty($message)) { |
|
| 336 | - if(!empty($userMessage)) { |
|
| 337 | - $message = "$userMessage: $message"; |
|
| 338 | - } |
|
| 339 | - if(empty($message)) { |
|
| 340 | - $message = "Database error"; |
|
| 341 | - } |
|
| 342 | - $this->log->fatal($message); |
|
| 343 | - if ($dieOnError || $this->dieOnError) { |
|
| 344 | - if(isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 345 | - sugar_die($GLOBALS['app_strings']['ERR_DB_FAIL']); |
|
| 346 | - } else { |
|
| 347 | - sugar_die("Database error. Please check suitecrm.log for details."); |
|
| 348 | - } |
|
| 349 | - } else { |
|
| 350 | - $this->last_error = $message; |
|
| 351 | - } |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Return DB error message for the last query executed |
|
| 357 | - * @return string Last error message |
|
| 358 | - */ |
|
| 359 | - public function lastError() |
|
| 360 | - { |
|
| 361 | - return $this->last_error; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * This method is called by every method that runs a query. |
|
| 366 | - * If slow query dumping is turned on and the query time is beyond |
|
| 367 | - * the time limit, we will log the query. This function may do |
|
| 368 | - * additional reporting or log in a different area in the future. |
|
| 369 | - * |
|
| 370 | - * @param string $query query to log |
|
| 371 | - * @return boolean true if the query was logged, false otherwise |
|
| 372 | - */ |
|
| 373 | - protected function dump_slow_queries($query) |
|
| 374 | - { |
|
| 375 | - global $sugar_config; |
|
| 376 | - |
|
| 377 | - $do_the_dump = isset($sugar_config['dump_slow_queries']) |
|
| 378 | - ? $sugar_config['dump_slow_queries'] : false; |
|
| 379 | - $slow_query_time_msec = isset($sugar_config['slow_query_time_msec']) |
|
| 380 | - ? $sugar_config['slow_query_time_msec'] : 5000; |
|
| 381 | - |
|
| 382 | - if($do_the_dump) { |
|
| 383 | - if($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 384 | - // Then log both the query and the query time |
|
| 385 | - $this->log->fatal('Slow Query (time:'.$this->query_time."\n".$query); |
|
| 386 | - return true; |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - return false; |
|
| 390 | - } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Register database error |
|
| 327 | + * If die-on-error flag is set, logs the message and dies, |
|
| 328 | + * otherwise sets last_error to the message |
|
| 329 | + * @param string $userMessage Message from function user |
|
| 330 | + * @param string $message Message from SQL driver |
|
| 331 | + * @param bool $dieOnError |
|
| 332 | + */ |
|
| 333 | + protected function registerError($userMessage, $message, $dieOnError = false) |
|
| 334 | + { |
|
| 335 | + if(!empty($message)) { |
|
| 336 | + if(!empty($userMessage)) { |
|
| 337 | + $message = "$userMessage: $message"; |
|
| 338 | + } |
|
| 339 | + if(empty($message)) { |
|
| 340 | + $message = "Database error"; |
|
| 341 | + } |
|
| 342 | + $this->log->fatal($message); |
|
| 343 | + if ($dieOnError || $this->dieOnError) { |
|
| 344 | + if(isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 345 | + sugar_die($GLOBALS['app_strings']['ERR_DB_FAIL']); |
|
| 346 | + } else { |
|
| 347 | + sugar_die("Database error. Please check suitecrm.log for details."); |
|
| 348 | + } |
|
| 349 | + } else { |
|
| 350 | + $this->last_error = $message; |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Return DB error message for the last query executed |
|
| 357 | + * @return string Last error message |
|
| 358 | + */ |
|
| 359 | + public function lastError() |
|
| 360 | + { |
|
| 361 | + return $this->last_error; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * This method is called by every method that runs a query. |
|
| 366 | + * If slow query dumping is turned on and the query time is beyond |
|
| 367 | + * the time limit, we will log the query. This function may do |
|
| 368 | + * additional reporting or log in a different area in the future. |
|
| 369 | + * |
|
| 370 | + * @param string $query query to log |
|
| 371 | + * @return boolean true if the query was logged, false otherwise |
|
| 372 | + */ |
|
| 373 | + protected function dump_slow_queries($query) |
|
| 374 | + { |
|
| 375 | + global $sugar_config; |
|
| 376 | + |
|
| 377 | + $do_the_dump = isset($sugar_config['dump_slow_queries']) |
|
| 378 | + ? $sugar_config['dump_slow_queries'] : false; |
|
| 379 | + $slow_query_time_msec = isset($sugar_config['slow_query_time_msec']) |
|
| 380 | + ? $sugar_config['slow_query_time_msec'] : 5000; |
|
| 381 | + |
|
| 382 | + if($do_the_dump) { |
|
| 383 | + if($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 384 | + // Then log both the query and the query time |
|
| 385 | + $this->log->fatal('Slow Query (time:'.$this->query_time."\n".$query); |
|
| 386 | + return true; |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + return false; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | - * Scans order by to ensure that any field being ordered by is. |
|
| 394 | - * |
|
| 395 | - * It will throw a warning error to the log file - fatal if slow query logging is enabled |
|
| 396 | - * |
|
| 397 | - * @param string $sql query to be run |
|
| 398 | - * @param bool $object_name optional, object to look up indices in |
|
| 399 | - * @return bool true if an index is found false otherwise |
|
| 400 | - */ |
|
| 393 | + * Scans order by to ensure that any field being ordered by is. |
|
| 394 | + * |
|
| 395 | + * It will throw a warning error to the log file - fatal if slow query logging is enabled |
|
| 396 | + * |
|
| 397 | + * @param string $sql query to be run |
|
| 398 | + * @param bool $object_name optional, object to look up indices in |
|
| 399 | + * @return bool true if an index is found false otherwise |
|
| 400 | + */ |
|
| 401 | 401 | protected function checkQuery($sql, $object_name = false) |
| 402 | 402 | { |
| 403 | - $match = array(); |
|
| 404 | - preg_match_all("'.* FROM ([^ ]*).* ORDER BY (.*)'is", $sql, $match); |
|
| 405 | - $indices = false; |
|
| 406 | - if (!empty($match[1][0])) |
|
| 407 | - $table = $match[1][0]; |
|
| 408 | - else |
|
| 409 | - return false; |
|
| 410 | - |
|
| 411 | - if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) |
|
| 412 | - $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 413 | - |
|
| 414 | - if (empty($indices)) { |
|
| 415 | - foreach ( $GLOBALS['dictionary'] as $current ) { |
|
| 416 | - if ($current['table'] == $table){ |
|
| 417 | - $indices = $current['indices']; |
|
| 418 | - break; |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - if (empty($indices)) { |
|
| 423 | - $this->log->warn('CHECK QUERY: Could not find index definitions for table ' . $table); |
|
| 424 | - return false; |
|
| 425 | - } |
|
| 426 | - if (!empty($match[2][0])) { |
|
| 427 | - $orderBys = explode(' ', $match[2][0]); |
|
| 428 | - foreach ($orderBys as $orderBy){ |
|
| 429 | - $orderBy = trim($orderBy); |
|
| 430 | - if (empty($orderBy)) |
|
| 431 | - continue; |
|
| 432 | - $orderBy = strtolower($orderBy); |
|
| 433 | - if ($orderBy == 'asc' || $orderBy == 'desc') |
|
| 434 | - continue; |
|
| 435 | - |
|
| 436 | - $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
|
| 437 | - |
|
| 438 | - foreach ($indices as $index) |
|
| 439 | - if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 440 | - foreach ($index['fields'] as $field) |
|
| 441 | - if ($field == $orderBy) |
|
| 442 | - return true; |
|
| 443 | - |
|
| 444 | - $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
|
| 445 | - if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
|
| 446 | - $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 447 | - else |
|
| 448 | - $this->log->warn('CHECK QUERY:' .$warning); |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - return false; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * Returns the time the last query took to execute |
|
| 456 | - * |
|
| 457 | - * @return int |
|
| 458 | - */ |
|
| 459 | - public function getQueryTime() |
|
| 460 | - { |
|
| 461 | - return $this->query_time; |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * Checks the current connection; if it is not connected then reconnect |
|
| 466 | - */ |
|
| 467 | - public function checkConnection() |
|
| 468 | - { |
|
| 469 | - $this->last_error = ''; |
|
| 470 | - if (!isset($this->database)) |
|
| 471 | - $this->connect(); |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Sets the dieOnError value |
|
| 476 | - * |
|
| 477 | - * @param bool $value |
|
| 478 | - */ |
|
| 479 | - public function setDieOnError($value) |
|
| 480 | - { |
|
| 481 | - $this->dieOnError = $value; |
|
| 482 | - } |
|
| 403 | + $match = array(); |
|
| 404 | + preg_match_all("'.* FROM ([^ ]*).* ORDER BY (.*)'is", $sql, $match); |
|
| 405 | + $indices = false; |
|
| 406 | + if (!empty($match[1][0])) |
|
| 407 | + $table = $match[1][0]; |
|
| 408 | + else |
|
| 409 | + return false; |
|
| 410 | + |
|
| 411 | + if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) |
|
| 412 | + $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 413 | + |
|
| 414 | + if (empty($indices)) { |
|
| 415 | + foreach ( $GLOBALS['dictionary'] as $current ) { |
|
| 416 | + if ($current['table'] == $table){ |
|
| 417 | + $indices = $current['indices']; |
|
| 418 | + break; |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + if (empty($indices)) { |
|
| 423 | + $this->log->warn('CHECK QUERY: Could not find index definitions for table ' . $table); |
|
| 424 | + return false; |
|
| 425 | + } |
|
| 426 | + if (!empty($match[2][0])) { |
|
| 427 | + $orderBys = explode(' ', $match[2][0]); |
|
| 428 | + foreach ($orderBys as $orderBy){ |
|
| 429 | + $orderBy = trim($orderBy); |
|
| 430 | + if (empty($orderBy)) |
|
| 431 | + continue; |
|
| 432 | + $orderBy = strtolower($orderBy); |
|
| 433 | + if ($orderBy == 'asc' || $orderBy == 'desc') |
|
| 434 | + continue; |
|
| 435 | + |
|
| 436 | + $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
|
| 437 | + |
|
| 438 | + foreach ($indices as $index) |
|
| 439 | + if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 440 | + foreach ($index['fields'] as $field) |
|
| 441 | + if ($field == $orderBy) |
|
| 442 | + return true; |
|
| 443 | + |
|
| 444 | + $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
|
| 445 | + if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
|
| 446 | + $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 447 | + else |
|
| 448 | + $this->log->warn('CHECK QUERY:' .$warning); |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + /** |
|
| 455 | + * Returns the time the last query took to execute |
|
| 456 | + * |
|
| 457 | + * @return int |
|
| 458 | + */ |
|
| 459 | + public function getQueryTime() |
|
| 460 | + { |
|
| 461 | + return $this->query_time; |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * Checks the current connection; if it is not connected then reconnect |
|
| 466 | + */ |
|
| 467 | + public function checkConnection() |
|
| 468 | + { |
|
| 469 | + $this->last_error = ''; |
|
| 470 | + if (!isset($this->database)) |
|
| 471 | + $this->connect(); |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Sets the dieOnError value |
|
| 476 | + * |
|
| 477 | + * @param bool $value |
|
| 478 | + */ |
|
| 479 | + public function setDieOnError($value) |
|
| 480 | + { |
|
| 481 | + $this->dieOnError = $value; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | 485 | * Implements a generic insert for any bean. |
@@ -488,67 +488,67 @@ discard block |
||
| 488 | 488 | * @return bool query result |
| 489 | 489 | * |
| 490 | 490 | */ |
| 491 | - public function insert(SugarBean $bean) |
|
| 492 | - { |
|
| 493 | - $sql = $this->insertSQL($bean); |
|
| 494 | - $tablename = $bean->getTableName(); |
|
| 495 | - $msg = "Error inserting into table: $tablename:"; |
|
| 496 | - return $this->query($sql,true,$msg); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * Insert data into table by parameter definition |
|
| 501 | - * @param string $table Table name |
|
| 502 | - * @param array $field_defs Definitions in vardef-like format |
|
| 503 | - * @param array $data Key/value to insert |
|
| 504 | - * @param array $field_map Fields map from SugarBean |
|
| 505 | - * @param bool $execute Execute or return query? |
|
| 491 | + public function insert(SugarBean $bean) |
|
| 492 | + { |
|
| 493 | + $sql = $this->insertSQL($bean); |
|
| 494 | + $tablename = $bean->getTableName(); |
|
| 495 | + $msg = "Error inserting into table: $tablename:"; |
|
| 496 | + return $this->query($sql,true,$msg); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * Insert data into table by parameter definition |
|
| 501 | + * @param string $table Table name |
|
| 502 | + * @param array $field_defs Definitions in vardef-like format |
|
| 503 | + * @param array $data Key/value to insert |
|
| 504 | + * @param array $field_map Fields map from SugarBean |
|
| 505 | + * @param bool $execute Execute or return query? |
|
| 506 | 506 | * @return bool query result |
| 507 | 507 | */ |
| 508 | - public function insertParams($table, $field_defs, $data, $field_map = null, $execute = true) |
|
| 509 | - { |
|
| 510 | - $values = array(); |
|
| 511 | - foreach ($field_defs as $field => $fieldDef) |
|
| 512 | - { |
|
| 513 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 514 | - //custom fields handle there save seperatley |
|
| 515 | - if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 516 | - |
|
| 517 | - if(isset($data[$field])) { |
|
| 518 | - // clean the incoming value.. |
|
| 519 | - $val = from_html($data[$field]); |
|
| 520 | - } else { |
|
| 521 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 522 | - $val = $fieldDef['default']; |
|
| 523 | - } else { |
|
| 524 | - $val = null; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - //handle auto increment values here - we may have to do something like nextval for oracle |
|
| 529 | - if (!empty($fieldDef['auto_increment'])) { |
|
| 530 | - $auto = $this->getAutoIncrementSQL($table, $fieldDef['name']); |
|
| 531 | - if(!empty($auto)) { |
|
| 532 | - $values[$field] = $auto; |
|
| 533 | - } |
|
| 534 | - } elseif ($fieldDef['name'] == 'deleted') { |
|
| 535 | - $values['deleted'] = (int)$val; |
|
| 536 | - } else { |
|
| 537 | - // need to do some thing about types of values |
|
| 538 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 539 | - $values[$field] = $this->massageValue($val, $fieldDef); |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if (empty($values)) |
|
| 545 | - return $execute?true:''; // no columns set |
|
| 546 | - |
|
| 547 | - // get the entire sql |
|
| 548 | - $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
|
| 508 | + public function insertParams($table, $field_defs, $data, $field_map = null, $execute = true) |
|
| 509 | + { |
|
| 510 | + $values = array(); |
|
| 511 | + foreach ($field_defs as $field => $fieldDef) |
|
| 512 | + { |
|
| 513 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 514 | + //custom fields handle there save seperatley |
|
| 515 | + if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 516 | + |
|
| 517 | + if(isset($data[$field])) { |
|
| 518 | + // clean the incoming value.. |
|
| 519 | + $val = from_html($data[$field]); |
|
| 520 | + } else { |
|
| 521 | + if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 522 | + $val = $fieldDef['default']; |
|
| 523 | + } else { |
|
| 524 | + $val = null; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + //handle auto increment values here - we may have to do something like nextval for oracle |
|
| 529 | + if (!empty($fieldDef['auto_increment'])) { |
|
| 530 | + $auto = $this->getAutoIncrementSQL($table, $fieldDef['name']); |
|
| 531 | + if(!empty($auto)) { |
|
| 532 | + $values[$field] = $auto; |
|
| 533 | + } |
|
| 534 | + } elseif ($fieldDef['name'] == 'deleted') { |
|
| 535 | + $values['deleted'] = (int)$val; |
|
| 536 | + } else { |
|
| 537 | + // need to do some thing about types of values |
|
| 538 | + if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 539 | + $values[$field] = $this->massageValue($val, $fieldDef); |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + if (empty($values)) |
|
| 545 | + return $execute?true:''; // no columns set |
|
| 546 | + |
|
| 547 | + // get the entire sql |
|
| 548 | + $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
|
| 549 | 549 | VALUES (".implode(",", $values).")"; |
| 550 | - return $execute?$this->query($query):$query; |
|
| 551 | - } |
|
| 550 | + return $execute?$this->query($query):$query; |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * Implements a generic update for any bean |
@@ -560,13 +560,13 @@ discard block |
||
| 560 | 560 | * @return bool query result |
| 561 | 561 | * |
| 562 | 562 | */ |
| 563 | - public function update(SugarBean $bean, array $where = array()) |
|
| 564 | - { |
|
| 565 | - $sql = $this->updateSQL($bean, $where); |
|
| 566 | - $tablename = $bean->getTableName(); |
|
| 567 | - $msg = "Error updating table: $tablename:"; |
|
| 568 | - return $this->query($sql,true,$msg); |
|
| 569 | - } |
|
| 563 | + public function update(SugarBean $bean, array $where = array()) |
|
| 564 | + { |
|
| 565 | + $sql = $this->updateSQL($bean, $where); |
|
| 566 | + $tablename = $bean->getTableName(); |
|
| 567 | + $msg = "Error updating table: $tablename:"; |
|
| 568 | + return $this->query($sql,true,$msg); |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | 571 | /** |
| 572 | 572 | * Implements a generic delete for any bean identified by id |
@@ -577,215 +577,215 @@ discard block |
||
| 577 | 577 | * If where is not passed, it defaults to id of table |
| 578 | 578 | * @return bool query result |
| 579 | 579 | */ |
| 580 | - public function delete(SugarBean $bean, array $where = array()) |
|
| 581 | - { |
|
| 582 | - $sql = $this->deleteSQL($bean, $where); |
|
| 583 | - $tableName = $bean->getTableName(); |
|
| 584 | - $msg = "Error deleting from table: ".$tableName. ":"; |
|
| 585 | - return $this->query($sql,true,$msg); |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Implements a generic retrieve for any bean identified by id |
|
| 590 | - * |
|
| 591 | - * If we want to pass multiple values for a name, pass it as an array |
|
| 592 | - * If where is not passed, it defaults to id of table |
|
| 593 | - * |
|
| 594 | - * @param SugarBean $bean Sugarbean instance |
|
| 595 | - * @param array $where values with the keys as names of fields. |
|
| 596 | - * @return resource result from the query |
|
| 597 | - */ |
|
| 598 | - public function retrieve(SugarBean $bean, array $where = array()) |
|
| 599 | - { |
|
| 600 | - $sql = $this->retrieveSQL($bean, $where); |
|
| 601 | - $tableName = $bean->getTableName(); |
|
| 602 | - $msg = "Error retriving values from table:".$tableName. ":"; |
|
| 603 | - return $this->query($sql,true,$msg); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - /** |
|
| 607 | - * Implements a generic retrieve for a collection of beans. |
|
| 608 | - * |
|
| 609 | - * These beans will be joined in the sql by the key attribute of field defs. |
|
| 610 | - * Currently, this function does support outer joins. |
|
| 611 | - * |
|
| 612 | - * @param array $beans Sugarbean instance(s) |
|
| 613 | - * @param array $cols columns to be returned with the keys as names of bean as identified by |
|
| 614 | - * get_class of bean. Values of this array is the array of fieldDefs to be returned for a bean. |
|
| 615 | - * If an empty array is passed, all columns are selected. |
|
| 616 | - * @param array $where values with the keys as names of bean as identified by get_class of bean |
|
| 617 | - * Each value at the first level is an array of values for that bean identified by name of fields. |
|
| 618 | - * If we want to pass multiple values for a name, pass it as an array |
|
| 619 | - * If where is not passed, all the rows will be returned. |
|
| 620 | - * @return resource |
|
| 621 | - */ |
|
| 622 | - public function retrieveView(array $beans, array $cols = array(), array $where = array()) |
|
| 623 | - { |
|
| 624 | - $sql = $this->retrieveViewSQL($beans, $cols, $where); |
|
| 625 | - $msg = "Error retriving values from View Collection:"; |
|
| 626 | - return $this->query($sql,true,$msg); |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * Implements creation of a db table for a bean. |
|
| 632 | - * |
|
| 633 | - * NOTE: does not handle out-of-table constraints, use createConstraintSQL for that |
|
| 634 | - * @param SugarBean $bean Sugarbean instance |
|
| 635 | - */ |
|
| 636 | - public function createTable(SugarBean $bean) |
|
| 637 | - { |
|
| 638 | - $sql = $this->createTableSQL($bean); |
|
| 639 | - $tablename = $bean->getTableName(); |
|
| 640 | - $msg = "Error creating table: $tablename:"; |
|
| 641 | - $this->query($sql,true,$msg); |
|
| 642 | - if(!$this->supports("inline_keys")) { |
|
| 643 | - // handle constraints and indices |
|
| 644 | - $indicesArr = $this->createConstraintSql($bean); |
|
| 645 | - if (count($indicesArr) > 0) |
|
| 646 | - foreach ($indicesArr as $indexSql) |
|
| 647 | - $this->query($indexSql, true, $msg); |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * returns SQL to create constraints or indices |
|
| 653 | - * |
|
| 654 | - * @param SugarBean $bean SugarBean instance |
|
| 655 | - * @return array list of SQL statements |
|
| 656 | - */ |
|
| 657 | - protected function createConstraintSql(SugarBean $bean) |
|
| 658 | - { |
|
| 659 | - return $this->getConstraintSql($bean->getIndices(), $bean->getTableName()); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * Implements creation of a db table |
|
| 664 | - * |
|
| 665 | - * @param string $tablename |
|
| 666 | - * @param array $fieldDefs Field definitions, in vardef format |
|
| 667 | - * @param array $indices Index definitions, in vardef format |
|
| 668 | - * @param string $engine Engine parameter, used for MySQL engine so far |
|
| 580 | + public function delete(SugarBean $bean, array $where = array()) |
|
| 581 | + { |
|
| 582 | + $sql = $this->deleteSQL($bean, $where); |
|
| 583 | + $tableName = $bean->getTableName(); |
|
| 584 | + $msg = "Error deleting from table: ".$tableName. ":"; |
|
| 585 | + return $this->query($sql,true,$msg); |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Implements a generic retrieve for any bean identified by id |
|
| 590 | + * |
|
| 591 | + * If we want to pass multiple values for a name, pass it as an array |
|
| 592 | + * If where is not passed, it defaults to id of table |
|
| 593 | + * |
|
| 594 | + * @param SugarBean $bean Sugarbean instance |
|
| 595 | + * @param array $where values with the keys as names of fields. |
|
| 596 | + * @return resource result from the query |
|
| 597 | + */ |
|
| 598 | + public function retrieve(SugarBean $bean, array $where = array()) |
|
| 599 | + { |
|
| 600 | + $sql = $this->retrieveSQL($bean, $where); |
|
| 601 | + $tableName = $bean->getTableName(); |
|
| 602 | + $msg = "Error retriving values from table:".$tableName. ":"; |
|
| 603 | + return $this->query($sql,true,$msg); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + /** |
|
| 607 | + * Implements a generic retrieve for a collection of beans. |
|
| 608 | + * |
|
| 609 | + * These beans will be joined in the sql by the key attribute of field defs. |
|
| 610 | + * Currently, this function does support outer joins. |
|
| 611 | + * |
|
| 612 | + * @param array $beans Sugarbean instance(s) |
|
| 613 | + * @param array $cols columns to be returned with the keys as names of bean as identified by |
|
| 614 | + * get_class of bean. Values of this array is the array of fieldDefs to be returned for a bean. |
|
| 615 | + * If an empty array is passed, all columns are selected. |
|
| 616 | + * @param array $where values with the keys as names of bean as identified by get_class of bean |
|
| 617 | + * Each value at the first level is an array of values for that bean identified by name of fields. |
|
| 618 | + * If we want to pass multiple values for a name, pass it as an array |
|
| 619 | + * If where is not passed, all the rows will be returned. |
|
| 620 | + * @return resource |
|
| 621 | + */ |
|
| 622 | + public function retrieveView(array $beans, array $cols = array(), array $where = array()) |
|
| 623 | + { |
|
| 624 | + $sql = $this->retrieveViewSQL($beans, $cols, $where); |
|
| 625 | + $msg = "Error retriving values from View Collection:"; |
|
| 626 | + return $this->query($sql,true,$msg); |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * Implements creation of a db table for a bean. |
|
| 632 | + * |
|
| 633 | + * NOTE: does not handle out-of-table constraints, use createConstraintSQL for that |
|
| 634 | + * @param SugarBean $bean Sugarbean instance |
|
| 635 | + */ |
|
| 636 | + public function createTable(SugarBean $bean) |
|
| 637 | + { |
|
| 638 | + $sql = $this->createTableSQL($bean); |
|
| 639 | + $tablename = $bean->getTableName(); |
|
| 640 | + $msg = "Error creating table: $tablename:"; |
|
| 641 | + $this->query($sql,true,$msg); |
|
| 642 | + if(!$this->supports("inline_keys")) { |
|
| 643 | + // handle constraints and indices |
|
| 644 | + $indicesArr = $this->createConstraintSql($bean); |
|
| 645 | + if (count($indicesArr) > 0) |
|
| 646 | + foreach ($indicesArr as $indexSql) |
|
| 647 | + $this->query($indexSql, true, $msg); |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * returns SQL to create constraints or indices |
|
| 653 | + * |
|
| 654 | + * @param SugarBean $bean SugarBean instance |
|
| 655 | + * @return array list of SQL statements |
|
| 656 | + */ |
|
| 657 | + protected function createConstraintSql(SugarBean $bean) |
|
| 658 | + { |
|
| 659 | + return $this->getConstraintSql($bean->getIndices(), $bean->getTableName()); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * Implements creation of a db table |
|
| 664 | + * |
|
| 665 | + * @param string $tablename |
|
| 666 | + * @param array $fieldDefs Field definitions, in vardef format |
|
| 667 | + * @param array $indices Index definitions, in vardef format |
|
| 668 | + * @param string $engine Engine parameter, used for MySQL engine so far |
|
| 669 | 669 | * @todo: refactor engine param to be more generic |
| 670 | 670 | * @return bool success value |
| 671 | 671 | */ |
| 672 | - public function createTableParams($tablename, $fieldDefs, $indices, $engine = null) |
|
| 673 | - { |
|
| 674 | - if (!empty($fieldDefs)) { |
|
| 675 | - $sql = $this->createTableSQLParams($tablename, $fieldDefs, $indices, $engine); |
|
| 676 | - $res = true; |
|
| 677 | - if ($sql) { |
|
| 678 | - $msg = "Error creating table: $tablename"; |
|
| 679 | - $res = ($res and $this->query($sql,true,$msg)); |
|
| 680 | - } |
|
| 681 | - if(!$this->supports("inline_keys")) { |
|
| 682 | - // handle constraints and indices |
|
| 683 | - $indicesArr = $this->getConstraintSql($indices, $tablename); |
|
| 684 | - if (count($indicesArr) > 0) |
|
| 685 | - foreach ($indicesArr as $indexSql) |
|
| 686 | - $res = ($res and $this->query($indexSql, true, "Error creating indexes")); |
|
| 687 | - } |
|
| 688 | - return $res; |
|
| 689 | - } |
|
| 690 | - return false; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * Implements repair of a db table for a bean. |
|
| 695 | - * |
|
| 696 | - * @param SugarBean $bean SugarBean instance |
|
| 697 | - * @param bool $execute true if we want the action to take place, false if we just want the sql returned |
|
| 698 | - * @return string SQL statement or empty string, depending upon $execute |
|
| 699 | - */ |
|
| 700 | - public function repairTable(SugarBean $bean, $execute = true) |
|
| 701 | - { |
|
| 702 | - $indices = $bean->getIndices(); |
|
| 703 | - $fielddefs = $bean->getFieldDefinitions(); |
|
| 704 | - $tablename = $bean->getTableName(); |
|
| 705 | - |
|
| 706 | - //Clean the indexes to prevent duplicate definitions |
|
| 707 | - $new_index = array(); |
|
| 708 | - foreach($indices as $ind_def){ |
|
| 709 | - $new_index[$ind_def['name']] = $ind_def; |
|
| 710 | - } |
|
| 711 | - //jc: added this for beans that do not actually have a table, namely |
|
| 712 | - //ForecastOpportunities |
|
| 713 | - if($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | - return ''; |
|
| 715 | - |
|
| 716 | - global $dictionary; |
|
| 717 | - $engine=null; |
|
| 718 | - if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 719 | - $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 720 | - |
|
| 721 | - return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - /** |
|
| 725 | - * Can this field be null? |
|
| 726 | - * Auto-increment and ID fields can not be null |
|
| 727 | - * @param array $vardef |
|
| 672 | + public function createTableParams($tablename, $fieldDefs, $indices, $engine = null) |
|
| 673 | + { |
|
| 674 | + if (!empty($fieldDefs)) { |
|
| 675 | + $sql = $this->createTableSQLParams($tablename, $fieldDefs, $indices, $engine); |
|
| 676 | + $res = true; |
|
| 677 | + if ($sql) { |
|
| 678 | + $msg = "Error creating table: $tablename"; |
|
| 679 | + $res = ($res and $this->query($sql,true,$msg)); |
|
| 680 | + } |
|
| 681 | + if(!$this->supports("inline_keys")) { |
|
| 682 | + // handle constraints and indices |
|
| 683 | + $indicesArr = $this->getConstraintSql($indices, $tablename); |
|
| 684 | + if (count($indicesArr) > 0) |
|
| 685 | + foreach ($indicesArr as $indexSql) |
|
| 686 | + $res = ($res and $this->query($indexSql, true, "Error creating indexes")); |
|
| 687 | + } |
|
| 688 | + return $res; |
|
| 689 | + } |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * Implements repair of a db table for a bean. |
|
| 695 | + * |
|
| 696 | + * @param SugarBean $bean SugarBean instance |
|
| 697 | + * @param bool $execute true if we want the action to take place, false if we just want the sql returned |
|
| 698 | + * @return string SQL statement or empty string, depending upon $execute |
|
| 699 | + */ |
|
| 700 | + public function repairTable(SugarBean $bean, $execute = true) |
|
| 701 | + { |
|
| 702 | + $indices = $bean->getIndices(); |
|
| 703 | + $fielddefs = $bean->getFieldDefinitions(); |
|
| 704 | + $tablename = $bean->getTableName(); |
|
| 705 | + |
|
| 706 | + //Clean the indexes to prevent duplicate definitions |
|
| 707 | + $new_index = array(); |
|
| 708 | + foreach($indices as $ind_def){ |
|
| 709 | + $new_index[$ind_def['name']] = $ind_def; |
|
| 710 | + } |
|
| 711 | + //jc: added this for beans that do not actually have a table, namely |
|
| 712 | + //ForecastOpportunities |
|
| 713 | + if($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | + return ''; |
|
| 715 | + |
|
| 716 | + global $dictionary; |
|
| 717 | + $engine=null; |
|
| 718 | + if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 719 | + $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 720 | + |
|
| 721 | + return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + /** |
|
| 725 | + * Can this field be null? |
|
| 726 | + * Auto-increment and ID fields can not be null |
|
| 727 | + * @param array $vardef |
|
| 728 | 728 | * @return bool |
| 729 | 729 | */ |
| 730 | - protected function isNullable($vardef) |
|
| 731 | - { |
|
| 732 | - |
|
| 733 | - if(isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 734 | - && !empty($vardef['required'])) { |
|
| 735 | - /* required + is_null=false => not null */ |
|
| 736 | - return false; |
|
| 737 | - } |
|
| 738 | - if(empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 739 | - && (empty($vardef['dbType']) || $vardef['dbType'] != 'id') |
|
| 740 | - && (empty($vardef['name']) || ($vardef['name'] != 'id' && $vardef['name'] != 'deleted')) |
|
| 741 | - ) { |
|
| 742 | - return true; |
|
| 743 | - } |
|
| 744 | - return false; |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - /** |
|
| 749 | - * Builds the SQL commands that repair a table structure |
|
| 750 | - * |
|
| 751 | - * @param string $tablename |
|
| 752 | - * @param array $fielddefs Field definitions, in vardef format |
|
| 753 | - * @param array $indices Index definitions, in vardef format |
|
| 754 | - * @param bool $execute optional, true if we want the queries executed instead of returned |
|
| 755 | - * @param string $engine optional, MySQL engine |
|
| 730 | + protected function isNullable($vardef) |
|
| 731 | + { |
|
| 732 | + |
|
| 733 | + if(isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 734 | + && !empty($vardef['required'])) { |
|
| 735 | + /* required + is_null=false => not null */ |
|
| 736 | + return false; |
|
| 737 | + } |
|
| 738 | + if(empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 739 | + && (empty($vardef['dbType']) || $vardef['dbType'] != 'id') |
|
| 740 | + && (empty($vardef['name']) || ($vardef['name'] != 'id' && $vardef['name'] != 'deleted')) |
|
| 741 | + ) { |
|
| 742 | + return true; |
|
| 743 | + } |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * Builds the SQL commands that repair a table structure |
|
| 750 | + * |
|
| 751 | + * @param string $tablename |
|
| 752 | + * @param array $fielddefs Field definitions, in vardef format |
|
| 753 | + * @param array $indices Index definitions, in vardef format |
|
| 754 | + * @param bool $execute optional, true if we want the queries executed instead of returned |
|
| 755 | + * @param string $engine optional, MySQL engine |
|
| 756 | 756 | * @todo: refactor engine param to be more generic |
| 757 | 757 | * @return string |
| 758 | 758 | */ |
| 759 | - public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 760 | - { |
|
| 761 | - //jc: had a bug when running the repair if the tablename is blank the repair will |
|
| 762 | - //fail when it tries to create a repair table |
|
| 763 | - if ($tablename == '' || empty($fielddefs)) |
|
| 764 | - return ''; |
|
| 765 | - |
|
| 766 | - //if the table does not exist create it and we are done |
|
| 767 | - $sql = "/* Table : $tablename */\n"; |
|
| 768 | - if (!$this->tableExists($tablename)) { |
|
| 769 | - $createtablesql = $this->createTableSQLParams($tablename,$fielddefs,$indices,$engine); |
|
| 770 | - if($execute && $createtablesql){ |
|
| 771 | - $this->createTableParams($tablename,$fielddefs,$indices,$engine); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - $sql .= "/* MISSING TABLE: {$tablename} */\n"; |
|
| 775 | - $sql .= $createtablesql . "\n"; |
|
| 776 | - return $sql; |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - $compareFieldDefs = $this->get_columns($tablename); |
|
| 780 | - $compareIndices = $this->get_indices($tablename); |
|
| 781 | - |
|
| 782 | - $take_action = false; |
|
| 783 | - |
|
| 784 | - // do column comparisons |
|
| 785 | - $sql .= "/*COLUMNS*/\n"; |
|
| 786 | - foreach ($fielddefs as $name => $value) { |
|
| 787 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 788 | - continue; |
|
| 759 | + public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 760 | + { |
|
| 761 | + //jc: had a bug when running the repair if the tablename is blank the repair will |
|
| 762 | + //fail when it tries to create a repair table |
|
| 763 | + if ($tablename == '' || empty($fielddefs)) |
|
| 764 | + return ''; |
|
| 765 | + |
|
| 766 | + //if the table does not exist create it and we are done |
|
| 767 | + $sql = "/* Table : $tablename */\n"; |
|
| 768 | + if (!$this->tableExists($tablename)) { |
|
| 769 | + $createtablesql = $this->createTableSQLParams($tablename,$fielddefs,$indices,$engine); |
|
| 770 | + if($execute && $createtablesql){ |
|
| 771 | + $this->createTableParams($tablename,$fielddefs,$indices,$engine); |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + $sql .= "/* MISSING TABLE: {$tablename} */\n"; |
|
| 775 | + $sql .= $createtablesql . "\n"; |
|
| 776 | + return $sql; |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + $compareFieldDefs = $this->get_columns($tablename); |
|
| 780 | + $compareIndices = $this->get_indices($tablename); |
|
| 781 | + |
|
| 782 | + $take_action = false; |
|
| 783 | + |
|
| 784 | + // do column comparisons |
|
| 785 | + $sql .= "/*COLUMNS*/\n"; |
|
| 786 | + foreach ($fielddefs as $name => $value) { |
|
| 787 | + if (isset($value['source']) && $value['source'] != 'db') |
|
| 788 | + continue; |
|
| 789 | 789 | |
| 790 | 790 | // Bug #42406. Skipping breaked vardef without type or name |
| 791 | 791 | if (isset($value['name']) == false || $value['name'] == false) |
@@ -799,183 +799,183 @@ discard block |
||
| 799 | 799 | continue; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - $name = strtolower($value['name']); |
|
| 803 | - // add or fix the field defs per what the DB is expected to give us back |
|
| 804 | - $this->massageFieldDef($value,$tablename); |
|
| 805 | - |
|
| 806 | - $ignorerequired=false; |
|
| 807 | - |
|
| 808 | - //Do not track requiredness in the DB, auto_increment, ID, |
|
| 809 | - // and deleted fields are always required in the DB, so don't force those |
|
| 810 | - if ($this->isNullable($value)) { |
|
| 811 | - $value['required'] = false; |
|
| 812 | - } |
|
| 813 | - //Should match the conditions in DBManager::oneColumnSQLRep for DB required fields, type='id' fields will sometimes |
|
| 814 | - |
|
| 815 | - //come into this function as 'type' = 'char', 'dbType' = 'id' without required set in $value. Assume they are correct and leave them alone. |
|
| 816 | - else if (($name == 'id' || $value['type'] == 'id' || (isset($value['dbType']) && $value['dbType'] == 'id')) |
|
| 817 | - && (!isset($value['required']) && isset($compareFieldDefs[$name]['required']))) |
|
| 818 | - { |
|
| 819 | - $value['required'] = $compareFieldDefs[$name]['required']; |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - if ( !isset($compareFieldDefs[$name]) ) { |
|
| 823 | - // ok we need this field lets create it |
|
| 824 | - $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | - $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
|
| 826 | - if ($execute) |
|
| 827 | - $this->addColumn($tablename, $value); |
|
| 828 | - $take_action = true; |
|
| 829 | - } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
|
| 830 | - //fields are different lets alter it |
|
| 831 | - $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | - foreach($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 834 | - } |
|
| 835 | - $sql .= "*/\n"; |
|
| 836 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | - foreach($value as $rKey => $rValue) { |
|
| 838 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 839 | - } |
|
| 840 | - $sql .= "*/\n"; |
|
| 841 | - |
|
| 842 | - //jc: oracle will complain if you try to execute a statement that sets a column to (not) null |
|
| 843 | - //when it is already (not) null |
|
| 844 | - if ( isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 845 | - $value['isnull'] === $compareFieldDefs[$name]['isnull']) { |
|
| 846 | - unset($value['required']); |
|
| 847 | - $ignorerequired=true; |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - //dwheeler: Once a column has been defined as null, we cannot try to force it back to !null |
|
| 851 | - if ((isset($value['required']) && ($value['required'] === true || $value['required'] == 'true' || $value['required'] === 1)) |
|
| 852 | - && (empty($compareFieldDefs[$name]['required']) || $compareFieldDefs[$name]['required'] != 'true')) |
|
| 853 | - { |
|
| 854 | - $ignorerequired = true; |
|
| 855 | - } |
|
| 856 | - $altersql = $this->alterColumnSQL($tablename, $value,$ignorerequired); |
|
| 857 | - if(is_array($altersql)) { |
|
| 858 | - $altersql = join("\n", $altersql); |
|
| 859 | - } |
|
| 860 | - $sql .= $altersql . "\n"; |
|
| 861 | - if($execute){ |
|
| 862 | - $this->alterColumn($tablename, $value, $ignorerequired); |
|
| 863 | - } |
|
| 864 | - $take_action = true; |
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - // do index comparisons |
|
| 869 | - $sql .= "/* INDEXES */\n"; |
|
| 870 | - $correctedIndexs = array(); |
|
| 802 | + $name = strtolower($value['name']); |
|
| 803 | + // add or fix the field defs per what the DB is expected to give us back |
|
| 804 | + $this->massageFieldDef($value,$tablename); |
|
| 871 | 805 | |
| 872 | - $compareIndices_case_insensitive = array(); |
|
| 806 | + $ignorerequired=false; |
|
| 873 | 807 | |
| 874 | - // do indices comparisons case-insensitive |
|
| 875 | - foreach($compareIndices as $k => $value){ |
|
| 876 | - $value['name'] = strtolower($value['name']); |
|
| 877 | - $compareIndices_case_insensitive[strtolower($k)] = $value; |
|
| 878 | - } |
|
| 879 | - $compareIndices = $compareIndices_case_insensitive; |
|
| 880 | - unset($compareIndices_case_insensitive); |
|
| 881 | - |
|
| 882 | - foreach ($indices as $value) { |
|
| 883 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 884 | - continue; |
|
| 885 | - |
|
| 886 | - |
|
| 887 | - $validDBName = $this->getValidDBName($value['name'], true, 'index', true); |
|
| 888 | - if (isset($compareIndices[$validDBName])) { |
|
| 889 | - $value['name'] = $validDBName; |
|
| 890 | - } |
|
| 891 | - $name = strtolower($value['name']); |
|
| 892 | - |
|
| 893 | - //Don't attempt to fix the same index twice in one pass; |
|
| 894 | - if (isset($correctedIndexs[$name])) |
|
| 895 | - continue; |
|
| 896 | - |
|
| 897 | - //don't bother checking primary nothing we can do about them |
|
| 898 | - if (isset($value['type']) && $value['type'] == 'primary') |
|
| 899 | - continue; |
|
| 900 | - |
|
| 901 | - //database helpers do not know how to handle full text indices |
|
| 902 | - if ($value['type']=='fulltext') |
|
| 903 | - continue; |
|
| 904 | - |
|
| 905 | - if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 906 | - $value['type'] = 'index'; |
|
| 907 | - |
|
| 908 | - if ( !isset($compareIndices[$name]) ) { |
|
| 909 | - //First check if an index exists that doesn't match our name, if so, try to rename it |
|
| 910 | - $found = false; |
|
| 911 | - foreach ($compareIndices as $ex_name => $ex_value) { |
|
| 912 | - if($this->compareVarDefs($ex_value, $value, true)) { |
|
| 913 | - $found = $ex_name; |
|
| 914 | - break; |
|
| 915 | - } |
|
| 916 | - } |
|
| 917 | - if ($found) { |
|
| 918 | - $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 919 | - $rename = $this->renameIndexDefs($ex_value, $value, $tablename); |
|
| 920 | - if($execute) { |
|
| 921 | - $this->query($rename, true, "Cannot rename index"); |
|
| 922 | - } |
|
| 923 | - $sql .= is_array($rename)?join("\n", $rename). "\n":$rename."\n"; |
|
| 924 | - |
|
| 925 | - } else { |
|
| 926 | - // ok we need this field lets create it |
|
| 927 | - $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | - $sql .= $this->addIndexes($tablename,array($value), $execute) . "\n"; |
|
| 929 | - } |
|
| 930 | - $take_action = true; |
|
| 931 | - $correctedIndexs[$name] = true; |
|
| 932 | - } elseif ( !$this->compareVarDefs($compareIndices[$name],$value) ) { |
|
| 933 | - // fields are different lets alter it |
|
| 934 | - $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 935 | - foreach ($compareIndices[$name] as $n1 => $t1) { |
|
| 936 | - $sql .= "<$n1>"; |
|
| 937 | - if ( $n1 == 'fields' ) |
|
| 938 | - foreach($t1 as $rKey => $rValue) |
|
| 939 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 940 | - else |
|
| 941 | - $sql .= " $t1 "; |
|
| 942 | - } |
|
| 943 | - $sql .= "*/\n"; |
|
| 944 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 945 | - foreach ($value as $n1 => $t1) { |
|
| 946 | - $sql .= "<$n1>"; |
|
| 947 | - if ( $n1 == 'fields' ) |
|
| 948 | - foreach ($t1 as $rKey => $rValue) |
|
| 949 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 950 | - else |
|
| 951 | - $sql .= " $t1 "; |
|
| 952 | - } |
|
| 953 | - $sql .= "*/\n"; |
|
| 954 | - $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
|
| 955 | - $take_action = true; |
|
| 956 | - $correctedIndexs[$name] = true; |
|
| 957 | - } |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - return ($take_action === true) ? $sql : ''; |
|
| 961 | - } |
|
| 808 | + //Do not track requiredness in the DB, auto_increment, ID, |
|
| 809 | + // and deleted fields are always required in the DB, so don't force those |
|
| 810 | + if ($this->isNullable($value)) { |
|
| 811 | + $value['required'] = false; |
|
| 812 | + } |
|
| 813 | + //Should match the conditions in DBManager::oneColumnSQLRep for DB required fields, type='id' fields will sometimes |
|
| 962 | 814 | |
| 963 | - /** |
|
| 964 | - * Compares two vardefs |
|
| 965 | - * |
|
| 966 | - * @param array $fielddef1 This is from the database |
|
| 967 | - * @param array $fielddef2 This is from the vardef |
|
| 968 | - * @param bool $ignoreName Ignore name-only differences? |
|
| 969 | - * @return bool true if they match, false if they don't |
|
| 970 | - */ |
|
| 971 | - public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
|
| 972 | - { |
|
| 973 | - foreach ( $fielddef1 as $key => $value ) { |
|
| 974 | - if ($key == 'name' && $ignoreName) |
|
| 975 | - continue; |
|
| 976 | - if (isset($fielddef2[$key])) |
|
| 815 | + //come into this function as 'type' = 'char', 'dbType' = 'id' without required set in $value. Assume they are correct and leave them alone. |
|
| 816 | + else if (($name == 'id' || $value['type'] == 'id' || (isset($value['dbType']) && $value['dbType'] == 'id')) |
|
| 817 | + && (!isset($value['required']) && isset($compareFieldDefs[$name]['required']))) |
|
| 977 | 818 | { |
| 978 | - if (!is_array($fielddef1[$key]) && !is_array($fielddef2[$key])) |
|
| 819 | + $value['required'] = $compareFieldDefs[$name]['required']; |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + if ( !isset($compareFieldDefs[$name]) ) { |
|
| 823 | + // ok we need this field lets create it |
|
| 824 | + $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | + $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
|
| 826 | + if ($execute) |
|
| 827 | + $this->addColumn($tablename, $value); |
|
| 828 | + $take_action = true; |
|
| 829 | + } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
|
| 830 | + //fields are different lets alter it |
|
| 831 | + $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | + foreach($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 834 | + } |
|
| 835 | + $sql .= "*/\n"; |
|
| 836 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | + foreach($value as $rKey => $rValue) { |
|
| 838 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 839 | + } |
|
| 840 | + $sql .= "*/\n"; |
|
| 841 | + |
|
| 842 | + //jc: oracle will complain if you try to execute a statement that sets a column to (not) null |
|
| 843 | + //when it is already (not) null |
|
| 844 | + if ( isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 845 | + $value['isnull'] === $compareFieldDefs[$name]['isnull']) { |
|
| 846 | + unset($value['required']); |
|
| 847 | + $ignorerequired=true; |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + //dwheeler: Once a column has been defined as null, we cannot try to force it back to !null |
|
| 851 | + if ((isset($value['required']) && ($value['required'] === true || $value['required'] == 'true' || $value['required'] === 1)) |
|
| 852 | + && (empty($compareFieldDefs[$name]['required']) || $compareFieldDefs[$name]['required'] != 'true')) |
|
| 853 | + { |
|
| 854 | + $ignorerequired = true; |
|
| 855 | + } |
|
| 856 | + $altersql = $this->alterColumnSQL($tablename, $value,$ignorerequired); |
|
| 857 | + if(is_array($altersql)) { |
|
| 858 | + $altersql = join("\n", $altersql); |
|
| 859 | + } |
|
| 860 | + $sql .= $altersql . "\n"; |
|
| 861 | + if($execute){ |
|
| 862 | + $this->alterColumn($tablename, $value, $ignorerequired); |
|
| 863 | + } |
|
| 864 | + $take_action = true; |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + // do index comparisons |
|
| 869 | + $sql .= "/* INDEXES */\n"; |
|
| 870 | + $correctedIndexs = array(); |
|
| 871 | + |
|
| 872 | + $compareIndices_case_insensitive = array(); |
|
| 873 | + |
|
| 874 | + // do indices comparisons case-insensitive |
|
| 875 | + foreach($compareIndices as $k => $value){ |
|
| 876 | + $value['name'] = strtolower($value['name']); |
|
| 877 | + $compareIndices_case_insensitive[strtolower($k)] = $value; |
|
| 878 | + } |
|
| 879 | + $compareIndices = $compareIndices_case_insensitive; |
|
| 880 | + unset($compareIndices_case_insensitive); |
|
| 881 | + |
|
| 882 | + foreach ($indices as $value) { |
|
| 883 | + if (isset($value['source']) && $value['source'] != 'db') |
|
| 884 | + continue; |
|
| 885 | + |
|
| 886 | + |
|
| 887 | + $validDBName = $this->getValidDBName($value['name'], true, 'index', true); |
|
| 888 | + if (isset($compareIndices[$validDBName])) { |
|
| 889 | + $value['name'] = $validDBName; |
|
| 890 | + } |
|
| 891 | + $name = strtolower($value['name']); |
|
| 892 | + |
|
| 893 | + //Don't attempt to fix the same index twice in one pass; |
|
| 894 | + if (isset($correctedIndexs[$name])) |
|
| 895 | + continue; |
|
| 896 | + |
|
| 897 | + //don't bother checking primary nothing we can do about them |
|
| 898 | + if (isset($value['type']) && $value['type'] == 'primary') |
|
| 899 | + continue; |
|
| 900 | + |
|
| 901 | + //database helpers do not know how to handle full text indices |
|
| 902 | + if ($value['type']=='fulltext') |
|
| 903 | + continue; |
|
| 904 | + |
|
| 905 | + if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 906 | + $value['type'] = 'index'; |
|
| 907 | + |
|
| 908 | + if ( !isset($compareIndices[$name]) ) { |
|
| 909 | + //First check if an index exists that doesn't match our name, if so, try to rename it |
|
| 910 | + $found = false; |
|
| 911 | + foreach ($compareIndices as $ex_name => $ex_value) { |
|
| 912 | + if($this->compareVarDefs($ex_value, $value, true)) { |
|
| 913 | + $found = $ex_name; |
|
| 914 | + break; |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | + if ($found) { |
|
| 918 | + $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 919 | + $rename = $this->renameIndexDefs($ex_value, $value, $tablename); |
|
| 920 | + if($execute) { |
|
| 921 | + $this->query($rename, true, "Cannot rename index"); |
|
| 922 | + } |
|
| 923 | + $sql .= is_array($rename)?join("\n", $rename). "\n":$rename."\n"; |
|
| 924 | + |
|
| 925 | + } else { |
|
| 926 | + // ok we need this field lets create it |
|
| 927 | + $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | + $sql .= $this->addIndexes($tablename,array($value), $execute) . "\n"; |
|
| 929 | + } |
|
| 930 | + $take_action = true; |
|
| 931 | + $correctedIndexs[$name] = true; |
|
| 932 | + } elseif ( !$this->compareVarDefs($compareIndices[$name],$value) ) { |
|
| 933 | + // fields are different lets alter it |
|
| 934 | + $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 935 | + foreach ($compareIndices[$name] as $n1 => $t1) { |
|
| 936 | + $sql .= "<$n1>"; |
|
| 937 | + if ( $n1 == 'fields' ) |
|
| 938 | + foreach($t1 as $rKey => $rValue) |
|
| 939 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 940 | + else |
|
| 941 | + $sql .= " $t1 "; |
|
| 942 | + } |
|
| 943 | + $sql .= "*/\n"; |
|
| 944 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 945 | + foreach ($value as $n1 => $t1) { |
|
| 946 | + $sql .= "<$n1>"; |
|
| 947 | + if ( $n1 == 'fields' ) |
|
| 948 | + foreach ($t1 as $rKey => $rValue) |
|
| 949 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 950 | + else |
|
| 951 | + $sql .= " $t1 "; |
|
| 952 | + } |
|
| 953 | + $sql .= "*/\n"; |
|
| 954 | + $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
|
| 955 | + $take_action = true; |
|
| 956 | + $correctedIndexs[$name] = true; |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + return ($take_action === true) ? $sql : ''; |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + /** |
|
| 964 | + * Compares two vardefs |
|
| 965 | + * |
|
| 966 | + * @param array $fielddef1 This is from the database |
|
| 967 | + * @param array $fielddef2 This is from the vardef |
|
| 968 | + * @param bool $ignoreName Ignore name-only differences? |
|
| 969 | + * @return bool true if they match, false if they don't |
|
| 970 | + */ |
|
| 971 | + public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
|
| 972 | + { |
|
| 973 | + foreach ( $fielddef1 as $key => $value ) { |
|
| 974 | + if ($key == 'name' && $ignoreName) |
|
| 975 | + continue; |
|
| 976 | + if (isset($fielddef2[$key])) |
|
| 977 | + { |
|
| 978 | + if (!is_array($fielddef1[$key]) && !is_array($fielddef2[$key])) |
|
| 979 | 979 | { |
| 980 | 980 | if (strtolower($fielddef1[$key]) == strtolower($fielddef2[$key])) |
| 981 | 981 | { |
@@ -990,64 +990,64 @@ discard block |
||
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | - //Ignore len if its not set in the vardef |
|
| 994 | - if ($key == 'len' && empty($fielddef2[$key])) |
|
| 995 | - continue; |
|
| 993 | + //Ignore len if its not set in the vardef |
|
| 994 | + if ($key == 'len' && empty($fielddef2[$key])) |
|
| 995 | + continue; |
|
| 996 | 996 | // if the length in db is greather than the vardef, ignore it |
| 997 | 997 | if ($key == 'len' && ($fielddef1[$key] >= $fielddef2[$key])) { |
| 998 | 998 | continue; |
| 999 | 999 | } |
| 1000 | - return false; |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - return true; |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - /** |
|
| 1007 | - * Compare a field in two tables |
|
| 1008 | - * @deprecated |
|
| 1009 | - * @param string $name field name |
|
| 1010 | - * @param string $table1 |
|
| 1011 | - * @param string $table2 |
|
| 1012 | - * @return array array with keys 'msg','table1','table2' |
|
| 1013 | - */ |
|
| 1014 | - public function compareFieldInTables($name, $table1, $table2) |
|
| 1015 | - { |
|
| 1016 | - $row1 = $this->describeField($name, $table1); |
|
| 1017 | - $row2 = $this->describeField($name, $table2); |
|
| 1018 | - $returnArray = array( |
|
| 1019 | - 'table1' => $row1, |
|
| 1020 | - 'table2' => $row2, |
|
| 1021 | - 'msg' => 'error', |
|
| 1022 | - ); |
|
| 1023 | - |
|
| 1024 | - $ignore_filter = array('Key'=>1); |
|
| 1025 | - if ($row1) { |
|
| 1026 | - if (!$row2) { |
|
| 1027 | - // Exists on table1 but not table2 |
|
| 1028 | - $returnArray['msg'] = 'not_exists_table2'; |
|
| 1029 | - } |
|
| 1030 | - else { |
|
| 1031 | - if (sizeof($row1) != sizeof($row2)) { |
|
| 1032 | - $returnArray['msg'] = 'no_match'; |
|
| 1033 | - } |
|
| 1034 | - else { |
|
| 1035 | - $returnArray['msg'] = 'match'; |
|
| 1036 | - foreach($row1 as $key => $value){ |
|
| 1037 | - //ignore keys when checking we will check them when we do the index check |
|
| 1038 | - if( !isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])){ |
|
| 1039 | - $returnArray['msg'] = 'no_match'; |
|
| 1040 | - } |
|
| 1041 | - } |
|
| 1042 | - } |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1045 | - else { |
|
| 1046 | - $returnArray['msg'] = 'not_exists_table1'; |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - return $returnArray; |
|
| 1050 | - } |
|
| 1000 | + return false; |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + return true; |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + /** |
|
| 1007 | + * Compare a field in two tables |
|
| 1008 | + * @deprecated |
|
| 1009 | + * @param string $name field name |
|
| 1010 | + * @param string $table1 |
|
| 1011 | + * @param string $table2 |
|
| 1012 | + * @return array array with keys 'msg','table1','table2' |
|
| 1013 | + */ |
|
| 1014 | + public function compareFieldInTables($name, $table1, $table2) |
|
| 1015 | + { |
|
| 1016 | + $row1 = $this->describeField($name, $table1); |
|
| 1017 | + $row2 = $this->describeField($name, $table2); |
|
| 1018 | + $returnArray = array( |
|
| 1019 | + 'table1' => $row1, |
|
| 1020 | + 'table2' => $row2, |
|
| 1021 | + 'msg' => 'error', |
|
| 1022 | + ); |
|
| 1023 | + |
|
| 1024 | + $ignore_filter = array('Key'=>1); |
|
| 1025 | + if ($row1) { |
|
| 1026 | + if (!$row2) { |
|
| 1027 | + // Exists on table1 but not table2 |
|
| 1028 | + $returnArray['msg'] = 'not_exists_table2'; |
|
| 1029 | + } |
|
| 1030 | + else { |
|
| 1031 | + if (sizeof($row1) != sizeof($row2)) { |
|
| 1032 | + $returnArray['msg'] = 'no_match'; |
|
| 1033 | + } |
|
| 1034 | + else { |
|
| 1035 | + $returnArray['msg'] = 'match'; |
|
| 1036 | + foreach($row1 as $key => $value){ |
|
| 1037 | + //ignore keys when checking we will check them when we do the index check |
|
| 1038 | + if( !isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])){ |
|
| 1039 | + $returnArray['msg'] = 'no_match'; |
|
| 1040 | + } |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | + else { |
|
| 1046 | + $returnArray['msg'] = 'not_exists_table1'; |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + return $returnArray; |
|
| 1050 | + } |
|
| 1051 | 1051 | // |
| 1052 | 1052 | // /** |
| 1053 | 1053 | // * Compare an index in two different tables |
@@ -1097,193 +1097,193 @@ discard block |
||
| 1097 | 1097 | // } |
| 1098 | 1098 | |
| 1099 | 1099 | |
| 1100 | - /** |
|
| 1101 | - * Creates an index identified by name on the given fields. |
|
| 1102 | - * |
|
| 1103 | - * @param SugarBean $bean SugarBean instance |
|
| 1104 | - * @param array $fieldDefs Field definitions, in vardef format |
|
| 1105 | - * @param string $name index name |
|
| 1106 | - * @param bool $unique optional, true if we want to create an unique index |
|
| 1100 | + /** |
|
| 1101 | + * Creates an index identified by name on the given fields. |
|
| 1102 | + * |
|
| 1103 | + * @param SugarBean $bean SugarBean instance |
|
| 1104 | + * @param array $fieldDefs Field definitions, in vardef format |
|
| 1105 | + * @param string $name index name |
|
| 1106 | + * @param bool $unique optional, true if we want to create an unique index |
|
| 1107 | 1107 | * @return bool query result |
| 1108 | 1108 | */ |
| 1109 | - public function createIndex(SugarBean $bean, $fieldDefs, $name, $unique = true) |
|
| 1110 | - { |
|
| 1111 | - $sql = $this->createIndexSQL($bean, $fieldDefs, $name, $unique); |
|
| 1112 | - $tablename = $bean->getTableName(); |
|
| 1113 | - $msg = "Error creating index $name on table: $tablename:"; |
|
| 1114 | - return $this->query($sql,true,$msg); |
|
| 1115 | - } |
|
| 1116 | - |
|
| 1117 | - /** |
|
| 1118 | - * returns a SQL query that creates the indices as defined in metadata |
|
| 1119 | - * @param array $indices Assoc array with index definitions from vardefs |
|
| 1120 | - * @param string $table Focus table |
|
| 1121 | - * @return array Array of SQL queries to generate indices |
|
| 1122 | - */ |
|
| 1123 | - public function getConstraintSql($indices, $table) |
|
| 1124 | - { |
|
| 1125 | - if (!$this->isFieldArray($indices)) |
|
| 1126 | - $indices = array($indices); |
|
| 1127 | - |
|
| 1128 | - $columns = array(); |
|
| 1129 | - |
|
| 1130 | - foreach ($indices as $index) { |
|
| 1131 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | - continue; |
|
| 1133 | - if (isset($index['source']) && $index['source'] != 'db') |
|
| 1134 | - continue; |
|
| 1135 | - |
|
| 1136 | - $sql = $this->add_drop_constraint($table, $index); |
|
| 1137 | - |
|
| 1138 | - if(!empty($sql)) { |
|
| 1139 | - $columns[] = $sql; |
|
| 1140 | - } |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - return $columns; |
|
| 1144 | - } |
|
| 1145 | - |
|
| 1146 | - /** |
|
| 1147 | - * Adds a new indexes |
|
| 1148 | - * |
|
| 1149 | - * @param string $tablename |
|
| 1150 | - * @param array $indexes indexes to add |
|
| 1151 | - * @param bool $execute true if we want to execute the returned sql statement |
|
| 1152 | - * @return string SQL statement |
|
| 1153 | - */ |
|
| 1154 | - public function addIndexes($tablename, $indexes, $execute = true) |
|
| 1155 | - { |
|
| 1156 | - $alters = $this->getConstraintSql($indexes, $tablename); |
|
| 1157 | - if ($execute) { |
|
| 1158 | - foreach($alters as $sql) { |
|
| 1159 | - $this->query($sql, true, "Error adding index: "); |
|
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - if(!empty($alters)) { |
|
| 1163 | - $sql = join(";\n", $alters).";\n"; |
|
| 1164 | - } else { |
|
| 1165 | - $sql = ''; |
|
| 1166 | - } |
|
| 1167 | - return $sql; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - /** |
|
| 1171 | - * Drops indexes |
|
| 1172 | - * |
|
| 1173 | - * @param string $tablename |
|
| 1174 | - * @param array $indexes indexes to drop |
|
| 1175 | - * @param bool $execute true if we want to execute the returned sql statement |
|
| 1176 | - * @return string SQL statement |
|
| 1177 | - */ |
|
| 1178 | - public function dropIndexes($tablename, $indexes, $execute = true) |
|
| 1179 | - { |
|
| 1180 | - $sqls = array(); |
|
| 1181 | - foreach ($indexes as $index) { |
|
| 1182 | - $name =$index['name']; |
|
| 1183 | - $sqls[$name] = $this->add_drop_constraint($tablename,$index,true); |
|
| 1184 | - } |
|
| 1185 | - if (!empty($sqls) && $execute) { |
|
| 1186 | - foreach($sqls as $name => $sql) { |
|
| 1187 | - unset(self::$index_descriptions[$tablename][$name]); |
|
| 1188 | - $this->query($sql); |
|
| 1189 | - } |
|
| 1190 | - } |
|
| 1191 | - if(!empty($sqls)) { |
|
| 1192 | - return join(";\n",$sqls).";"; |
|
| 1193 | - } else { |
|
| 1194 | - return ''; |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1197 | - |
|
| 1198 | - /** |
|
| 1199 | - * Modifies indexes |
|
| 1200 | - * |
|
| 1201 | - * @param string $tablename |
|
| 1202 | - * @param array $indexes indexes to modify |
|
| 1203 | - * @param bool $execute true if we want to execute the returned sql statement |
|
| 1204 | - * @return string SQL statement |
|
| 1205 | - */ |
|
| 1206 | - public function modifyIndexes($tablename, $indexes, $execute = true) |
|
| 1207 | - { |
|
| 1208 | - return $this->dropIndexes($tablename, $indexes, $execute)."\n". |
|
| 1209 | - $this->addIndexes($tablename, $indexes, $execute); |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - /** |
|
| 1213 | - * Adds a column to table identified by field def. |
|
| 1214 | - * |
|
| 1215 | - * @param string $tablename |
|
| 1216 | - * @param array $fieldDefs |
|
| 1109 | + public function createIndex(SugarBean $bean, $fieldDefs, $name, $unique = true) |
|
| 1110 | + { |
|
| 1111 | + $sql = $this->createIndexSQL($bean, $fieldDefs, $name, $unique); |
|
| 1112 | + $tablename = $bean->getTableName(); |
|
| 1113 | + $msg = "Error creating index $name on table: $tablename:"; |
|
| 1114 | + return $this->query($sql,true,$msg); |
|
| 1115 | + } |
|
| 1116 | + |
|
| 1117 | + /** |
|
| 1118 | + * returns a SQL query that creates the indices as defined in metadata |
|
| 1119 | + * @param array $indices Assoc array with index definitions from vardefs |
|
| 1120 | + * @param string $table Focus table |
|
| 1121 | + * @return array Array of SQL queries to generate indices |
|
| 1122 | + */ |
|
| 1123 | + public function getConstraintSql($indices, $table) |
|
| 1124 | + { |
|
| 1125 | + if (!$this->isFieldArray($indices)) |
|
| 1126 | + $indices = array($indices); |
|
| 1127 | + |
|
| 1128 | + $columns = array(); |
|
| 1129 | + |
|
| 1130 | + foreach ($indices as $index) { |
|
| 1131 | + if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | + continue; |
|
| 1133 | + if (isset($index['source']) && $index['source'] != 'db') |
|
| 1134 | + continue; |
|
| 1135 | + |
|
| 1136 | + $sql = $this->add_drop_constraint($table, $index); |
|
| 1137 | + |
|
| 1138 | + if(!empty($sql)) { |
|
| 1139 | + $columns[] = $sql; |
|
| 1140 | + } |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + return $columns; |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + /** |
|
| 1147 | + * Adds a new indexes |
|
| 1148 | + * |
|
| 1149 | + * @param string $tablename |
|
| 1150 | + * @param array $indexes indexes to add |
|
| 1151 | + * @param bool $execute true if we want to execute the returned sql statement |
|
| 1152 | + * @return string SQL statement |
|
| 1153 | + */ |
|
| 1154 | + public function addIndexes($tablename, $indexes, $execute = true) |
|
| 1155 | + { |
|
| 1156 | + $alters = $this->getConstraintSql($indexes, $tablename); |
|
| 1157 | + if ($execute) { |
|
| 1158 | + foreach($alters as $sql) { |
|
| 1159 | + $this->query($sql, true, "Error adding index: "); |
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + if(!empty($alters)) { |
|
| 1163 | + $sql = join(";\n", $alters).";\n"; |
|
| 1164 | + } else { |
|
| 1165 | + $sql = ''; |
|
| 1166 | + } |
|
| 1167 | + return $sql; |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + /** |
|
| 1171 | + * Drops indexes |
|
| 1172 | + * |
|
| 1173 | + * @param string $tablename |
|
| 1174 | + * @param array $indexes indexes to drop |
|
| 1175 | + * @param bool $execute true if we want to execute the returned sql statement |
|
| 1176 | + * @return string SQL statement |
|
| 1177 | + */ |
|
| 1178 | + public function dropIndexes($tablename, $indexes, $execute = true) |
|
| 1179 | + { |
|
| 1180 | + $sqls = array(); |
|
| 1181 | + foreach ($indexes as $index) { |
|
| 1182 | + $name =$index['name']; |
|
| 1183 | + $sqls[$name] = $this->add_drop_constraint($tablename,$index,true); |
|
| 1184 | + } |
|
| 1185 | + if (!empty($sqls) && $execute) { |
|
| 1186 | + foreach($sqls as $name => $sql) { |
|
| 1187 | + unset(self::$index_descriptions[$tablename][$name]); |
|
| 1188 | + $this->query($sql); |
|
| 1189 | + } |
|
| 1190 | + } |
|
| 1191 | + if(!empty($sqls)) { |
|
| 1192 | + return join(";\n",$sqls).";"; |
|
| 1193 | + } else { |
|
| 1194 | + return ''; |
|
| 1195 | + } |
|
| 1196 | + } |
|
| 1197 | + |
|
| 1198 | + /** |
|
| 1199 | + * Modifies indexes |
|
| 1200 | + * |
|
| 1201 | + * @param string $tablename |
|
| 1202 | + * @param array $indexes indexes to modify |
|
| 1203 | + * @param bool $execute true if we want to execute the returned sql statement |
|
| 1204 | + * @return string SQL statement |
|
| 1205 | + */ |
|
| 1206 | + public function modifyIndexes($tablename, $indexes, $execute = true) |
|
| 1207 | + { |
|
| 1208 | + return $this->dropIndexes($tablename, $indexes, $execute)."\n". |
|
| 1209 | + $this->addIndexes($tablename, $indexes, $execute); |
|
| 1210 | + } |
|
| 1211 | + |
|
| 1212 | + /** |
|
| 1213 | + * Adds a column to table identified by field def. |
|
| 1214 | + * |
|
| 1215 | + * @param string $tablename |
|
| 1216 | + * @param array $fieldDefs |
|
| 1217 | 1217 | * @return bool query result |
| 1218 | 1218 | */ |
| 1219 | - public function addColumn($tablename, $fieldDefs) |
|
| 1220 | - { |
|
| 1221 | - $sql = $this->addColumnSQL($tablename, $fieldDefs); |
|
| 1222 | - if ($this->isFieldArray($fieldDefs)){ |
|
| 1223 | - $columns = array(); |
|
| 1224 | - foreach ($fieldDefs as $fieldDef) |
|
| 1225 | - $columns[] = $fieldDef['name']; |
|
| 1226 | - $columns = implode(",", $columns); |
|
| 1227 | - } |
|
| 1228 | - else { |
|
| 1229 | - $columns = $fieldDefs['name']; |
|
| 1230 | - } |
|
| 1231 | - $msg = "Error adding column(s) $columns on table: $tablename:"; |
|
| 1232 | - return $this->query($sql,true,$msg); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Alters old column identified by oldFieldDef to new fieldDef. |
|
| 1237 | - * |
|
| 1238 | - * @param string $tablename |
|
| 1239 | - * @param array $newFieldDef |
|
| 1240 | - * @param bool $ignoreRequired optional, true if we are ignoring this being a required field |
|
| 1219 | + public function addColumn($tablename, $fieldDefs) |
|
| 1220 | + { |
|
| 1221 | + $sql = $this->addColumnSQL($tablename, $fieldDefs); |
|
| 1222 | + if ($this->isFieldArray($fieldDefs)){ |
|
| 1223 | + $columns = array(); |
|
| 1224 | + foreach ($fieldDefs as $fieldDef) |
|
| 1225 | + $columns[] = $fieldDef['name']; |
|
| 1226 | + $columns = implode(",", $columns); |
|
| 1227 | + } |
|
| 1228 | + else { |
|
| 1229 | + $columns = $fieldDefs['name']; |
|
| 1230 | + } |
|
| 1231 | + $msg = "Error adding column(s) $columns on table: $tablename:"; |
|
| 1232 | + return $this->query($sql,true,$msg); |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * Alters old column identified by oldFieldDef to new fieldDef. |
|
| 1237 | + * |
|
| 1238 | + * @param string $tablename |
|
| 1239 | + * @param array $newFieldDef |
|
| 1240 | + * @param bool $ignoreRequired optional, true if we are ignoring this being a required field |
|
| 1241 | 1241 | * @return bool query result |
| 1242 | 1242 | */ |
| 1243 | - public function alterColumn($tablename, $newFieldDef, $ignoreRequired = false) |
|
| 1244 | - { |
|
| 1245 | - $sql = $this->alterColumnSQL($tablename, $newFieldDef,$ignoreRequired); |
|
| 1246 | - if ($this->isFieldArray($newFieldDef)){ |
|
| 1247 | - $columns = array(); |
|
| 1248 | - foreach ($newFieldDef as $fieldDef) { |
|
| 1249 | - $columns[] = $fieldDef['name']; |
|
| 1250 | - } |
|
| 1251 | - $columns = implode(",", $columns); |
|
| 1252 | - } |
|
| 1253 | - else { |
|
| 1254 | - $columns = $newFieldDef['name']; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - $msg = "Error altering column(s) $columns on table: $tablename:"; |
|
| 1258 | - $res = $this->query($sql,true,$msg); |
|
| 1259 | - if($res) { |
|
| 1260 | - $this->getTableDescription($tablename, true); // reload table description after altering |
|
| 1261 | - } |
|
| 1262 | - return $res; |
|
| 1263 | - } |
|
| 1264 | - |
|
| 1265 | - /** |
|
| 1266 | - * Drops the table associated with a bean |
|
| 1267 | - * |
|
| 1268 | - * @param SugarBean $bean SugarBean instance |
|
| 1243 | + public function alterColumn($tablename, $newFieldDef, $ignoreRequired = false) |
|
| 1244 | + { |
|
| 1245 | + $sql = $this->alterColumnSQL($tablename, $newFieldDef,$ignoreRequired); |
|
| 1246 | + if ($this->isFieldArray($newFieldDef)){ |
|
| 1247 | + $columns = array(); |
|
| 1248 | + foreach ($newFieldDef as $fieldDef) { |
|
| 1249 | + $columns[] = $fieldDef['name']; |
|
| 1250 | + } |
|
| 1251 | + $columns = implode(",", $columns); |
|
| 1252 | + } |
|
| 1253 | + else { |
|
| 1254 | + $columns = $newFieldDef['name']; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + $msg = "Error altering column(s) $columns on table: $tablename:"; |
|
| 1258 | + $res = $this->query($sql,true,$msg); |
|
| 1259 | + if($res) { |
|
| 1260 | + $this->getTableDescription($tablename, true); // reload table description after altering |
|
| 1261 | + } |
|
| 1262 | + return $res; |
|
| 1263 | + } |
|
| 1264 | + |
|
| 1265 | + /** |
|
| 1266 | + * Drops the table associated with a bean |
|
| 1267 | + * |
|
| 1268 | + * @param SugarBean $bean SugarBean instance |
|
| 1269 | 1269 | * @return bool query result |
| 1270 | - */ |
|
| 1271 | - public function dropTable(SugarBean $bean) |
|
| 1272 | - { |
|
| 1273 | - return $this->dropTableName($bean->getTableName()); |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Drops the table by name |
|
| 1278 | - * |
|
| 1279 | - * @param string $name Table name |
|
| 1270 | + */ |
|
| 1271 | + public function dropTable(SugarBean $bean) |
|
| 1272 | + { |
|
| 1273 | + return $this->dropTableName($bean->getTableName()); |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Drops the table by name |
|
| 1278 | + * |
|
| 1279 | + * @param string $name Table name |
|
| 1280 | 1280 | * @return bool query result |
| 1281 | - */ |
|
| 1282 | - public function dropTableName($name) |
|
| 1283 | - { |
|
| 1284 | - $sql = $this->dropTableNameSQL($name); |
|
| 1285 | - return $this->query($sql,true,"Error dropping table $name:"); |
|
| 1286 | - } |
|
| 1281 | + */ |
|
| 1282 | + public function dropTableName($name) |
|
| 1283 | + { |
|
| 1284 | + $sql = $this->dropTableNameSQL($name); |
|
| 1285 | + return $this->query($sql,true,"Error dropping table $name:"); |
|
| 1286 | + } |
|
| 1287 | 1287 | |
| 1288 | 1288 | /** |
| 1289 | 1289 | * Deletes a column identified by fieldDef. |
@@ -1292,13 +1292,13 @@ discard block |
||
| 1292 | 1292 | * @param array $fieldDefs Vardef definition of the field |
| 1293 | 1293 | * @return bool query result |
| 1294 | 1294 | */ |
| 1295 | - public function deleteColumn(SugarBean $bean, $fieldDefs) |
|
| 1296 | - { |
|
| 1297 | - $tablename = $bean->getTableName(); |
|
| 1298 | - $sql = $this->dropColumnSQL($tablename, $fieldDefs); |
|
| 1299 | - $msg = "Error deleting column(s) on table: $tablename:"; |
|
| 1300 | - return $this->query($sql,true,$msg); |
|
| 1301 | - } |
|
| 1295 | + public function deleteColumn(SugarBean $bean, $fieldDefs) |
|
| 1296 | + { |
|
| 1297 | + $tablename = $bean->getTableName(); |
|
| 1298 | + $sql = $this->dropColumnSQL($tablename, $fieldDefs); |
|
| 1299 | + $msg = "Error deleting column(s) on table: $tablename:"; |
|
| 1300 | + return $this->query($sql,true,$msg); |
|
| 1301 | + } |
|
| 1302 | 1302 | |
| 1303 | 1303 | /** |
| 1304 | 1304 | * Generate a set of Insert statements based on the bean given |
@@ -1313,228 +1313,228 @@ discard block |
||
| 1313 | 1313 | * @param bool $is_related_query |
| 1314 | 1314 | * @return string SQL insert statement |
| 1315 | 1315 | */ |
| 1316 | - public function generateInsertSQL(SugarBean $bean, $select_query, $start, $count = -1, $table, $is_related_query = false) |
|
| 1317 | - { |
|
| 1318 | - $this->log->info('call to DBManager::generateInsertSQL() is deprecated'); |
|
| 1319 | - global $sugar_config; |
|
| 1320 | - |
|
| 1321 | - $rows_found = 0; |
|
| 1322 | - $count_query = $bean->create_list_count_query($select_query); |
|
| 1323 | - if(!empty($count_query)) |
|
| 1324 | - { |
|
| 1325 | - // We have a count query. Run it and get the results. |
|
| 1326 | - $result = $this->query($count_query, true, "Error running count query for $this->object_name List: "); |
|
| 1327 | - $assoc = $this->fetchByAssoc($result); |
|
| 1328 | - if(!empty($assoc['c'])) |
|
| 1329 | - { |
|
| 1330 | - $rows_found = $assoc['c']; |
|
| 1331 | - } |
|
| 1332 | - } |
|
| 1333 | - if($count == -1){ |
|
| 1334 | - $count = $sugar_config['list_max_entries_per_page']; |
|
| 1335 | - } |
|
| 1336 | - $next_offset = $start + $count; |
|
| 1337 | - |
|
| 1338 | - $result = $this->limitQuery($select_query, $start, $count); |
|
| 1339 | - // get basic insert |
|
| 1340 | - $sql = "INSERT INTO ".$table; |
|
| 1341 | - $custom_sql = "INSERT INTO ".$table."_cstm"; |
|
| 1342 | - |
|
| 1343 | - // get field definitions |
|
| 1344 | - $fields = $bean->getFieldDefinitions(); |
|
| 1345 | - $custom_fields = array(); |
|
| 1346 | - |
|
| 1347 | - if($bean->hasCustomFields()){ |
|
| 1348 | - foreach ($fields as $fieldDef){ |
|
| 1349 | - if($fieldDef['source'] == 'custom_fields'){ |
|
| 1350 | - $custom_fields[$fieldDef['name']] = $fieldDef['name']; |
|
| 1351 | - } |
|
| 1352 | - } |
|
| 1353 | - if(!empty($custom_fields)){ |
|
| 1354 | - $custom_fields['id_c'] = 'id_c'; |
|
| 1355 | - $id_field = array('name' => 'id_c', 'custom_type' => 'id',); |
|
| 1356 | - $fields[] = $id_field; |
|
| 1357 | - } |
|
| 1358 | - } |
|
| 1359 | - |
|
| 1360 | - // get column names and values |
|
| 1361 | - $row_array = array(); |
|
| 1362 | - $columns = array(); |
|
| 1363 | - $cstm_row_array = array(); |
|
| 1364 | - $cstm_columns = array(); |
|
| 1365 | - $built_columns = false; |
|
| 1366 | - while(($row = $this->fetchByAssoc($result)) != null) |
|
| 1367 | - { |
|
| 1368 | - $values = array(); |
|
| 1369 | - $cstm_values = array(); |
|
| 1370 | - if(!$is_related_query){ |
|
| 1371 | - foreach ($fields as $fieldDef) |
|
| 1372 | - { |
|
| 1373 | - if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1374 | - $val = $row[$fieldDef['name']]; |
|
| 1375 | - |
|
| 1376 | - //handle auto increment values here only need to do this on insert not create |
|
| 1377 | - if ($fieldDef['name'] == 'deleted'){ |
|
| 1378 | - $values['deleted'] = $val; |
|
| 1379 | - if(!$built_columns){ |
|
| 1380 | - $columns[] = 'deleted'; |
|
| 1381 | - } |
|
| 1382 | - } |
|
| 1383 | - else |
|
| 1384 | - { |
|
| 1385 | - $type = $fieldDef['type']; |
|
| 1386 | - if(!empty($fieldDef['custom_type'])){ |
|
| 1387 | - $type = $fieldDef['custom_type']; |
|
| 1388 | - } |
|
| 1389 | - // need to do some thing about types of values |
|
| 1390 | - if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
|
| 1391 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | - $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1393 | - else |
|
| 1394 | - $values[$fieldDef['name']] = 'null'; |
|
| 1395 | - }else{ |
|
| 1396 | - if(isset($type) && $type=='int') { |
|
| 1397 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | - $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1399 | - else |
|
| 1400 | - $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1401 | - } else { |
|
| 1402 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | - $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1404 | - else |
|
| 1405 | - $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1406 | - } |
|
| 1407 | - } |
|
| 1408 | - if(!$built_columns){ |
|
| 1409 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | - $cstm_columns[] = $fieldDef['name']; |
|
| 1411 | - else |
|
| 1412 | - $columns[] = $fieldDef['name']; |
|
| 1413 | - } |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - } |
|
| 1417 | - } else { |
|
| 1418 | - foreach ($row as $key=>$val) |
|
| 1419 | - { |
|
| 1420 | - if($key != 'orc_row'){ |
|
| 1421 | - $values[$key] = "'$val'"; |
|
| 1422 | - if(!$built_columns){ |
|
| 1423 | - $columns[] = $key; |
|
| 1424 | - } |
|
| 1425 | - } |
|
| 1426 | - } |
|
| 1427 | - } |
|
| 1428 | - $built_columns = true; |
|
| 1429 | - if(!empty($values)){ |
|
| 1430 | - $row_array[] = $values; |
|
| 1431 | - } |
|
| 1432 | - if(!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)){ |
|
| 1433 | - $cstm_row_array[] = $cstm_values; |
|
| 1434 | - } |
|
| 1435 | - } |
|
| 1436 | - |
|
| 1437 | - //if (sizeof ($values) == 0) return ""; // no columns set |
|
| 1438 | - |
|
| 1439 | - // get the entire sql |
|
| 1440 | - $sql .= "(".implode(",", $columns).") "; |
|
| 1441 | - $sql .= "VALUES"; |
|
| 1442 | - for($i = 0; $i < count($row_array); $i++){ |
|
| 1443 | - $sql .= " (".implode(",", $row_array[$i]).")"; |
|
| 1444 | - if($i < (count($row_array) - 1)){ |
|
| 1445 | - $sql .= ", "; |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1448 | - //custom |
|
| 1449 | - // get the entire sql |
|
| 1450 | - $custom_sql .= "(".implode(",", $cstm_columns).") "; |
|
| 1451 | - $custom_sql .= "VALUES"; |
|
| 1452 | - |
|
| 1453 | - for($i = 0; $i < count($cstm_row_array); $i++){ |
|
| 1454 | - $custom_sql .= " (".implode(",", $cstm_row_array[$i]).")"; |
|
| 1455 | - if($i < (count($cstm_row_array) - 1)){ |
|
| 1456 | - $custom_sql .= ", "; |
|
| 1457 | - } |
|
| 1458 | - } |
|
| 1459 | - return array('data' => $sql, 'cstm_sql' => $custom_sql, /*'result_count' => $row_count, */ 'total_count' => $rows_found, 'next_offset' => $next_offset); |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - /** |
|
| 1463 | - * @deprecated |
|
| 1464 | - * Disconnects all instances |
|
| 1465 | - */ |
|
| 1466 | - public function disconnectAll() |
|
| 1467 | - { |
|
| 1468 | - DBManagerFactory::disconnectAll(); |
|
| 1469 | - } |
|
| 1470 | - |
|
| 1471 | - /** |
|
| 1472 | - * This function sets the query threshold limit |
|
| 1473 | - * |
|
| 1474 | - * @param int $limit value of query threshold limit |
|
| 1475 | - */ |
|
| 1476 | - public static function setQueryLimit($limit) |
|
| 1477 | - { |
|
| 1478 | - //reset the queryCount |
|
| 1479 | - self::$queryCount = 0; |
|
| 1480 | - self::$queryLimit = $limit; |
|
| 1481 | - } |
|
| 1482 | - |
|
| 1483 | - /** |
|
| 1484 | - * Returns the static queryCount value |
|
| 1485 | - * |
|
| 1486 | - * @return int value of the queryCount static variable |
|
| 1487 | - */ |
|
| 1488 | - public static function getQueryCount() |
|
| 1489 | - { |
|
| 1490 | - return self::$queryCount; |
|
| 1491 | - } |
|
| 1492 | - |
|
| 1493 | - |
|
| 1494 | - /** |
|
| 1495 | - * Resets the queryCount value to 0 |
|
| 1496 | - * |
|
| 1497 | - */ |
|
| 1498 | - public static function resetQueryCount() |
|
| 1499 | - { |
|
| 1500 | - self::$queryCount = 0; |
|
| 1501 | - } |
|
| 1502 | - |
|
| 1503 | - /** |
|
| 1504 | - * This function increments the global $sql_queries variable |
|
| 1505 | - */ |
|
| 1506 | - public function countQuery() |
|
| 1507 | - { |
|
| 1508 | - if (self::$queryLimit != 0 && ++self::$queryCount > self::$queryLimit |
|
| 1509 | - &&(empty($GLOBALS['current_user']) || !is_admin($GLOBALS['current_user']))) { |
|
| 1316 | + public function generateInsertSQL(SugarBean $bean, $select_query, $start, $count = -1, $table, $is_related_query = false) |
|
| 1317 | + { |
|
| 1318 | + $this->log->info('call to DBManager::generateInsertSQL() is deprecated'); |
|
| 1319 | + global $sugar_config; |
|
| 1320 | + |
|
| 1321 | + $rows_found = 0; |
|
| 1322 | + $count_query = $bean->create_list_count_query($select_query); |
|
| 1323 | + if(!empty($count_query)) |
|
| 1324 | + { |
|
| 1325 | + // We have a count query. Run it and get the results. |
|
| 1326 | + $result = $this->query($count_query, true, "Error running count query for $this->object_name List: "); |
|
| 1327 | + $assoc = $this->fetchByAssoc($result); |
|
| 1328 | + if(!empty($assoc['c'])) |
|
| 1329 | + { |
|
| 1330 | + $rows_found = $assoc['c']; |
|
| 1331 | + } |
|
| 1332 | + } |
|
| 1333 | + if($count == -1){ |
|
| 1334 | + $count = $sugar_config['list_max_entries_per_page']; |
|
| 1335 | + } |
|
| 1336 | + $next_offset = $start + $count; |
|
| 1337 | + |
|
| 1338 | + $result = $this->limitQuery($select_query, $start, $count); |
|
| 1339 | + // get basic insert |
|
| 1340 | + $sql = "INSERT INTO ".$table; |
|
| 1341 | + $custom_sql = "INSERT INTO ".$table."_cstm"; |
|
| 1342 | + |
|
| 1343 | + // get field definitions |
|
| 1344 | + $fields = $bean->getFieldDefinitions(); |
|
| 1345 | + $custom_fields = array(); |
|
| 1346 | + |
|
| 1347 | + if($bean->hasCustomFields()){ |
|
| 1348 | + foreach ($fields as $fieldDef){ |
|
| 1349 | + if($fieldDef['source'] == 'custom_fields'){ |
|
| 1350 | + $custom_fields[$fieldDef['name']] = $fieldDef['name']; |
|
| 1351 | + } |
|
| 1352 | + } |
|
| 1353 | + if(!empty($custom_fields)){ |
|
| 1354 | + $custom_fields['id_c'] = 'id_c'; |
|
| 1355 | + $id_field = array('name' => 'id_c', 'custom_type' => 'id',); |
|
| 1356 | + $fields[] = $id_field; |
|
| 1357 | + } |
|
| 1358 | + } |
|
| 1359 | + |
|
| 1360 | + // get column names and values |
|
| 1361 | + $row_array = array(); |
|
| 1362 | + $columns = array(); |
|
| 1363 | + $cstm_row_array = array(); |
|
| 1364 | + $cstm_columns = array(); |
|
| 1365 | + $built_columns = false; |
|
| 1366 | + while(($row = $this->fetchByAssoc($result)) != null) |
|
| 1367 | + { |
|
| 1368 | + $values = array(); |
|
| 1369 | + $cstm_values = array(); |
|
| 1370 | + if(!$is_related_query){ |
|
| 1371 | + foreach ($fields as $fieldDef) |
|
| 1372 | + { |
|
| 1373 | + if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1374 | + $val = $row[$fieldDef['name']]; |
|
| 1375 | + |
|
| 1376 | + //handle auto increment values here only need to do this on insert not create |
|
| 1377 | + if ($fieldDef['name'] == 'deleted'){ |
|
| 1378 | + $values['deleted'] = $val; |
|
| 1379 | + if(!$built_columns){ |
|
| 1380 | + $columns[] = 'deleted'; |
|
| 1381 | + } |
|
| 1382 | + } |
|
| 1383 | + else |
|
| 1384 | + { |
|
| 1385 | + $type = $fieldDef['type']; |
|
| 1386 | + if(!empty($fieldDef['custom_type'])){ |
|
| 1387 | + $type = $fieldDef['custom_type']; |
|
| 1388 | + } |
|
| 1389 | + // need to do some thing about types of values |
|
| 1390 | + if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
|
| 1391 | + if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | + $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1393 | + else |
|
| 1394 | + $values[$fieldDef['name']] = 'null'; |
|
| 1395 | + }else{ |
|
| 1396 | + if(isset($type) && $type=='int') { |
|
| 1397 | + if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | + $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1399 | + else |
|
| 1400 | + $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1401 | + } else { |
|
| 1402 | + if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | + $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1404 | + else |
|
| 1405 | + $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1406 | + } |
|
| 1407 | + } |
|
| 1408 | + if(!$built_columns){ |
|
| 1409 | + if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | + $cstm_columns[] = $fieldDef['name']; |
|
| 1411 | + else |
|
| 1412 | + $columns[] = $fieldDef['name']; |
|
| 1413 | + } |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + } |
|
| 1417 | + } else { |
|
| 1418 | + foreach ($row as $key=>$val) |
|
| 1419 | + { |
|
| 1420 | + if($key != 'orc_row'){ |
|
| 1421 | + $values[$key] = "'$val'"; |
|
| 1422 | + if(!$built_columns){ |
|
| 1423 | + $columns[] = $key; |
|
| 1424 | + } |
|
| 1425 | + } |
|
| 1426 | + } |
|
| 1427 | + } |
|
| 1428 | + $built_columns = true; |
|
| 1429 | + if(!empty($values)){ |
|
| 1430 | + $row_array[] = $values; |
|
| 1431 | + } |
|
| 1432 | + if(!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)){ |
|
| 1433 | + $cstm_row_array[] = $cstm_values; |
|
| 1434 | + } |
|
| 1435 | + } |
|
| 1436 | + |
|
| 1437 | + //if (sizeof ($values) == 0) return ""; // no columns set |
|
| 1438 | + |
|
| 1439 | + // get the entire sql |
|
| 1440 | + $sql .= "(".implode(",", $columns).") "; |
|
| 1441 | + $sql .= "VALUES"; |
|
| 1442 | + for($i = 0; $i < count($row_array); $i++){ |
|
| 1443 | + $sql .= " (".implode(",", $row_array[$i]).")"; |
|
| 1444 | + if($i < (count($row_array) - 1)){ |
|
| 1445 | + $sql .= ", "; |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | + //custom |
|
| 1449 | + // get the entire sql |
|
| 1450 | + $custom_sql .= "(".implode(",", $cstm_columns).") "; |
|
| 1451 | + $custom_sql .= "VALUES"; |
|
| 1452 | + |
|
| 1453 | + for($i = 0; $i < count($cstm_row_array); $i++){ |
|
| 1454 | + $custom_sql .= " (".implode(",", $cstm_row_array[$i]).")"; |
|
| 1455 | + if($i < (count($cstm_row_array) - 1)){ |
|
| 1456 | + $custom_sql .= ", "; |
|
| 1457 | + } |
|
| 1458 | + } |
|
| 1459 | + return array('data' => $sql, 'cstm_sql' => $custom_sql, /*'result_count' => $row_count, */ 'total_count' => $rows_found, 'next_offset' => $next_offset); |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + /** |
|
| 1463 | + * @deprecated |
|
| 1464 | + * Disconnects all instances |
|
| 1465 | + */ |
|
| 1466 | + public function disconnectAll() |
|
| 1467 | + { |
|
| 1468 | + DBManagerFactory::disconnectAll(); |
|
| 1469 | + } |
|
| 1470 | + |
|
| 1471 | + /** |
|
| 1472 | + * This function sets the query threshold limit |
|
| 1473 | + * |
|
| 1474 | + * @param int $limit value of query threshold limit |
|
| 1475 | + */ |
|
| 1476 | + public static function setQueryLimit($limit) |
|
| 1477 | + { |
|
| 1478 | + //reset the queryCount |
|
| 1479 | + self::$queryCount = 0; |
|
| 1480 | + self::$queryLimit = $limit; |
|
| 1481 | + } |
|
| 1482 | + |
|
| 1483 | + /** |
|
| 1484 | + * Returns the static queryCount value |
|
| 1485 | + * |
|
| 1486 | + * @return int value of the queryCount static variable |
|
| 1487 | + */ |
|
| 1488 | + public static function getQueryCount() |
|
| 1489 | + { |
|
| 1490 | + return self::$queryCount; |
|
| 1491 | + } |
|
| 1492 | + |
|
| 1493 | + |
|
| 1494 | + /** |
|
| 1495 | + * Resets the queryCount value to 0 |
|
| 1496 | + * |
|
| 1497 | + */ |
|
| 1498 | + public static function resetQueryCount() |
|
| 1499 | + { |
|
| 1500 | + self::$queryCount = 0; |
|
| 1501 | + } |
|
| 1502 | + |
|
| 1503 | + /** |
|
| 1504 | + * This function increments the global $sql_queries variable |
|
| 1505 | + */ |
|
| 1506 | + public function countQuery() |
|
| 1507 | + { |
|
| 1508 | + if (self::$queryLimit != 0 && ++self::$queryCount > self::$queryLimit |
|
| 1509 | + &&(empty($GLOBALS['current_user']) || !is_admin($GLOBALS['current_user']))) { |
|
| 1510 | 1510 | require_once('include/resource/ResourceManager.php'); |
| 1511 | 1511 | $resourceManager = ResourceManager::getInstance(); |
| 1512 | 1512 | $resourceManager->notifyObservers('ERR_QUERY_LIMIT'); |
| 1513 | - } |
|
| 1514 | - } |
|
| 1513 | + } |
|
| 1514 | + } |
|
| 1515 | + |
|
| 1516 | + /** |
|
| 1517 | + * Pre-process string for quoting |
|
| 1518 | + * @internal |
|
| 1519 | + * @param string $string |
|
| 1520 | + * @return string |
|
| 1521 | + */ |
|
| 1522 | + protected function quoteInternal($string) |
|
| 1523 | + { |
|
| 1524 | + return from_html($string); |
|
| 1525 | + } |
|
| 1515 | 1526 | |
| 1516 | - /** |
|
| 1517 | - * Pre-process string for quoting |
|
| 1518 | - * @internal |
|
| 1519 | - * @param string $string |
|
| 1527 | + /** |
|
| 1528 | + * Return string properly quoted with '' |
|
| 1529 | + * @param string $string |
|
| 1520 | 1530 | * @return string |
| 1521 | 1531 | */ |
| 1522 | - protected function quoteInternal($string) |
|
| 1523 | - { |
|
| 1524 | - return from_html($string); |
|
| 1525 | - } |
|
| 1526 | - |
|
| 1527 | - /** |
|
| 1528 | - * Return string properly quoted with '' |
|
| 1529 | - * @param string $string |
|
| 1530 | - * @return string |
|
| 1531 | - */ |
|
| 1532 | - public function quoted($string) |
|
| 1533 | - { |
|
| 1534 | - return "'".$this->quote($string)."'"; |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - /** |
|
| 1532 | + public function quoted($string) |
|
| 1533 | + { |
|
| 1534 | + return "'".$this->quote($string)."'"; |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + /** |
|
| 1538 | 1538 | * Quote value according to type |
| 1539 | 1539 | * Numerics aren't quoted |
| 1540 | 1540 | * Dates are converted and quoted |
@@ -1544,13 +1544,13 @@ discard block |
||
| 1544 | 1544 | * @return string Quoted value |
| 1545 | 1545 | */ |
| 1546 | 1546 | public function quoteType($type, $value) |
| 1547 | - { |
|
| 1548 | - if($type == 'date') { |
|
| 1549 | - return $this->convert($this->quoted($value), "date"); |
|
| 1550 | - } |
|
| 1551 | - if($type == 'time') { |
|
| 1552 | - return $this->convert($this->quoted($value), "time"); |
|
| 1553 | - } |
|
| 1547 | + { |
|
| 1548 | + if($type == 'date') { |
|
| 1549 | + return $this->convert($this->quoted($value), "date"); |
|
| 1550 | + } |
|
| 1551 | + if($type == 'time') { |
|
| 1552 | + return $this->convert($this->quoted($value), "time"); |
|
| 1553 | + } |
|
| 1554 | 1554 | if(isset($this->type_class[$type]) && $this->type_class[$type] == "date") { |
| 1555 | 1555 | return $this->convert($this->quoted($value), "datetime"); |
| 1556 | 1556 | } |
@@ -1559,7 +1559,7 @@ discard block |
||
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | return $this->quoted($value); |
| 1562 | - } |
|
| 1562 | + } |
|
| 1563 | 1563 | |
| 1564 | 1564 | /** |
| 1565 | 1565 | * Quote the strings of the passed in array |
@@ -1569,177 +1569,177 @@ discard block |
||
| 1569 | 1569 | * @param array $array |
| 1570 | 1570 | * @return array Quoted strings |
| 1571 | 1571 | */ |
| 1572 | - public function arrayQuote(array &$array) |
|
| 1573 | - { |
|
| 1574 | - foreach($array as &$val) { |
|
| 1575 | - $val = $this->quote($val); |
|
| 1576 | - } |
|
| 1577 | - return $array; |
|
| 1578 | - } |
|
| 1572 | + public function arrayQuote(array &$array) |
|
| 1573 | + { |
|
| 1574 | + foreach($array as &$val) { |
|
| 1575 | + $val = $this->quote($val); |
|
| 1576 | + } |
|
| 1577 | + return $array; |
|
| 1578 | + } |
|
| 1579 | 1579 | |
| 1580 | 1580 | /** |
| 1581 | 1581 | * Frees out previous results |
| 1582 | 1582 | * |
| 1583 | 1583 | * @param resource|bool $result optional, pass if you want to free a single result instead of all results |
| 1584 | 1584 | */ |
| 1585 | - protected function freeResult($result = false) |
|
| 1586 | - { |
|
| 1587 | - if($result) { |
|
| 1588 | - $this->freeDbResult($result); |
|
| 1589 | - } |
|
| 1590 | - if($this->lastResult) { |
|
| 1591 | - $this->freeDbResult($this->lastResult); |
|
| 1592 | - $this->lastResult = null; |
|
| 1593 | - } |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - /** |
|
| 1597 | - * @abstract |
|
| 1598 | - * Check if query has LIMIT clause |
|
| 1599 | - * Relevant for now only for Mysql |
|
| 1600 | - * @param string $sql |
|
| 1601 | - * @return bool |
|
| 1602 | - */ |
|
| 1603 | - protected function hasLimit($sql) |
|
| 1604 | - { |
|
| 1605 | - return false; |
|
| 1606 | - } |
|
| 1607 | - |
|
| 1608 | - /** |
|
| 1609 | - * Runs a query and returns a single row containing single value |
|
| 1610 | - * |
|
| 1611 | - * @param string $sql SQL Statement to execute |
|
| 1612 | - * @param bool $dieOnError True if we want to call die if the query returns errors |
|
| 1613 | - * @param string $msg Message to log if error occurs |
|
| 1614 | - * @return array single value from the query |
|
| 1615 | - */ |
|
| 1616 | - public function getOne($sql, $dieOnError = false, $msg = '') |
|
| 1617 | - { |
|
| 1618 | - $this->log->info("Get One: |$sql|"); |
|
| 1619 | - if(!$this->hasLimit($sql)) { |
|
| 1620 | - $queryresult = $this->limitQuery($sql, 0, 1, $dieOnError, $msg); |
|
| 1621 | - } else { |
|
| 1622 | - // support old code that passes LIMIT to sql |
|
| 1623 | - // works only for mysql, so do not rely on this |
|
| 1624 | - $queryresult = $this->query($sql, $dieOnError, $msg); |
|
| 1625 | - } |
|
| 1626 | - $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
|
| 1627 | - if (!$queryresult) return false; |
|
| 1628 | - $row = $this->fetchByAssoc($queryresult); |
|
| 1629 | - if(!empty($row)) { |
|
| 1630 | - return array_shift($row); |
|
| 1631 | - } |
|
| 1632 | - return false; |
|
| 1633 | - } |
|
| 1634 | - |
|
| 1635 | - /** |
|
| 1636 | - * Runs a query and returns a single row |
|
| 1637 | - * |
|
| 1638 | - * @param string $sql SQL Statement to execute |
|
| 1639 | - * @param bool $dieOnError True if we want to call die if the query returns errors |
|
| 1640 | - * @param string $msg Message to log if error occurs |
|
| 1641 | - * @param bool $suppress Message to log if error occurs |
|
| 1642 | - * @return array single row from the query |
|
| 1643 | - */ |
|
| 1644 | - public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
|
| 1645 | - { |
|
| 1646 | - $this->log->info("Fetch One: |$sql|"); |
|
| 1647 | - $this->checkConnection(); |
|
| 1648 | - $queryresult = $this->query($sql, $dieOnError, $msg); |
|
| 1649 | - $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
|
| 1650 | - |
|
| 1651 | - if (!$queryresult) return false; |
|
| 1652 | - |
|
| 1653 | - $row = $this->fetchByAssoc($queryresult); |
|
| 1654 | - if ( !$row ) return false; |
|
| 1655 | - |
|
| 1656 | - $this->freeResult($queryresult); |
|
| 1657 | - return $row; |
|
| 1658 | - } |
|
| 1585 | + protected function freeResult($result = false) |
|
| 1586 | + { |
|
| 1587 | + if($result) { |
|
| 1588 | + $this->freeDbResult($result); |
|
| 1589 | + } |
|
| 1590 | + if($this->lastResult) { |
|
| 1591 | + $this->freeDbResult($this->lastResult); |
|
| 1592 | + $this->lastResult = null; |
|
| 1593 | + } |
|
| 1594 | + } |
|
| 1659 | 1595 | |
| 1660 | 1596 | /** |
| 1661 | - * Returns the number of rows affected by the last query |
|
| 1662 | 1597 | * @abstract |
| 1663 | - * See also affected_rows capability, will return 0 unless the DB supports it |
|
| 1664 | - * @param resource $result query result resource |
|
| 1665 | - * @return int |
|
| 1598 | + * Check if query has LIMIT clause |
|
| 1599 | + * Relevant for now only for Mysql |
|
| 1600 | + * @param string $sql |
|
| 1601 | + * @return bool |
|
| 1666 | 1602 | */ |
| 1667 | - public function getAffectedRowCount($result) |
|
| 1668 | - { |
|
| 1669 | - return 0; |
|
| 1670 | - } |
|
| 1671 | - |
|
| 1672 | - /** |
|
| 1673 | - * Returns the number of rows returned by the result |
|
| 1674 | - * |
|
| 1675 | - * This function can't be reliably implemented on most DB, do not use it. |
|
| 1676 | - * @abstract |
|
| 1677 | - * @deprecated |
|
| 1678 | - * @param resource $result |
|
| 1679 | - * @return int |
|
| 1680 | - */ |
|
| 1681 | - public function getRowCount($result) |
|
| 1682 | - { |
|
| 1683 | - return 0; |
|
| 1684 | - } |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * Get table description |
|
| 1688 | - * @param string $tablename |
|
| 1603 | + protected function hasLimit($sql) |
|
| 1604 | + { |
|
| 1605 | + return false; |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + /** |
|
| 1609 | + * Runs a query and returns a single row containing single value |
|
| 1610 | + * |
|
| 1611 | + * @param string $sql SQL Statement to execute |
|
| 1612 | + * @param bool $dieOnError True if we want to call die if the query returns errors |
|
| 1613 | + * @param string $msg Message to log if error occurs |
|
| 1614 | + * @return array single value from the query |
|
| 1615 | + */ |
|
| 1616 | + public function getOne($sql, $dieOnError = false, $msg = '') |
|
| 1617 | + { |
|
| 1618 | + $this->log->info("Get One: |$sql|"); |
|
| 1619 | + if(!$this->hasLimit($sql)) { |
|
| 1620 | + $queryresult = $this->limitQuery($sql, 0, 1, $dieOnError, $msg); |
|
| 1621 | + } else { |
|
| 1622 | + // support old code that passes LIMIT to sql |
|
| 1623 | + // works only for mysql, so do not rely on this |
|
| 1624 | + $queryresult = $this->query($sql, $dieOnError, $msg); |
|
| 1625 | + } |
|
| 1626 | + $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
|
| 1627 | + if (!$queryresult) return false; |
|
| 1628 | + $row = $this->fetchByAssoc($queryresult); |
|
| 1629 | + if(!empty($row)) { |
|
| 1630 | + return array_shift($row); |
|
| 1631 | + } |
|
| 1632 | + return false; |
|
| 1633 | + } |
|
| 1634 | + |
|
| 1635 | + /** |
|
| 1636 | + * Runs a query and returns a single row |
|
| 1637 | + * |
|
| 1638 | + * @param string $sql SQL Statement to execute |
|
| 1639 | + * @param bool $dieOnError True if we want to call die if the query returns errors |
|
| 1640 | + * @param string $msg Message to log if error occurs |
|
| 1641 | + * @param bool $suppress Message to log if error occurs |
|
| 1642 | + * @return array single row from the query |
|
| 1643 | + */ |
|
| 1644 | + public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
|
| 1645 | + { |
|
| 1646 | + $this->log->info("Fetch One: |$sql|"); |
|
| 1647 | + $this->checkConnection(); |
|
| 1648 | + $queryresult = $this->query($sql, $dieOnError, $msg); |
|
| 1649 | + $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
|
| 1650 | + |
|
| 1651 | + if (!$queryresult) return false; |
|
| 1652 | + |
|
| 1653 | + $row = $this->fetchByAssoc($queryresult); |
|
| 1654 | + if ( !$row ) return false; |
|
| 1655 | + |
|
| 1656 | + $this->freeResult($queryresult); |
|
| 1657 | + return $row; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + /** |
|
| 1661 | + * Returns the number of rows affected by the last query |
|
| 1662 | + * @abstract |
|
| 1663 | + * See also affected_rows capability, will return 0 unless the DB supports it |
|
| 1664 | + * @param resource $result query result resource |
|
| 1665 | + * @return int |
|
| 1666 | + */ |
|
| 1667 | + public function getAffectedRowCount($result) |
|
| 1668 | + { |
|
| 1669 | + return 0; |
|
| 1670 | + } |
|
| 1671 | + |
|
| 1672 | + /** |
|
| 1673 | + * Returns the number of rows returned by the result |
|
| 1674 | + * |
|
| 1675 | + * This function can't be reliably implemented on most DB, do not use it. |
|
| 1676 | + * @abstract |
|
| 1677 | + * @deprecated |
|
| 1678 | + * @param resource $result |
|
| 1679 | + * @return int |
|
| 1680 | + */ |
|
| 1681 | + public function getRowCount($result) |
|
| 1682 | + { |
|
| 1683 | + return 0; |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * Get table description |
|
| 1688 | + * @param string $tablename |
|
| 1689 | 1689 | * @param bool $reload true means load from DB, false allows using cache |
| 1690 | 1690 | * @return array Vardef-format table description |
| 1691 | 1691 | * |
| 1692 | 1692 | */ |
| 1693 | - public function getTableDescription($tablename, $reload = false) |
|
| 1694 | - { |
|
| 1695 | - if($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1696 | - self::$table_descriptions[$tablename] = $this->get_columns($tablename); |
|
| 1697 | - } |
|
| 1698 | - return self::$table_descriptions[$tablename]; |
|
| 1699 | - } |
|
| 1700 | - |
|
| 1701 | - /** |
|
| 1702 | - * Returns the field description for a given field in table |
|
| 1703 | - * |
|
| 1704 | - * @param string $name |
|
| 1705 | - * @param string $tablename |
|
| 1706 | - * @return array |
|
| 1707 | - */ |
|
| 1708 | - protected function describeField($name, $tablename) |
|
| 1709 | - { |
|
| 1710 | - $table = $this->getTableDescription($tablename); |
|
| 1711 | - if(!empty($table) && isset($table[$name])) |
|
| 1712 | - return $table[$name]; |
|
| 1713 | - |
|
| 1714 | - $table = $this->getTableDescription($tablename, true); |
|
| 1715 | - |
|
| 1716 | - if(isset($table[$name])) |
|
| 1717 | - return $table[$name]; |
|
| 1718 | - |
|
| 1719 | - return array(); |
|
| 1720 | - } |
|
| 1721 | - |
|
| 1722 | - /** |
|
| 1723 | - * Returns the index description for a given index in table |
|
| 1724 | - * |
|
| 1725 | - * @param string $name |
|
| 1726 | - * @param string $tablename |
|
| 1727 | - * @return array |
|
| 1728 | - */ |
|
| 1729 | - protected function describeIndex($name, $tablename) |
|
| 1730 | - { |
|
| 1731 | - if(isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1732 | - return self::$index_descriptions[$tablename][$name]; |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - self::$index_descriptions[$tablename] = $this->get_indices($tablename); |
|
| 1736 | - |
|
| 1737 | - if(isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1738 | - return self::$index_descriptions[$tablename][$name]; |
|
| 1739 | - } |
|
| 1740 | - |
|
| 1741 | - return array(); |
|
| 1742 | - } |
|
| 1693 | + public function getTableDescription($tablename, $reload = false) |
|
| 1694 | + { |
|
| 1695 | + if($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1696 | + self::$table_descriptions[$tablename] = $this->get_columns($tablename); |
|
| 1697 | + } |
|
| 1698 | + return self::$table_descriptions[$tablename]; |
|
| 1699 | + } |
|
| 1700 | + |
|
| 1701 | + /** |
|
| 1702 | + * Returns the field description for a given field in table |
|
| 1703 | + * |
|
| 1704 | + * @param string $name |
|
| 1705 | + * @param string $tablename |
|
| 1706 | + * @return array |
|
| 1707 | + */ |
|
| 1708 | + protected function describeField($name, $tablename) |
|
| 1709 | + { |
|
| 1710 | + $table = $this->getTableDescription($tablename); |
|
| 1711 | + if(!empty($table) && isset($table[$name])) |
|
| 1712 | + return $table[$name]; |
|
| 1713 | + |
|
| 1714 | + $table = $this->getTableDescription($tablename, true); |
|
| 1715 | + |
|
| 1716 | + if(isset($table[$name])) |
|
| 1717 | + return $table[$name]; |
|
| 1718 | + |
|
| 1719 | + return array(); |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + /** |
|
| 1723 | + * Returns the index description for a given index in table |
|
| 1724 | + * |
|
| 1725 | + * @param string $name |
|
| 1726 | + * @param string $tablename |
|
| 1727 | + * @return array |
|
| 1728 | + */ |
|
| 1729 | + protected function describeIndex($name, $tablename) |
|
| 1730 | + { |
|
| 1731 | + if(isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1732 | + return self::$index_descriptions[$tablename][$name]; |
|
| 1733 | + } |
|
| 1734 | + |
|
| 1735 | + self::$index_descriptions[$tablename] = $this->get_indices($tablename); |
|
| 1736 | + |
|
| 1737 | + if(isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1738 | + return self::$index_descriptions[$tablename][$name]; |
|
| 1739 | + } |
|
| 1740 | + |
|
| 1741 | + return array(); |
|
| 1742 | + } |
|
| 1743 | 1743 | |
| 1744 | 1744 | /** |
| 1745 | 1745 | * Truncates a string to a given length |
@@ -1749,14 +1749,14 @@ discard block |
||
| 1749 | 1749 | * @return string |
| 1750 | 1750 | * |
| 1751 | 1751 | */ |
| 1752 | - public function truncate($string, $len) |
|
| 1753 | - { |
|
| 1754 | - if ( is_numeric($len) && $len > 0) |
|
| 1755 | - { |
|
| 1756 | - $string = mb_substr($string,0,(int) $len, "UTF-8"); |
|
| 1757 | - } |
|
| 1758 | - return $string; |
|
| 1759 | - } |
|
| 1752 | + public function truncate($string, $len) |
|
| 1753 | + { |
|
| 1754 | + if ( is_numeric($len) && $len > 0) |
|
| 1755 | + { |
|
| 1756 | + $string = mb_substr($string,0,(int) $len, "UTF-8"); |
|
| 1757 | + } |
|
| 1758 | + return $string; |
|
| 1759 | + } |
|
| 1760 | 1760 | |
| 1761 | 1761 | /** |
| 1762 | 1762 | * Returns the database string needed for concatinating multiple database strings together |
@@ -1766,121 +1766,121 @@ discard block |
||
| 1766 | 1766 | * @param string $space Separator between strings, default is single space |
| 1767 | 1767 | * @return string |
| 1768 | 1768 | */ |
| 1769 | - public function concat($table, array $fields, $space = ' ') |
|
| 1770 | - { |
|
| 1771 | - if(empty($fields)) return ''; |
|
| 1772 | - $elems = array(); |
|
| 1773 | - $space = $this->quoted($space); |
|
| 1774 | - foreach ( $fields as $field ) { |
|
| 1775 | - if(!empty($elems)) $elems[] = $space; |
|
| 1776 | - $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
|
| 1777 | - } |
|
| 1778 | - $first = array_shift($elems); |
|
| 1779 | - return "LTRIM(RTRIM(".$this->convert($first, 'CONCAT', $elems)."))"; |
|
| 1780 | - } |
|
| 1781 | - |
|
| 1782 | - /** |
|
| 1783 | - * Given a sql stmt attempt to parse it into the sql and the tokens. Then return the index of this prepared statement |
|
| 1784 | - * Tokens can come in the following forms: |
|
| 1785 | - * ? - a scalar which will be quoted |
|
| 1786 | - * ! - a literal which will not be quoted |
|
| 1787 | - * & - binary data to read from a file |
|
| 1788 | - * |
|
| 1789 | - * @param string $sql The sql to parse |
|
| 1790 | - * @return int index of the prepared statement to be used with execute |
|
| 1791 | - */ |
|
| 1792 | - public function prepareQuery($sql) |
|
| 1793 | - { |
|
| 1794 | - //parse out the tokens |
|
| 1795 | - $tokens = preg_split('/((?<!\\\)[&?!])/', $sql, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 1796 | - |
|
| 1797 | - //maintain a count of the actual tokens for quick reference in execute |
|
| 1798 | - $count = 0; |
|
| 1799 | - |
|
| 1800 | - $sqlStr = ''; |
|
| 1801 | - foreach ($tokens as $key => $val) { |
|
| 1802 | - switch ($val) { |
|
| 1803 | - case '?' : |
|
| 1804 | - case '!' : |
|
| 1805 | - case '&' : |
|
| 1806 | - $count++; |
|
| 1807 | - $sqlStr .= '?'; |
|
| 1808 | - break; |
|
| 1809 | - |
|
| 1810 | - default : |
|
| 1811 | - //escape any special characters |
|
| 1812 | - $tokens[$key] = preg_replace('/\\\([&?!])/', "\\1", $val); |
|
| 1813 | - $sqlStr .= $tokens[$key]; |
|
| 1814 | - break; |
|
| 1815 | - } // switch |
|
| 1816 | - } // foreach |
|
| 1817 | - |
|
| 1818 | - $this->preparedTokens[] = array('tokens' => $tokens, 'tokenCount' => $count, 'sqlString' => $sqlStr); |
|
| 1819 | - end($this->preparedTokens); |
|
| 1820 | - return key($this->preparedTokens); |
|
| 1821 | - } |
|
| 1822 | - |
|
| 1823 | - /** |
|
| 1824 | - * Takes a prepared stmt index and the data to replace and creates the query and runs it. |
|
| 1825 | - * |
|
| 1826 | - * @param int $stmt The index of the prepared statement from preparedTokens |
|
| 1827 | - * @param array $data The array of data to replace the tokens with. |
|
| 1828 | - * @return resource result set or false on error |
|
| 1829 | - */ |
|
| 1830 | - public function executePreparedQuery($stmt, $data = array()) |
|
| 1831 | - { |
|
| 1832 | - if(!empty($this->preparedTokens[$stmt])){ |
|
| 1833 | - if(!is_array($data)){ |
|
| 1834 | - $data = array($data); |
|
| 1835 | - } |
|
| 1836 | - |
|
| 1837 | - $pTokens = $this->preparedTokens[$stmt]; |
|
| 1838 | - |
|
| 1839 | - //ensure that the number of data elements matches the number of replacement tokens |
|
| 1840 | - //we found in prepare(). |
|
| 1841 | - if(count($data) != $pTokens['tokenCount']){ |
|
| 1842 | - //error the data count did not match the token count |
|
| 1843 | - return false; |
|
| 1844 | - } |
|
| 1845 | - |
|
| 1846 | - $query = ''; |
|
| 1847 | - $dataIndex = 0; |
|
| 1848 | - $tokens = $pTokens['tokens']; |
|
| 1849 | - foreach ($tokens as $val) { |
|
| 1850 | - switch ($val) { |
|
| 1851 | - case '?': |
|
| 1852 | - $query .= $this->quote($data[$dataIndex++]); |
|
| 1853 | - break; |
|
| 1854 | - case '&': |
|
| 1855 | - $filename = $data[$dataIndex++]; |
|
| 1856 | - $query .= file_get_contents($filename); |
|
| 1857 | - break; |
|
| 1858 | - case '!': |
|
| 1859 | - $query .= $data[$dataIndex++]; |
|
| 1860 | - break; |
|
| 1861 | - default: |
|
| 1862 | - $query .= $val; |
|
| 1863 | - break; |
|
| 1864 | - }//switch |
|
| 1865 | - }//foreach |
|
| 1866 | - return $this->query($query); |
|
| 1867 | - }else{ |
|
| 1868 | - return false; |
|
| 1869 | - } |
|
| 1870 | - } |
|
| 1871 | - |
|
| 1872 | - /** |
|
| 1873 | - * Run both prepare and execute without the client having to run both individually. |
|
| 1874 | - * |
|
| 1875 | - * @param string $sql The sql to parse |
|
| 1876 | - * @param array $data The array of data to replace the tokens with. |
|
| 1877 | - * @return resource result set or false on error |
|
| 1878 | - */ |
|
| 1879 | - public function pQuery($sql, $data = array()) |
|
| 1880 | - { |
|
| 1881 | - $stmt = $this->prepareQuery($sql); |
|
| 1882 | - return $this->executePreparedQuery($stmt, $data); |
|
| 1883 | - } |
|
| 1769 | + public function concat($table, array $fields, $space = ' ') |
|
| 1770 | + { |
|
| 1771 | + if(empty($fields)) return ''; |
|
| 1772 | + $elems = array(); |
|
| 1773 | + $space = $this->quoted($space); |
|
| 1774 | + foreach ( $fields as $field ) { |
|
| 1775 | + if(!empty($elems)) $elems[] = $space; |
|
| 1776 | + $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
|
| 1777 | + } |
|
| 1778 | + $first = array_shift($elems); |
|
| 1779 | + return "LTRIM(RTRIM(".$this->convert($first, 'CONCAT', $elems)."))"; |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * Given a sql stmt attempt to parse it into the sql and the tokens. Then return the index of this prepared statement |
|
| 1784 | + * Tokens can come in the following forms: |
|
| 1785 | + * ? - a scalar which will be quoted |
|
| 1786 | + * ! - a literal which will not be quoted |
|
| 1787 | + * & - binary data to read from a file |
|
| 1788 | + * |
|
| 1789 | + * @param string $sql The sql to parse |
|
| 1790 | + * @return int index of the prepared statement to be used with execute |
|
| 1791 | + */ |
|
| 1792 | + public function prepareQuery($sql) |
|
| 1793 | + { |
|
| 1794 | + //parse out the tokens |
|
| 1795 | + $tokens = preg_split('/((?<!\\\)[&?!])/', $sql, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 1796 | + |
|
| 1797 | + //maintain a count of the actual tokens for quick reference in execute |
|
| 1798 | + $count = 0; |
|
| 1799 | + |
|
| 1800 | + $sqlStr = ''; |
|
| 1801 | + foreach ($tokens as $key => $val) { |
|
| 1802 | + switch ($val) { |
|
| 1803 | + case '?' : |
|
| 1804 | + case '!' : |
|
| 1805 | + case '&' : |
|
| 1806 | + $count++; |
|
| 1807 | + $sqlStr .= '?'; |
|
| 1808 | + break; |
|
| 1809 | + |
|
| 1810 | + default : |
|
| 1811 | + //escape any special characters |
|
| 1812 | + $tokens[$key] = preg_replace('/\\\([&?!])/', "\\1", $val); |
|
| 1813 | + $sqlStr .= $tokens[$key]; |
|
| 1814 | + break; |
|
| 1815 | + } // switch |
|
| 1816 | + } // foreach |
|
| 1817 | + |
|
| 1818 | + $this->preparedTokens[] = array('tokens' => $tokens, 'tokenCount' => $count, 'sqlString' => $sqlStr); |
|
| 1819 | + end($this->preparedTokens); |
|
| 1820 | + return key($this->preparedTokens); |
|
| 1821 | + } |
|
| 1822 | + |
|
| 1823 | + /** |
|
| 1824 | + * Takes a prepared stmt index and the data to replace and creates the query and runs it. |
|
| 1825 | + * |
|
| 1826 | + * @param int $stmt The index of the prepared statement from preparedTokens |
|
| 1827 | + * @param array $data The array of data to replace the tokens with. |
|
| 1828 | + * @return resource result set or false on error |
|
| 1829 | + */ |
|
| 1830 | + public function executePreparedQuery($stmt, $data = array()) |
|
| 1831 | + { |
|
| 1832 | + if(!empty($this->preparedTokens[$stmt])){ |
|
| 1833 | + if(!is_array($data)){ |
|
| 1834 | + $data = array($data); |
|
| 1835 | + } |
|
| 1836 | + |
|
| 1837 | + $pTokens = $this->preparedTokens[$stmt]; |
|
| 1838 | + |
|
| 1839 | + //ensure that the number of data elements matches the number of replacement tokens |
|
| 1840 | + //we found in prepare(). |
|
| 1841 | + if(count($data) != $pTokens['tokenCount']){ |
|
| 1842 | + //error the data count did not match the token count |
|
| 1843 | + return false; |
|
| 1844 | + } |
|
| 1845 | + |
|
| 1846 | + $query = ''; |
|
| 1847 | + $dataIndex = 0; |
|
| 1848 | + $tokens = $pTokens['tokens']; |
|
| 1849 | + foreach ($tokens as $val) { |
|
| 1850 | + switch ($val) { |
|
| 1851 | + case '?': |
|
| 1852 | + $query .= $this->quote($data[$dataIndex++]); |
|
| 1853 | + break; |
|
| 1854 | + case '&': |
|
| 1855 | + $filename = $data[$dataIndex++]; |
|
| 1856 | + $query .= file_get_contents($filename); |
|
| 1857 | + break; |
|
| 1858 | + case '!': |
|
| 1859 | + $query .= $data[$dataIndex++]; |
|
| 1860 | + break; |
|
| 1861 | + default: |
|
| 1862 | + $query .= $val; |
|
| 1863 | + break; |
|
| 1864 | + }//switch |
|
| 1865 | + }//foreach |
|
| 1866 | + return $this->query($query); |
|
| 1867 | + }else{ |
|
| 1868 | + return false; |
|
| 1869 | + } |
|
| 1870 | + } |
|
| 1871 | + |
|
| 1872 | + /** |
|
| 1873 | + * Run both prepare and execute without the client having to run both individually. |
|
| 1874 | + * |
|
| 1875 | + * @param string $sql The sql to parse |
|
| 1876 | + * @param array $data The array of data to replace the tokens with. |
|
| 1877 | + * @return resource result set or false on error |
|
| 1878 | + */ |
|
| 1879 | + public function pQuery($sql, $data = array()) |
|
| 1880 | + { |
|
| 1881 | + $stmt = $this->prepareQuery($sql); |
|
| 1882 | + return $this->executePreparedQuery($stmt, $data); |
|
| 1883 | + } |
|
| 1884 | 1884 | |
| 1885 | 1885 | /********************** SQL FUNCTIONS ****************************/ |
| 1886 | 1886 | /** |
@@ -1890,933 +1890,933 @@ discard block |
||
| 1890 | 1890 | * @param SugarBean $bean SugarBean instance |
| 1891 | 1891 | * @return string SQL Create Table statement |
| 1892 | 1892 | */ |
| 1893 | - public function createTableSQL(SugarBean $bean) |
|
| 1894 | - { |
|
| 1895 | - $tablename = $bean->getTableName(); |
|
| 1896 | - $fieldDefs = $bean->getFieldDefinitions(); |
|
| 1897 | - $indices = $bean->getIndices(); |
|
| 1898 | - return $this->createTableSQLParams($tablename, $fieldDefs, $indices); |
|
| 1899 | - } |
|
| 1900 | - |
|
| 1901 | - /** |
|
| 1902 | - * Generates SQL for insert statement. |
|
| 1903 | - * |
|
| 1904 | - * @param SugarBean $bean SugarBean instance |
|
| 1905 | - * @return string SQL Create Table statement |
|
| 1906 | - */ |
|
| 1907 | - public function insertSQL(SugarBean $bean) |
|
| 1908 | - { |
|
| 1909 | - // get column names and values |
|
| 1910 | - $sql = $this->insertParams($bean->getTableName(), $bean->getFieldDefinitions(), get_object_vars($bean), |
|
| 1911 | - isset($bean->field_name_map)?$bean->field_name_map:null, false); |
|
| 1912 | - return $sql; |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - /** |
|
| 1916 | - * Generates SQL for update statement. |
|
| 1917 | - * |
|
| 1918 | - * @param SugarBean $bean SugarBean instance |
|
| 1919 | - * @param array $where Optional, where conditions in an array |
|
| 1920 | - * @return string SQL Create Table statement |
|
| 1921 | - */ |
|
| 1922 | - public function updateSQL(SugarBean $bean, array $where = array()) |
|
| 1923 | - { |
|
| 1924 | - $primaryField = $bean->getPrimaryFieldDefinition(); |
|
| 1925 | - $columns = array(); |
|
| 1893 | + public function createTableSQL(SugarBean $bean) |
|
| 1894 | + { |
|
| 1895 | + $tablename = $bean->getTableName(); |
|
| 1896 | + $fieldDefs = $bean->getFieldDefinitions(); |
|
| 1897 | + $indices = $bean->getIndices(); |
|
| 1898 | + return $this->createTableSQLParams($tablename, $fieldDefs, $indices); |
|
| 1899 | + } |
|
| 1900 | + |
|
| 1901 | + /** |
|
| 1902 | + * Generates SQL for insert statement. |
|
| 1903 | + * |
|
| 1904 | + * @param SugarBean $bean SugarBean instance |
|
| 1905 | + * @return string SQL Create Table statement |
|
| 1906 | + */ |
|
| 1907 | + public function insertSQL(SugarBean $bean) |
|
| 1908 | + { |
|
| 1909 | + // get column names and values |
|
| 1910 | + $sql = $this->insertParams($bean->getTableName(), $bean->getFieldDefinitions(), get_object_vars($bean), |
|
| 1911 | + isset($bean->field_name_map)?$bean->field_name_map:null, false); |
|
| 1912 | + return $sql; |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + /** |
|
| 1916 | + * Generates SQL for update statement. |
|
| 1917 | + * |
|
| 1918 | + * @param SugarBean $bean SugarBean instance |
|
| 1919 | + * @param array $where Optional, where conditions in an array |
|
| 1920 | + * @return string SQL Create Table statement |
|
| 1921 | + */ |
|
| 1922 | + public function updateSQL(SugarBean $bean, array $where = array()) |
|
| 1923 | + { |
|
| 1924 | + $primaryField = $bean->getPrimaryFieldDefinition(); |
|
| 1925 | + $columns = array(); |
|
| 1926 | 1926 | $fields = $bean->getFieldDefinitions(); |
| 1927 | - // get column names and values |
|
| 1928 | - foreach ($fields as $field => $fieldDef) { |
|
| 1929 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 1930 | - // Do not write out the id field on the update statement. |
|
| 1931 | - // We are not allowed to change ids. |
|
| 1932 | - if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) continue; |
|
| 1933 | - |
|
| 1934 | - // If the field is an auto_increment field, then we shouldn't be setting it. This was added |
|
| 1935 | - // specially for Bugs and Cases which have a number associated with them. |
|
| 1936 | - if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
|
| 1937 | - |
|
| 1938 | - //custom fields handle their save separately |
|
| 1939 | - if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1940 | - |
|
| 1941 | - // no need to clear deleted since we only update not deleted records anyway |
|
| 1942 | - if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1943 | - |
|
| 1944 | - if(isset($bean->$field)) { |
|
| 1945 | - $val = from_html($bean->$field); |
|
| 1946 | - } else { |
|
| 1947 | - continue; |
|
| 1948 | - } |
|
| 1949 | - |
|
| 1950 | - if(!empty($fieldDef['type']) && $fieldDef['type'] == 'bool'){ |
|
| 1951 | - $val = $bean->getFieldValue($field); |
|
| 1952 | - } |
|
| 1953 | - |
|
| 1954 | - if(strlen($val) == 0) { |
|
| 1955 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1956 | - $val = $fieldDef['default']; |
|
| 1957 | - } else { |
|
| 1958 | - $val = null; |
|
| 1959 | - } |
|
| 1960 | - } |
|
| 1961 | - |
|
| 1962 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1963 | - $val = $this->truncate($val, $fieldDef['len']); |
|
| 1964 | - } |
|
| 1965 | - $columnName = $this->quoteIdentifier($fieldDef['name']); |
|
| 1966 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1967 | - $columns[] = "{$columnName}=".$this->massageValue($val, $fieldDef); |
|
| 1968 | - } elseif($this->isNullable($fieldDef)) { |
|
| 1969 | - $columns[] = "{$columnName}=NULL"; |
|
| 1970 | - } else { |
|
| 1971 | - $columns[] = "{$columnName}=".$this->emptyValue($fieldDef['type']); |
|
| 1972 | - } |
|
| 1973 | - } |
|
| 1974 | - |
|
| 1975 | - if ( sizeof($columns) == 0 ) |
|
| 1976 | - return ""; // no columns set |
|
| 1977 | - |
|
| 1978 | - // build where clause |
|
| 1979 | - $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 1980 | - if(isset($fields['deleted'])) { |
|
| 1981 | - $where .= " AND deleted=0"; |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - return "UPDATE ".$bean->getTableName()." |
|
| 1927 | + // get column names and values |
|
| 1928 | + foreach ($fields as $field => $fieldDef) { |
|
| 1929 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 1930 | + // Do not write out the id field on the update statement. |
|
| 1931 | + // We are not allowed to change ids. |
|
| 1932 | + if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) continue; |
|
| 1933 | + |
|
| 1934 | + // If the field is an auto_increment field, then we shouldn't be setting it. This was added |
|
| 1935 | + // specially for Bugs and Cases which have a number associated with them. |
|
| 1936 | + if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
|
| 1937 | + |
|
| 1938 | + //custom fields handle their save separately |
|
| 1939 | + if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1940 | + |
|
| 1941 | + // no need to clear deleted since we only update not deleted records anyway |
|
| 1942 | + if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1943 | + |
|
| 1944 | + if(isset($bean->$field)) { |
|
| 1945 | + $val = from_html($bean->$field); |
|
| 1946 | + } else { |
|
| 1947 | + continue; |
|
| 1948 | + } |
|
| 1949 | + |
|
| 1950 | + if(!empty($fieldDef['type']) && $fieldDef['type'] == 'bool'){ |
|
| 1951 | + $val = $bean->getFieldValue($field); |
|
| 1952 | + } |
|
| 1953 | + |
|
| 1954 | + if(strlen($val) == 0) { |
|
| 1955 | + if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1956 | + $val = $fieldDef['default']; |
|
| 1957 | + } else { |
|
| 1958 | + $val = null; |
|
| 1959 | + } |
|
| 1960 | + } |
|
| 1961 | + |
|
| 1962 | + if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1963 | + $val = $this->truncate($val, $fieldDef['len']); |
|
| 1964 | + } |
|
| 1965 | + $columnName = $this->quoteIdentifier($fieldDef['name']); |
|
| 1966 | + if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1967 | + $columns[] = "{$columnName}=".$this->massageValue($val, $fieldDef); |
|
| 1968 | + } elseif($this->isNullable($fieldDef)) { |
|
| 1969 | + $columns[] = "{$columnName}=NULL"; |
|
| 1970 | + } else { |
|
| 1971 | + $columns[] = "{$columnName}=".$this->emptyValue($fieldDef['type']); |
|
| 1972 | + } |
|
| 1973 | + } |
|
| 1974 | + |
|
| 1975 | + if ( sizeof($columns) == 0 ) |
|
| 1976 | + return ""; // no columns set |
|
| 1977 | + |
|
| 1978 | + // build where clause |
|
| 1979 | + $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 1980 | + if(isset($fields['deleted'])) { |
|
| 1981 | + $where .= " AND deleted=0"; |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + return "UPDATE ".$bean->getTableName()." |
|
| 1985 | 1985 | SET ".implode(",", $columns)." |
| 1986 | 1986 | $where"; |
| 1987 | - } |
|
| 1988 | - |
|
| 1989 | - /** |
|
| 1990 | - * This method returns a where array so that it has id entry if |
|
| 1991 | - * where is not an array or is empty |
|
| 1992 | - * |
|
| 1993 | - * @param SugarBean $bean SugarBean instance |
|
| 1994 | - * @param array $where Optional, where conditions in an array |
|
| 1995 | - * @return array |
|
| 1996 | - */ |
|
| 1997 | - protected function updateWhereArray(SugarBean $bean, array $where = array()) |
|
| 1998 | - { |
|
| 1999 | - if (count($where) == 0) { |
|
| 2000 | - $fieldDef = $bean->getPrimaryFieldDefinition(); |
|
| 2001 | - $primaryColumn = $fieldDef['name']; |
|
| 2002 | - |
|
| 2003 | - $val = $bean->getFieldValue($fieldDef['name']); |
|
| 2004 | - if ($val != FALSE){ |
|
| 2005 | - $where[$primaryColumn] = $val; |
|
| 2006 | - } |
|
| 2007 | - } |
|
| 2008 | - |
|
| 2009 | - return $where; |
|
| 2010 | - } |
|
| 2011 | - |
|
| 2012 | - /** |
|
| 2013 | - * Returns a where clause without the 'where' key word |
|
| 2014 | - * |
|
| 2015 | - * The clause returned does not have an 'and' at the beginning and the columns |
|
| 2016 | - * are joined by 'and'. |
|
| 2017 | - * |
|
| 2018 | - * @param string $table table name |
|
| 2019 | - * @param array $whereArray Optional, where conditions in an array |
|
| 2020 | - * @return string |
|
| 2021 | - */ |
|
| 2022 | - protected function getColumnWhereClause($table, array $whereArray = array()) |
|
| 2023 | - { |
|
| 2024 | - $where = array(); |
|
| 2025 | - foreach ($whereArray as $name => $val) { |
|
| 2026 | - $op = "="; |
|
| 2027 | - if (is_array($val)) { |
|
| 2028 | - $op = "IN"; |
|
| 2029 | - $temp = array(); |
|
| 2030 | - foreach ($val as $tval){ |
|
| 2031 | - $temp[] = $this->quoted($tval); |
|
| 2032 | - } |
|
| 2033 | - $val = implode(",", $temp); |
|
| 2034 | - $val = "($val)"; |
|
| 2035 | - } else { |
|
| 2036 | - $val = $this->quoted($val); |
|
| 2037 | - } |
|
| 2038 | - |
|
| 2039 | - $where[] = " $table.$name $op $val"; |
|
| 2040 | - } |
|
| 2041 | - |
|
| 2042 | - if (!empty($where)) |
|
| 2043 | - return implode(" AND ", $where); |
|
| 2044 | - |
|
| 2045 | - return ''; |
|
| 2046 | - } |
|
| 2047 | - |
|
| 2048 | - /** |
|
| 2049 | - * This method returns a complete where clause built from the |
|
| 2050 | - * where values specified. |
|
| 2051 | - * |
|
| 2052 | - * @param SugarBean $bean SugarBean that describes the table |
|
| 2053 | - * @param array $whereArray Optional, where conditions in an array |
|
| 2054 | - * @return string |
|
| 2055 | - */ |
|
| 2056 | - protected function getWhereClause(SugarBean $bean, array $whereArray=array()) |
|
| 2057 | - { |
|
| 2058 | - return " WHERE " . $this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2059 | - } |
|
| 2060 | - |
|
| 2061 | - /** |
|
| 2062 | - * Outputs a correct string for the sql statement according to value |
|
| 2063 | - * |
|
| 2064 | - * @param mixed $val |
|
| 2065 | - * @param array $fieldDef field definition |
|
| 2066 | - * @return mixed |
|
| 2067 | - */ |
|
| 2068 | - public function massageValue($val, $fieldDef) |
|
| 2069 | - { |
|
| 2070 | - $type = $this->getFieldType($fieldDef); |
|
| 2071 | - |
|
| 2072 | - if(isset($this->type_class[$type])) { |
|
| 2073 | - // handle some known types |
|
| 2074 | - switch($this->type_class[$type]) { |
|
| 2075 | - case 'bool': |
|
| 2076 | - case 'int': |
|
| 2077 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2078 | - if (isset($fieldDef['default'])){ |
|
| 2079 | - return $fieldDef['default']; |
|
| 2080 | - } |
|
| 2081 | - return 0; |
|
| 2082 | - } |
|
| 2083 | - return intval($val); |
|
| 1987 | + } |
|
| 1988 | + |
|
| 1989 | + /** |
|
| 1990 | + * This method returns a where array so that it has id entry if |
|
| 1991 | + * where is not an array or is empty |
|
| 1992 | + * |
|
| 1993 | + * @param SugarBean $bean SugarBean instance |
|
| 1994 | + * @param array $where Optional, where conditions in an array |
|
| 1995 | + * @return array |
|
| 1996 | + */ |
|
| 1997 | + protected function updateWhereArray(SugarBean $bean, array $where = array()) |
|
| 1998 | + { |
|
| 1999 | + if (count($where) == 0) { |
|
| 2000 | + $fieldDef = $bean->getPrimaryFieldDefinition(); |
|
| 2001 | + $primaryColumn = $fieldDef['name']; |
|
| 2002 | + |
|
| 2003 | + $val = $bean->getFieldValue($fieldDef['name']); |
|
| 2004 | + if ($val != FALSE){ |
|
| 2005 | + $where[$primaryColumn] = $val; |
|
| 2006 | + } |
|
| 2007 | + } |
|
| 2008 | + |
|
| 2009 | + return $where; |
|
| 2010 | + } |
|
| 2011 | + |
|
| 2012 | + /** |
|
| 2013 | + * Returns a where clause without the 'where' key word |
|
| 2014 | + * |
|
| 2015 | + * The clause returned does not have an 'and' at the beginning and the columns |
|
| 2016 | + * are joined by 'and'. |
|
| 2017 | + * |
|
| 2018 | + * @param string $table table name |
|
| 2019 | + * @param array $whereArray Optional, where conditions in an array |
|
| 2020 | + * @return string |
|
| 2021 | + */ |
|
| 2022 | + protected function getColumnWhereClause($table, array $whereArray = array()) |
|
| 2023 | + { |
|
| 2024 | + $where = array(); |
|
| 2025 | + foreach ($whereArray as $name => $val) { |
|
| 2026 | + $op = "="; |
|
| 2027 | + if (is_array($val)) { |
|
| 2028 | + $op = "IN"; |
|
| 2029 | + $temp = array(); |
|
| 2030 | + foreach ($val as $tval){ |
|
| 2031 | + $temp[] = $this->quoted($tval); |
|
| 2032 | + } |
|
| 2033 | + $val = implode(",", $temp); |
|
| 2034 | + $val = "($val)"; |
|
| 2035 | + } else { |
|
| 2036 | + $val = $this->quoted($val); |
|
| 2037 | + } |
|
| 2038 | + |
|
| 2039 | + $where[] = " $table.$name $op $val"; |
|
| 2040 | + } |
|
| 2041 | + |
|
| 2042 | + if (!empty($where)) |
|
| 2043 | + return implode(" AND ", $where); |
|
| 2044 | + |
|
| 2045 | + return ''; |
|
| 2046 | + } |
|
| 2047 | + |
|
| 2048 | + /** |
|
| 2049 | + * This method returns a complete where clause built from the |
|
| 2050 | + * where values specified. |
|
| 2051 | + * |
|
| 2052 | + * @param SugarBean $bean SugarBean that describes the table |
|
| 2053 | + * @param array $whereArray Optional, where conditions in an array |
|
| 2054 | + * @return string |
|
| 2055 | + */ |
|
| 2056 | + protected function getWhereClause(SugarBean $bean, array $whereArray=array()) |
|
| 2057 | + { |
|
| 2058 | + return " WHERE " . $this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2059 | + } |
|
| 2060 | + |
|
| 2061 | + /** |
|
| 2062 | + * Outputs a correct string for the sql statement according to value |
|
| 2063 | + * |
|
| 2064 | + * @param mixed $val |
|
| 2065 | + * @param array $fieldDef field definition |
|
| 2066 | + * @return mixed |
|
| 2067 | + */ |
|
| 2068 | + public function massageValue($val, $fieldDef) |
|
| 2069 | + { |
|
| 2070 | + $type = $this->getFieldType($fieldDef); |
|
| 2071 | + |
|
| 2072 | + if(isset($this->type_class[$type])) { |
|
| 2073 | + // handle some known types |
|
| 2074 | + switch($this->type_class[$type]) { |
|
| 2075 | + case 'bool': |
|
| 2076 | + case 'int': |
|
| 2077 | + if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2078 | + if (isset($fieldDef['default'])){ |
|
| 2079 | + return $fieldDef['default']; |
|
| 2080 | + } |
|
| 2081 | + return 0; |
|
| 2082 | + } |
|
| 2083 | + return intval($val); |
|
| 2084 | 2084 | case 'bigint' : |
| 2085 | 2085 | $val = (float)$val; |
| 2086 | - if (!empty($fieldDef['required']) && $val == false){ |
|
| 2087 | - if (isset($fieldDef['default'])){ |
|
| 2088 | - return $fieldDef['default']; |
|
| 2089 | - } |
|
| 2090 | - return 0; |
|
| 2091 | - } |
|
| 2086 | + if (!empty($fieldDef['required']) && $val == false){ |
|
| 2087 | + if (isset($fieldDef['default'])){ |
|
| 2088 | + return $fieldDef['default']; |
|
| 2089 | + } |
|
| 2090 | + return 0; |
|
| 2091 | + } |
|
| 2092 | 2092 | return $val; |
| 2093 | - case 'float': |
|
| 2094 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2095 | - if (isset($fieldDef['default'])){ |
|
| 2096 | - return $fieldDef['default']; |
|
| 2097 | - } |
|
| 2098 | - return 0; |
|
| 2099 | - } |
|
| 2100 | - return floatval($val); |
|
| 2101 | - case 'time': |
|
| 2102 | - case 'date': |
|
| 2103 | - // empty date can't be '', so convert it to either NULL or empty date value |
|
| 2104 | - if($val == '') { |
|
| 2105 | - if (!empty($fieldDef['required'])) { |
|
| 2106 | - if (isset($fieldDef['default'])) { |
|
| 2107 | - return $fieldDef['default']; |
|
| 2108 | - } |
|
| 2109 | - return $this->emptyValue($type); |
|
| 2110 | - } |
|
| 2111 | - return "NULL"; |
|
| 2112 | - } |
|
| 2113 | - break; |
|
| 2114 | - } |
|
| 2115 | - } else { |
|
| 2116 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2117 | - $val = $this->truncate($val, $fieldDef['len']); |
|
| 2118 | - } |
|
| 2119 | - } |
|
| 2120 | - |
|
| 2121 | - if ( is_null($val) ) { |
|
| 2122 | - if(!empty($fieldDef['required'])) { |
|
| 2123 | - if (isset($fieldDef['default']) && $fieldDef['default'] != ''){ |
|
| 2124 | - return $fieldDef['default']; |
|
| 2125 | - } |
|
| 2126 | - return $this->emptyValue($type); |
|
| 2127 | - } else { |
|
| 2128 | - return "NULL"; |
|
| 2129 | - } |
|
| 2130 | - } |
|
| 2093 | + case 'float': |
|
| 2094 | + if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2095 | + if (isset($fieldDef['default'])){ |
|
| 2096 | + return $fieldDef['default']; |
|
| 2097 | + } |
|
| 2098 | + return 0; |
|
| 2099 | + } |
|
| 2100 | + return floatval($val); |
|
| 2101 | + case 'time': |
|
| 2102 | + case 'date': |
|
| 2103 | + // empty date can't be '', so convert it to either NULL or empty date value |
|
| 2104 | + if($val == '') { |
|
| 2105 | + if (!empty($fieldDef['required'])) { |
|
| 2106 | + if (isset($fieldDef['default'])) { |
|
| 2107 | + return $fieldDef['default']; |
|
| 2108 | + } |
|
| 2109 | + return $this->emptyValue($type); |
|
| 2110 | + } |
|
| 2111 | + return "NULL"; |
|
| 2112 | + } |
|
| 2113 | + break; |
|
| 2114 | + } |
|
| 2115 | + } else { |
|
| 2116 | + if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2117 | + $val = $this->truncate($val, $fieldDef['len']); |
|
| 2118 | + } |
|
| 2119 | + } |
|
| 2120 | + |
|
| 2121 | + if ( is_null($val) ) { |
|
| 2122 | + if(!empty($fieldDef['required'])) { |
|
| 2123 | + if (isset($fieldDef['default']) && $fieldDef['default'] != ''){ |
|
| 2124 | + return $fieldDef['default']; |
|
| 2125 | + } |
|
| 2126 | + return $this->emptyValue($type); |
|
| 2127 | + } else { |
|
| 2128 | + return "NULL"; |
|
| 2129 | + } |
|
| 2130 | + } |
|
| 2131 | 2131 | if($type == "datetimecombo") { |
| 2132 | 2132 | $type = "datetime"; |
| 2133 | 2133 | } |
| 2134 | - return $this->convert($this->quoted($val), $type); |
|
| 2135 | - } |
|
| 2136 | - |
|
| 2137 | - /** |
|
| 2138 | - * Massages the field defintions to fill in anything else the DB backend may add |
|
| 2139 | - * |
|
| 2140 | - * @param array $fieldDef |
|
| 2141 | - * @param string $tablename |
|
| 2142 | - * @return array |
|
| 2143 | - */ |
|
| 2144 | - public function massageFieldDef(&$fieldDef, $tablename) |
|
| 2145 | - { |
|
| 2146 | - if ( !isset($fieldDef['dbType']) ) { |
|
| 2147 | - if ( isset($fieldDef['dbtype']) ) |
|
| 2148 | - $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2149 | - else |
|
| 2150 | - $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2151 | - } |
|
| 2152 | - $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
|
| 2153 | - $matches = array(); |
|
| 2134 | + return $this->convert($this->quoted($val), $type); |
|
| 2135 | + } |
|
| 2136 | + |
|
| 2137 | + /** |
|
| 2138 | + * Massages the field defintions to fill in anything else the DB backend may add |
|
| 2139 | + * |
|
| 2140 | + * @param array $fieldDef |
|
| 2141 | + * @param string $tablename |
|
| 2142 | + * @return array |
|
| 2143 | + */ |
|
| 2144 | + public function massageFieldDef(&$fieldDef, $tablename) |
|
| 2145 | + { |
|
| 2146 | + if ( !isset($fieldDef['dbType']) ) { |
|
| 2147 | + if ( isset($fieldDef['dbtype']) ) |
|
| 2148 | + $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2149 | + else |
|
| 2150 | + $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2151 | + } |
|
| 2152 | + $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
|
| 2153 | + $matches = array(); |
|
| 2154 | 2154 | // len can be a number or a string like 'max', for example, nvarchar(max) |
| 2155 | 2155 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches); |
| 2156 | - if ( isset($matches[1][0]) ) |
|
| 2157 | - $fieldDef['type'] = $matches[1][0]; |
|
| 2158 | - if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2159 | - $fieldDef['len'] = $matches[2][0]; |
|
| 2160 | - if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2161 | - $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2162 | - if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
|
| 2163 | - $fieldDef['required'] = 'true'; |
|
| 2164 | - } |
|
| 2165 | - } |
|
| 2166 | - |
|
| 2167 | - /** |
|
| 2168 | - * Take an SQL statement and produce a list of fields used in that select |
|
| 2169 | - * @param string $selectStatement |
|
| 2170 | - * @return array |
|
| 2171 | - */ |
|
| 2172 | - public function getSelectFieldsFromQuery($selectStatement) |
|
| 2173 | - { |
|
| 2174 | - $selectStatement = trim($selectStatement); |
|
| 2175 | - if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") |
|
| 2176 | - $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2177 | - |
|
| 2178 | - //Due to sql functions existing in many selects, we can't use php explode |
|
| 2179 | - $fields = array(); |
|
| 2180 | - $level = 0; |
|
| 2181 | - $selectField = ""; |
|
| 2182 | - $strLen = strlen($selectStatement); |
|
| 2183 | - for($i = 0; $i < $strLen; $i++) |
|
| 2184 | - { |
|
| 2185 | - $char = $selectStatement[$i]; |
|
| 2186 | - |
|
| 2187 | - if ($char == "," && $level == 0) |
|
| 2188 | - { |
|
| 2189 | - $field = $this->getFieldNameFromSelect(trim($selectField)); |
|
| 2190 | - $fields[$field] = $selectField; |
|
| 2191 | - $selectField = ""; |
|
| 2192 | - } |
|
| 2193 | - else if ($char == "("){ |
|
| 2194 | - $level++; |
|
| 2195 | - $selectField .= $char; |
|
| 2196 | - } |
|
| 2197 | - else if($char == ")"){ |
|
| 2198 | - $level--; |
|
| 2199 | - $selectField .= $char; |
|
| 2200 | - |
|
| 2201 | - |
|
| 2202 | - }else{ |
|
| 2203 | - $selectField .= $char; |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - } |
|
| 2207 | - $fields[$this->getFieldNameFromSelect($selectField)] = $selectField; |
|
| 2208 | - return $fields; |
|
| 2209 | - } |
|
| 2210 | - |
|
| 2211 | - /** |
|
| 2212 | - * returns the field name used in a select |
|
| 2213 | - * @param string $string SELECT query |
|
| 2156 | + if ( isset($matches[1][0]) ) |
|
| 2157 | + $fieldDef['type'] = $matches[1][0]; |
|
| 2158 | + if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2159 | + $fieldDef['len'] = $matches[2][0]; |
|
| 2160 | + if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2161 | + $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2162 | + if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
|
| 2163 | + $fieldDef['required'] = 'true'; |
|
| 2164 | + } |
|
| 2165 | + } |
|
| 2166 | + |
|
| 2167 | + /** |
|
| 2168 | + * Take an SQL statement and produce a list of fields used in that select |
|
| 2169 | + * @param string $selectStatement |
|
| 2170 | + * @return array |
|
| 2171 | + */ |
|
| 2172 | + public function getSelectFieldsFromQuery($selectStatement) |
|
| 2173 | + { |
|
| 2174 | + $selectStatement = trim($selectStatement); |
|
| 2175 | + if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") |
|
| 2176 | + $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2177 | + |
|
| 2178 | + //Due to sql functions existing in many selects, we can't use php explode |
|
| 2179 | + $fields = array(); |
|
| 2180 | + $level = 0; |
|
| 2181 | + $selectField = ""; |
|
| 2182 | + $strLen = strlen($selectStatement); |
|
| 2183 | + for($i = 0; $i < $strLen; $i++) |
|
| 2184 | + { |
|
| 2185 | + $char = $selectStatement[$i]; |
|
| 2186 | + |
|
| 2187 | + if ($char == "," && $level == 0) |
|
| 2188 | + { |
|
| 2189 | + $field = $this->getFieldNameFromSelect(trim($selectField)); |
|
| 2190 | + $fields[$field] = $selectField; |
|
| 2191 | + $selectField = ""; |
|
| 2192 | + } |
|
| 2193 | + else if ($char == "("){ |
|
| 2194 | + $level++; |
|
| 2195 | + $selectField .= $char; |
|
| 2196 | + } |
|
| 2197 | + else if($char == ")"){ |
|
| 2198 | + $level--; |
|
| 2199 | + $selectField .= $char; |
|
| 2200 | + |
|
| 2201 | + |
|
| 2202 | + }else{ |
|
| 2203 | + $selectField .= $char; |
|
| 2204 | + } |
|
| 2205 | + |
|
| 2206 | + } |
|
| 2207 | + $fields[$this->getFieldNameFromSelect($selectField)] = $selectField; |
|
| 2208 | + return $fields; |
|
| 2209 | + } |
|
| 2210 | + |
|
| 2211 | + /** |
|
| 2212 | + * returns the field name used in a select |
|
| 2213 | + * @param string $string SELECT query |
|
| 2214 | 2214 | * @return string |
| 2215 | 2215 | */ |
| 2216 | - protected function getFieldNameFromSelect($string) |
|
| 2217 | - { |
|
| 2218 | - if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2219 | - $string = substr($string, 9); |
|
| 2220 | - } |
|
| 2221 | - if (stripos($string, " as ") !== false) |
|
| 2222 | - //"as" used for an alias |
|
| 2223 | - return trim(substr($string, strripos($string, " as ") + 4)); |
|
| 2224 | - else if (strrpos($string, " ") != 0) |
|
| 2225 | - //Space used as a delimiter for an alias |
|
| 2226 | - return trim(substr($string, strrpos($string, " "))); |
|
| 2227 | - else if (strpos($string, ".") !== false) |
|
| 2228 | - //No alias, but a table.field format was used |
|
| 2229 | - return substr($string, strpos($string, ".") + 1); |
|
| 2230 | - else |
|
| 2231 | - //Give up and assume the whole thing is the field name |
|
| 2232 | - return $string; |
|
| 2233 | - } |
|
| 2234 | - |
|
| 2235 | - /** |
|
| 2236 | - * Generates SQL for delete statement identified by id. |
|
| 2237 | - * |
|
| 2238 | - * @param SugarBean $bean SugarBean instance |
|
| 2239 | - * @param array $where where conditions in an array |
|
| 2240 | - * @return string SQL Update Statement |
|
| 2241 | - */ |
|
| 2242 | - public function deleteSQL(SugarBean $bean, array $where) |
|
| 2243 | - { |
|
| 2244 | - $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 2245 | - return "UPDATE ".$bean->getTableName()." SET deleted=1 $where"; |
|
| 2246 | - } |
|
| 2216 | + protected function getFieldNameFromSelect($string) |
|
| 2217 | + { |
|
| 2218 | + if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2219 | + $string = substr($string, 9); |
|
| 2220 | + } |
|
| 2221 | + if (stripos($string, " as ") !== false) |
|
| 2222 | + //"as" used for an alias |
|
| 2223 | + return trim(substr($string, strripos($string, " as ") + 4)); |
|
| 2224 | + else if (strrpos($string, " ") != 0) |
|
| 2225 | + //Space used as a delimiter for an alias |
|
| 2226 | + return trim(substr($string, strrpos($string, " "))); |
|
| 2227 | + else if (strpos($string, ".") !== false) |
|
| 2228 | + //No alias, but a table.field format was used |
|
| 2229 | + return substr($string, strpos($string, ".") + 1); |
|
| 2230 | + else |
|
| 2231 | + //Give up and assume the whole thing is the field name |
|
| 2232 | + return $string; |
|
| 2233 | + } |
|
| 2234 | + |
|
| 2235 | + /** |
|
| 2236 | + * Generates SQL for delete statement identified by id. |
|
| 2237 | + * |
|
| 2238 | + * @param SugarBean $bean SugarBean instance |
|
| 2239 | + * @param array $where where conditions in an array |
|
| 2240 | + * @return string SQL Update Statement |
|
| 2241 | + */ |
|
| 2242 | + public function deleteSQL(SugarBean $bean, array $where) |
|
| 2243 | + { |
|
| 2244 | + $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 2245 | + return "UPDATE ".$bean->getTableName()." SET deleted=1 $where"; |
|
| 2246 | + } |
|
| 2247 | + |
|
| 2248 | + /** |
|
| 2249 | + * Generates SQL for select statement for any bean identified by id. |
|
| 2250 | + * |
|
| 2251 | + * @param SugarBean $bean SugarBean instance |
|
| 2252 | + * @param array $where where conditions in an array |
|
| 2253 | + * @return string SQL Select Statement |
|
| 2254 | + */ |
|
| 2255 | + public function retrieveSQL(SugarBean $bean, array $where) |
|
| 2256 | + { |
|
| 2257 | + $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 2258 | + return "SELECT * FROM ".$bean->getTableName()." $where AND deleted=0"; |
|
| 2259 | + } |
|
| 2260 | + |
|
| 2261 | + /** |
|
| 2262 | + * This method implements a generic sql for a collection of beans. |
|
| 2263 | + * |
|
| 2264 | + * Currently, this function does not support outer joins. |
|
| 2265 | + * |
|
| 2266 | + * @param array $beans Array of values returned by get_class method as the keys and a bean as |
|
| 2267 | + * the value for that key. These beans will be joined in the sql by the key |
|
| 2268 | + * attribute of field defs. |
|
| 2269 | + * @param array $cols Optional, columns to be returned with the keys as names of bean |
|
| 2270 | + * as identified by get_class of bean. Values of this array is the array of fieldDefs |
|
| 2271 | + * to be returned for a bean. If an empty array is passed, all columns are selected. |
|
| 2272 | + * @param array $whereClause Optional, values with the keys as names of bean as identified |
|
| 2273 | + * by get_class of bean. Each value at the first level is an array of values for that |
|
| 2274 | + * bean identified by name of fields. If we want to pass multiple values for a name, |
|
| 2275 | + * pass it as an array. If where is not passed, all the rows will be returned. |
|
| 2276 | + * |
|
| 2277 | + * @return string SQL Select Statement |
|
| 2278 | + */ |
|
| 2279 | + public function retrieveViewSQL(array $beans, array $cols = array(), array $whereClause = array()) |
|
| 2280 | + { |
|
| 2281 | + $relations = array(); // stores relations between tables as they are discovered |
|
| 2282 | + $where = $select = array(); |
|
| 2283 | + foreach ($beans as $beanID => $bean) { |
|
| 2284 | + $tableName = $bean->getTableName(); |
|
| 2285 | + $beanTables[$beanID] = $tableName; |
|
| 2286 | + |
|
| 2287 | + $table = $beanID; |
|
| 2288 | + $tables[$table] = $tableName; |
|
| 2289 | + $aliases[$tableName][] = $table; |
|
| 2290 | + |
|
| 2291 | + // build part of select for this table |
|
| 2292 | + if (is_array($cols[$beanID])) |
|
| 2293 | + foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2294 | + |
|
| 2295 | + // build part of where clause |
|
| 2296 | + if (is_array($whereClause[$beanID])){ |
|
| 2297 | + $where[] = $this->getColumnWhereClause($table, $whereClause[$beanID]); |
|
| 2298 | + } |
|
| 2299 | + // initialize so that it can be used properly in form clause generation |
|
| 2300 | + $table_used_in_from[$table] = false; |
|
| 2301 | + |
|
| 2302 | + $indices = $bean->getIndices(); |
|
| 2303 | + foreach ($indices as $index){ |
|
| 2304 | + if ($index['type'] == 'foreign') { |
|
| 2305 | + $relationship[$table][] = array('foreignTable'=> $index['foreignTable'] |
|
| 2306 | + ,'foreignColumn'=>$index['foreignField'] |
|
| 2307 | + ,'localColumn'=> $index['fields'] |
|
| 2308 | + ); |
|
| 2309 | + } |
|
| 2310 | + } |
|
| 2311 | + $where[] = " $table.deleted = 0"; |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + // join these clauses |
|
| 2315 | + $select = !empty($select) ? implode(",", $select) : "*"; |
|
| 2316 | + $where = implode(" AND ", $where); |
|
| 2317 | + |
|
| 2318 | + // generate the from clause. Use relations array to generate outer joins |
|
| 2319 | + // all the rest of the tables will be used as a simple from |
|
| 2320 | + // relations table define relations between table1 and table2 through column on table 1 |
|
| 2321 | + // table2 is assumed to joining through primary key called id |
|
| 2322 | + $separator = ""; |
|
| 2323 | + $from = ''; $table_used_in_from = array(); |
|
| 2324 | + foreach ($relations as $table1 => $rightsidearray){ |
|
| 2325 | + if ($table_used_in_from[$table1]) continue; // table has been joined |
|
| 2326 | + |
|
| 2327 | + $from .= $separator." ".$table1; |
|
| 2328 | + $table_used_in_from[$table1] = true; |
|
| 2329 | + foreach ($rightsidearray as $tablearray){ |
|
| 2330 | + $table2 = $tablearray['foreignTable']; // get foreign table |
|
| 2331 | + $tableAlias = $aliases[$table2]; // get a list of aliases for this table |
|
| 2332 | + foreach ($tableAlias as $table2) { |
|
| 2333 | + //choose first alias that does not match |
|
| 2334 | + // we are doing this because of self joins. |
|
| 2335 | + // in case of self joins, the same table will have many aliases. |
|
| 2336 | + if ($table2 != $table1) break; |
|
| 2337 | + } |
|
| 2338 | + |
|
| 2339 | + $col = $tablearray['foreingColumn']; |
|
| 2340 | + $name = $tablearray['localColumn']; |
|
| 2341 | + $from .= " LEFT JOIN $table on ($table1.$name = $table2.$col)"; |
|
| 2342 | + $table_used_in_from[$table2] = true; |
|
| 2343 | + } |
|
| 2344 | + $separator = ","; |
|
| 2345 | + } |
|
| 2346 | + |
|
| 2347 | + return "SELECT $select FROM $from WHERE $where"; |
|
| 2348 | + } |
|
| 2349 | + |
|
| 2350 | + /** |
|
| 2351 | + * Generates SQL for create index statement for a bean. |
|
| 2352 | + * |
|
| 2353 | + * @param SugarBean $bean SugarBean instance |
|
| 2354 | + * @param array $fields fields used in the index |
|
| 2355 | + * @param string $name index name |
|
| 2356 | + * @param bool $unique Optional, set to true if this is an unique index |
|
| 2357 | + * @return string SQL Select Statement |
|
| 2358 | + */ |
|
| 2359 | + public function createIndexSQL(SugarBean $bean, array $fields, $name, $unique = true) |
|
| 2360 | + { |
|
| 2361 | + $unique = ($unique) ? "unique" : ""; |
|
| 2362 | + $tablename = $bean->getTableName(); |
|
| 2363 | + $columns = array(); |
|
| 2364 | + // get column names |
|
| 2365 | + foreach ($fields as $fieldDef) |
|
| 2366 | + $columns[] = $fieldDef['name']; |
|
| 2367 | + |
|
| 2368 | + if (empty($columns)) |
|
| 2369 | + return ""; |
|
| 2370 | + |
|
| 2371 | + $columns = implode(",", $columns); |
|
| 2372 | + |
|
| 2373 | + return "CREATE $unique INDEX $name ON $tablename ($columns)"; |
|
| 2374 | + } |
|
| 2375 | + |
|
| 2376 | + /** |
|
| 2377 | + * Returns the type of the variable in the field |
|
| 2378 | + * |
|
| 2379 | + * @param array $fieldDef Vardef-format field def |
|
| 2380 | + * @return string |
|
| 2381 | + */ |
|
| 2382 | + public function getFieldType($fieldDef) |
|
| 2383 | + { |
|
| 2384 | + // get the type for db type. if that is not set, |
|
| 2385 | + // get it from type. This is done so that |
|
| 2386 | + // we do not have change a lot of existing code |
|
| 2387 | + // and add dbtype where type is being used for some special |
|
| 2388 | + // purposes like referring to foreign table etc. |
|
| 2389 | + if(!empty($fieldDef['dbType'])) |
|
| 2390 | + return $fieldDef['dbType']; |
|
| 2391 | + if(!empty($fieldDef['dbtype'])) |
|
| 2392 | + return $fieldDef['dbtype']; |
|
| 2393 | + if (!empty($fieldDef['type'])) |
|
| 2394 | + return $fieldDef['type']; |
|
| 2395 | + if (!empty($fieldDef['Type'])) |
|
| 2396 | + return $fieldDef['Type']; |
|
| 2397 | + if (!empty($fieldDef['data_type'])) |
|
| 2398 | + return $fieldDef['data_type']; |
|
| 2399 | + |
|
| 2400 | + return null; |
|
| 2401 | + } |
|
| 2402 | + |
|
| 2403 | + /** |
|
| 2404 | + * retrieves the different components from the passed column type as it is used in the type mapping and vardefs |
|
| 2405 | + * type format: <baseType>[(<len>[,<scale>])] |
|
| 2406 | + * @param string $type Column type |
|
| 2407 | + * @return array|bool array containing the different components of the passed in type or false in case the type contains illegal characters |
|
| 2408 | + */ |
|
| 2409 | + public function getTypeParts($type) |
|
| 2410 | + { |
|
| 2411 | + if(preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2412 | + { |
|
| 2413 | + $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2414 | + $return['baseType'] = $matches['type']; |
|
| 2415 | + if( isset($matches['arg'])) { |
|
| 2416 | + $return['arg'] = $matches['arg']; |
|
| 2417 | + } |
|
| 2418 | + if( isset($matches['len'])) { |
|
| 2419 | + $return['len'] = $matches['len']; |
|
| 2420 | + } |
|
| 2421 | + if( isset($matches['scale'])) { |
|
| 2422 | + $return['scale'] = $matches['scale']; |
|
| 2423 | + } |
|
| 2424 | + return $return; |
|
| 2425 | + } else { |
|
| 2426 | + return false; |
|
| 2427 | + } |
|
| 2428 | + } |
|
| 2429 | + |
|
| 2430 | + /** |
|
| 2431 | + * Returns the defintion for a single column |
|
| 2432 | + * |
|
| 2433 | + * @param array $fieldDef Vardef-format field def |
|
| 2434 | + * @param bool $ignoreRequired Optional, true if we should ignore this being a required field |
|
| 2435 | + * @param string $table Optional, table name |
|
| 2436 | + * @param bool $return_as_array Optional, true if we should return the result as an array instead of sql |
|
| 2437 | + * @return string or array if $return_as_array is true |
|
| 2438 | + */ |
|
| 2439 | + protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
|
| 2440 | + { |
|
| 2441 | + $name = $fieldDef['name']; |
|
| 2442 | + $type = $this->getFieldType($fieldDef); |
|
| 2443 | + $colType = $this->getColumnType($type); |
|
| 2444 | + |
|
| 2445 | + if($parts = $this->getTypeParts($colType)) |
|
| 2446 | + { |
|
| 2447 | + $colBaseType = $parts['baseType']; |
|
| 2448 | + $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2449 | + } |
|
| 2450 | + |
|
| 2451 | + if(!empty($fieldDef['len'])) { |
|
| 2452 | + if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2453 | + 'clob', 'blob', 'text'))) { |
|
| 2454 | + $colType = "$colBaseType(${fieldDef['len']})"; |
|
| 2455 | + } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
|
| 2456 | + if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | + if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | + $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | + }else{ |
|
| 2460 | + $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2461 | + } |
|
| 2462 | + else |
|
| 2463 | + $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2464 | + } |
|
| 2465 | + } else { |
|
| 2466 | + if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2467 | + $colType = "$colBaseType($defLen)"; |
|
| 2468 | + } |
|
| 2469 | + } |
|
| 2470 | + |
|
| 2471 | + $default = ''; |
|
| 2472 | + |
|
| 2473 | + // Bug #52610 We should have ability don't add DEFAULT part to query for boolean fields |
|
| 2474 | + if (!empty($fieldDef['no_default'])) |
|
| 2475 | + { |
|
| 2476 | + // nothing to do |
|
| 2477 | + } |
|
| 2478 | + elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2479 | + { |
|
| 2480 | + $default = " DEFAULT ".$this->quoted($fieldDef['default']); |
|
| 2481 | + } |
|
| 2482 | + elseif (!isset($default) && $type == 'bool') |
|
| 2483 | + { |
|
| 2484 | + $default = " DEFAULT 0 "; |
|
| 2485 | + } |
|
| 2486 | + |
|
| 2487 | + $auto_increment = ''; |
|
| 2488 | + if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | + $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2490 | + |
|
| 2491 | + $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2492 | + //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
|
| 2493 | + if ((empty($fieldDef['isnull']) || strtolower($fieldDef['isnull']) == 'false') && |
|
| 2494 | + (!empty($auto_increment) || $name == 'id' || ($fieldDef['type'] == 'id' && !empty($fieldDef['required'])))) { |
|
| 2495 | + $required = "NOT NULL"; |
|
| 2496 | + } |
|
| 2497 | + // If the field is marked both required & isnull=>false - alwqys make it not null |
|
| 2498 | + // Use this to ensure primary key fields never defined as null |
|
| 2499 | + if(isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2500 | + && !empty($fieldDef['required'])) { |
|
| 2501 | + $required = "NOT NULL"; |
|
| 2502 | + } |
|
| 2503 | + if ($ignoreRequired) |
|
| 2504 | + $required = ""; |
|
| 2505 | + |
|
| 2506 | + if ( $return_as_array ) { |
|
| 2507 | + return array( |
|
| 2508 | + 'name' => $name, |
|
| 2509 | + 'colType' => $colType, |
|
| 2510 | + 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2511 | + 'default' => $default, |
|
| 2512 | + 'required' => $required, |
|
| 2513 | + 'auto_increment' => $auto_increment, |
|
| 2514 | + 'full' => "$name $colType $default $required $auto_increment", |
|
| 2515 | + ); |
|
| 2516 | + } else { |
|
| 2517 | + return "$name $colType $default $required $auto_increment"; |
|
| 2518 | + } |
|
| 2519 | + } |
|
| 2520 | + |
|
| 2521 | + /** |
|
| 2522 | + * Returns SQL defintions for all columns in a table |
|
| 2523 | + * |
|
| 2524 | + * @param array $fieldDefs Vardef-format field def |
|
| 2525 | + * @param bool $ignoreRequired Optional, true if we should ignor this being a required field |
|
| 2526 | + * @param string $tablename Optional, table name |
|
| 2527 | + * @return string SQL column definitions |
|
| 2528 | + */ |
|
| 2529 | + protected function columnSQLRep($fieldDefs, $ignoreRequired = false, $tablename) |
|
| 2530 | + { |
|
| 2531 | + $columns = array(); |
|
| 2532 | + |
|
| 2533 | + if ($this->isFieldArray($fieldDefs)) { |
|
| 2534 | + foreach ($fieldDefs as $fieldDef) { |
|
| 2535 | + if(!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | + $columns[] = $this->oneColumnSQLRep($fieldDef,false, $tablename); |
|
| 2537 | + } |
|
| 2538 | + } |
|
| 2539 | + $columns = implode(",", $columns); |
|
| 2540 | + } |
|
| 2541 | + else { |
|
| 2542 | + $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
|
| 2543 | + } |
|
| 2544 | + |
|
| 2545 | + return $columns; |
|
| 2546 | + } |
|
| 2547 | + |
|
| 2548 | + /** |
|
| 2549 | + * Returns the next value for an auto increment |
|
| 2550 | + * @abstract |
|
| 2551 | + * @param string $table Table name |
|
| 2552 | + * @param string $field_name Field name |
|
| 2553 | + * @return string |
|
| 2554 | + */ |
|
| 2555 | + public function getAutoIncrement($table, $field_name) |
|
| 2556 | + { |
|
| 2557 | + return ""; |
|
| 2558 | + } |
|
| 2559 | + |
|
| 2560 | + /** |
|
| 2561 | + * Returns the sql for the next value in a sequence |
|
| 2562 | + * @abstract |
|
| 2563 | + * @param string $table Table name |
|
| 2564 | + * @param string $field_name Field name |
|
| 2565 | + * @return string |
|
| 2566 | + */ |
|
| 2567 | + public function getAutoIncrementSQL($table, $field_name) |
|
| 2568 | + { |
|
| 2569 | + return ""; |
|
| 2570 | + } |
|
| 2571 | + |
|
| 2572 | + /** |
|
| 2573 | + * Either creates an auto increment through queries or returns sql for auto increment |
|
| 2574 | + * that can be appended to the end of column defination (mysql) |
|
| 2575 | + * @abstract |
|
| 2576 | + * @param string $table Table name |
|
| 2577 | + * @param string $field_name Field name |
|
| 2578 | + * @return string |
|
| 2579 | + */ |
|
| 2580 | + protected function setAutoIncrement($table, $field_name) |
|
| 2581 | + { |
|
| 2582 | + $this->deleteAutoIncrement($table, $field_name); |
|
| 2583 | + return ""; |
|
| 2584 | + } |
|
| 2585 | + |
|
| 2586 | + /** |
|
| 2587 | + * Sets the next auto-increment value of a column to a specific value. |
|
| 2588 | + * @abstract |
|
| 2589 | + * @param string $table Table name |
|
| 2590 | + * @param string $field_name Field name |
|
| 2591 | + * @param int $start_value Starting autoincrement value |
|
| 2592 | + * @return string |
|
| 2593 | + * |
|
| 2594 | + */ |
|
| 2595 | + public function setAutoIncrementStart($table, $field_name, $start_value) |
|
| 2596 | + { |
|
| 2597 | + return ""; |
|
| 2598 | + } |
|
| 2599 | + |
|
| 2600 | + /** |
|
| 2601 | + * Deletes an auto increment |
|
| 2602 | + * @abstract |
|
| 2603 | + * @param string $table tablename |
|
| 2604 | + * @param string $field_name |
|
| 2605 | + */ |
|
| 2606 | + public function deleteAutoIncrement($table, $field_name) |
|
| 2607 | + { |
|
| 2608 | + return; |
|
| 2609 | + } |
|
| 2610 | + |
|
| 2611 | + /** |
|
| 2612 | + * This method generates sql for adding a column to table identified by field def. |
|
| 2613 | + * |
|
| 2614 | + * @param string $tablename |
|
| 2615 | + * @param array $fieldDefs |
|
| 2616 | + * @return string SQL statement |
|
| 2617 | + */ |
|
| 2618 | + public function addColumnSQL($tablename, $fieldDefs) |
|
| 2619 | + { |
|
| 2620 | + return $this->changeColumnSQL($tablename, $fieldDefs, 'add'); |
|
| 2621 | + } |
|
| 2622 | + |
|
| 2623 | + /** |
|
| 2624 | + * This method genrates sql for altering old column identified by oldFieldDef to new fieldDef. |
|
| 2625 | + * |
|
| 2626 | + * @param string $tablename |
|
| 2627 | + * @param array $newFieldDefs |
|
| 2628 | + * @param bool $ignorerequired Optional, true if we should ignor this being a required field |
|
| 2629 | + * @return string|array SQL statement(s) |
|
| 2630 | + */ |
|
| 2631 | + public function alterColumnSQL($tablename, $newFieldDefs, $ignorerequired = false) |
|
| 2632 | + { |
|
| 2633 | + return $this->changeColumnSQL($tablename, $newFieldDefs, 'modify', $ignorerequired); |
|
| 2634 | + } |
|
| 2247 | 2635 | |
| 2248 | 2636 | /** |
| 2249 | - * Generates SQL for select statement for any bean identified by id. |
|
| 2637 | + * Generates SQL for dropping a table. |
|
| 2250 | 2638 | * |
| 2251 | - * @param SugarBean $bean SugarBean instance |
|
| 2252 | - * @param array $where where conditions in an array |
|
| 2253 | - * @return string SQL Select Statement |
|
| 2639 | + * @param SugarBean $bean Sugarbean instance |
|
| 2640 | + * @return string SQL statement |
|
| 2254 | 2641 | */ |
| 2255 | - public function retrieveSQL(SugarBean $bean, array $where) |
|
| 2256 | - { |
|
| 2257 | - $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
|
| 2258 | - return "SELECT * FROM ".$bean->getTableName()." $where AND deleted=0"; |
|
| 2259 | - } |
|
| 2642 | + public function dropTableSQL(SugarBean $bean) |
|
| 2643 | + { |
|
| 2644 | + return $this->dropTableNameSQL($bean->getTableName()); |
|
| 2645 | + } |
|
| 2260 | 2646 | |
| 2261 | 2647 | /** |
| 2262 | - * This method implements a generic sql for a collection of beans. |
|
| 2648 | + * Generates SQL for dropping a table. |
|
| 2263 | 2649 | * |
| 2264 | - * Currently, this function does not support outer joins. |
|
| 2650 | + * @param string $name table name |
|
| 2651 | + * @return string SQL statement |
|
| 2652 | + */ |
|
| 2653 | + public function dropTableNameSQL($name) |
|
| 2654 | + { |
|
| 2655 | + return "DROP TABLE ".$name; |
|
| 2656 | + } |
|
| 2657 | + |
|
| 2658 | + /** |
|
| 2659 | + * Generates SQL for truncating a table. |
|
| 2660 | + * @param string $name table name |
|
| 2661 | + * @return string |
|
| 2662 | + */ |
|
| 2663 | + public function truncateTableSQL($name) |
|
| 2664 | + { |
|
| 2665 | + return "TRUNCATE $name"; |
|
| 2666 | + } |
|
| 2667 | + |
|
| 2668 | + /** |
|
| 2669 | + * This method generates sql that deletes a column identified by fieldDef. |
|
| 2265 | 2670 | * |
| 2266 | - * @param array $beans Array of values returned by get_class method as the keys and a bean as |
|
| 2267 | - * the value for that key. These beans will be joined in the sql by the key |
|
| 2268 | - * attribute of field defs. |
|
| 2269 | - * @param array $cols Optional, columns to be returned with the keys as names of bean |
|
| 2270 | - * as identified by get_class of bean. Values of this array is the array of fieldDefs |
|
| 2271 | - * to be returned for a bean. If an empty array is passed, all columns are selected. |
|
| 2272 | - * @param array $whereClause Optional, values with the keys as names of bean as identified |
|
| 2273 | - * by get_class of bean. Each value at the first level is an array of values for that |
|
| 2274 | - * bean identified by name of fields. If we want to pass multiple values for a name, |
|
| 2275 | - * pass it as an array. If where is not passed, all the rows will be returned. |
|
| 2671 | + * @param SugarBean $bean Sugarbean instance |
|
| 2672 | + * @param array $fieldDefs |
|
| 2673 | + * @return string SQL statement |
|
| 2674 | + */ |
|
| 2675 | + public function deleteColumnSQL(SugarBean $bean, $fieldDefs) |
|
| 2676 | + { |
|
| 2677 | + return $this->dropColumnSQL($bean->getTableName(), $fieldDefs); |
|
| 2678 | + } |
|
| 2679 | + |
|
| 2680 | + /** |
|
| 2681 | + * This method generates sql that drops a column identified by fieldDef. |
|
| 2682 | + * Designed to work like the other addColumnSQL() and alterColumnSQL() functions |
|
| 2276 | 2683 | * |
| 2277 | - * @return string SQL Select Statement |
|
| 2684 | + * @param string $tablename |
|
| 2685 | + * @param array $fieldDefs |
|
| 2686 | + * @return string SQL statement |
|
| 2278 | 2687 | */ |
| 2279 | - public function retrieveViewSQL(array $beans, array $cols = array(), array $whereClause = array()) |
|
| 2280 | - { |
|
| 2281 | - $relations = array(); // stores relations between tables as they are discovered |
|
| 2282 | - $where = $select = array(); |
|
| 2283 | - foreach ($beans as $beanID => $bean) { |
|
| 2284 | - $tableName = $bean->getTableName(); |
|
| 2285 | - $beanTables[$beanID] = $tableName; |
|
| 2286 | - |
|
| 2287 | - $table = $beanID; |
|
| 2288 | - $tables[$table] = $tableName; |
|
| 2289 | - $aliases[$tableName][] = $table; |
|
| 2290 | - |
|
| 2291 | - // build part of select for this table |
|
| 2292 | - if (is_array($cols[$beanID])) |
|
| 2293 | - foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2294 | - |
|
| 2295 | - // build part of where clause |
|
| 2296 | - if (is_array($whereClause[$beanID])){ |
|
| 2297 | - $where[] = $this->getColumnWhereClause($table, $whereClause[$beanID]); |
|
| 2298 | - } |
|
| 2299 | - // initialize so that it can be used properly in form clause generation |
|
| 2300 | - $table_used_in_from[$table] = false; |
|
| 2301 | - |
|
| 2302 | - $indices = $bean->getIndices(); |
|
| 2303 | - foreach ($indices as $index){ |
|
| 2304 | - if ($index['type'] == 'foreign') { |
|
| 2305 | - $relationship[$table][] = array('foreignTable'=> $index['foreignTable'] |
|
| 2306 | - ,'foreignColumn'=>$index['foreignField'] |
|
| 2307 | - ,'localColumn'=> $index['fields'] |
|
| 2308 | - ); |
|
| 2309 | - } |
|
| 2310 | - } |
|
| 2311 | - $where[] = " $table.deleted = 0"; |
|
| 2312 | - } |
|
| 2313 | - |
|
| 2314 | - // join these clauses |
|
| 2315 | - $select = !empty($select) ? implode(",", $select) : "*"; |
|
| 2316 | - $where = implode(" AND ", $where); |
|
| 2317 | - |
|
| 2318 | - // generate the from clause. Use relations array to generate outer joins |
|
| 2319 | - // all the rest of the tables will be used as a simple from |
|
| 2320 | - // relations table define relations between table1 and table2 through column on table 1 |
|
| 2321 | - // table2 is assumed to joining through primary key called id |
|
| 2322 | - $separator = ""; |
|
| 2323 | - $from = ''; $table_used_in_from = array(); |
|
| 2324 | - foreach ($relations as $table1 => $rightsidearray){ |
|
| 2325 | - if ($table_used_in_from[$table1]) continue; // table has been joined |
|
| 2326 | - |
|
| 2327 | - $from .= $separator." ".$table1; |
|
| 2328 | - $table_used_in_from[$table1] = true; |
|
| 2329 | - foreach ($rightsidearray as $tablearray){ |
|
| 2330 | - $table2 = $tablearray['foreignTable']; // get foreign table |
|
| 2331 | - $tableAlias = $aliases[$table2]; // get a list of aliases for this table |
|
| 2332 | - foreach ($tableAlias as $table2) { |
|
| 2333 | - //choose first alias that does not match |
|
| 2334 | - // we are doing this because of self joins. |
|
| 2335 | - // in case of self joins, the same table will have many aliases. |
|
| 2336 | - if ($table2 != $table1) break; |
|
| 2337 | - } |
|
| 2338 | - |
|
| 2339 | - $col = $tablearray['foreingColumn']; |
|
| 2340 | - $name = $tablearray['localColumn']; |
|
| 2341 | - $from .= " LEFT JOIN $table on ($table1.$name = $table2.$col)"; |
|
| 2342 | - $table_used_in_from[$table2] = true; |
|
| 2343 | - } |
|
| 2344 | - $separator = ","; |
|
| 2345 | - } |
|
| 2346 | - |
|
| 2347 | - return "SELECT $select FROM $from WHERE $where"; |
|
| 2348 | - } |
|
| 2349 | - |
|
| 2350 | - /** |
|
| 2351 | - * Generates SQL for create index statement for a bean. |
|
| 2352 | - * |
|
| 2353 | - * @param SugarBean $bean SugarBean instance |
|
| 2354 | - * @param array $fields fields used in the index |
|
| 2355 | - * @param string $name index name |
|
| 2356 | - * @param bool $unique Optional, set to true if this is an unique index |
|
| 2357 | - * @return string SQL Select Statement |
|
| 2358 | - */ |
|
| 2359 | - public function createIndexSQL(SugarBean $bean, array $fields, $name, $unique = true) |
|
| 2360 | - { |
|
| 2361 | - $unique = ($unique) ? "unique" : ""; |
|
| 2362 | - $tablename = $bean->getTableName(); |
|
| 2363 | - $columns = array(); |
|
| 2364 | - // get column names |
|
| 2365 | - foreach ($fields as $fieldDef) |
|
| 2366 | - $columns[] = $fieldDef['name']; |
|
| 2367 | - |
|
| 2368 | - if (empty($columns)) |
|
| 2369 | - return ""; |
|
| 2370 | - |
|
| 2371 | - $columns = implode(",", $columns); |
|
| 2372 | - |
|
| 2373 | - return "CREATE $unique INDEX $name ON $tablename ($columns)"; |
|
| 2374 | - } |
|
| 2375 | - |
|
| 2376 | - /** |
|
| 2377 | - * Returns the type of the variable in the field |
|
| 2378 | - * |
|
| 2379 | - * @param array $fieldDef Vardef-format field def |
|
| 2380 | - * @return string |
|
| 2381 | - */ |
|
| 2382 | - public function getFieldType($fieldDef) |
|
| 2383 | - { |
|
| 2384 | - // get the type for db type. if that is not set, |
|
| 2385 | - // get it from type. This is done so that |
|
| 2386 | - // we do not have change a lot of existing code |
|
| 2387 | - // and add dbtype where type is being used for some special |
|
| 2388 | - // purposes like referring to foreign table etc. |
|
| 2389 | - if(!empty($fieldDef['dbType'])) |
|
| 2390 | - return $fieldDef['dbType']; |
|
| 2391 | - if(!empty($fieldDef['dbtype'])) |
|
| 2392 | - return $fieldDef['dbtype']; |
|
| 2393 | - if (!empty($fieldDef['type'])) |
|
| 2394 | - return $fieldDef['type']; |
|
| 2395 | - if (!empty($fieldDef['Type'])) |
|
| 2396 | - return $fieldDef['Type']; |
|
| 2397 | - if (!empty($fieldDef['data_type'])) |
|
| 2398 | - return $fieldDef['data_type']; |
|
| 2399 | - |
|
| 2400 | - return null; |
|
| 2401 | - } |
|
| 2688 | + public function dropColumnSQL($tablename, $fieldDefs) |
|
| 2689 | + { |
|
| 2690 | + return $this->changeColumnSQL($tablename, $fieldDefs, 'drop'); |
|
| 2691 | + } |
|
| 2402 | 2692 | |
| 2403 | 2693 | /** |
| 2404 | - * retrieves the different components from the passed column type as it is used in the type mapping and vardefs |
|
| 2405 | - * type format: <baseType>[(<len>[,<scale>])] |
|
| 2406 | - * @param string $type Column type |
|
| 2407 | - * @return array|bool array containing the different components of the passed in type or false in case the type contains illegal characters |
|
| 2694 | + * Return a version of $proposed that can be used as a column name in any of our supported databases |
|
| 2695 | + * Practically this means no longer than 25 characters as the smallest identifier length for our supported DBs is 30 chars for Oracle plus we add on at least four characters in some places (for indicies for example) |
|
| 2696 | + * @param string|array $name Proposed name for the column |
|
| 2697 | + * @param bool|string $ensureUnique Ensure the name is unique |
|
| 2698 | + * @param string $type Name type (table, column) |
|
| 2699 | + * @param bool $force Force new name |
|
| 2700 | + * @return string|array Valid column name trimmed to right length and with invalid characters removed |
|
| 2408 | 2701 | */ |
| 2409 | - public function getTypeParts($type) |
|
| 2702 | + public function getValidDBName($name, $ensureUnique = false, $type = 'column', $force = false) |
|
| 2410 | 2703 | { |
| 2411 | - if(preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2412 | - { |
|
| 2413 | - $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2414 | - $return['baseType'] = $matches['type']; |
|
| 2415 | - if( isset($matches['arg'])) { |
|
| 2416 | - $return['arg'] = $matches['arg']; |
|
| 2704 | + if(is_array($name)) { |
|
| 2705 | + $result = array(); |
|
| 2706 | + foreach($name as $field) { |
|
| 2707 | + $result[] = $this->getValidDBName($field, $ensureUnique, $type); |
|
| 2417 | 2708 | } |
| 2418 | - if( isset($matches['len'])) { |
|
| 2419 | - $return['len'] = $matches['len']; |
|
| 2709 | + return $result; |
|
| 2710 | + } else { |
|
| 2711 | + if(strchr($name, ".")) { |
|
| 2712 | + // this is a compound name with dots, handle separately |
|
| 2713 | + $parts = explode(".", $name); |
|
| 2714 | + if(count($parts) > 2) { |
|
| 2715 | + // some weird name, cut to table.name |
|
| 2716 | + array_splice($parts, 0, count($parts)-2); |
|
| 2717 | + } |
|
| 2718 | + $parts = $this->getValidDBName($parts, $ensureUnique, $type, $force); |
|
| 2719 | + return join(".", $parts); |
|
| 2420 | 2720 | } |
| 2421 | - if( isset($matches['scale'])) { |
|
| 2422 | - $return['scale'] = $matches['scale']; |
|
| 2721 | + // first strip any invalid characters - all but word chars (which is alphanumeric and _) |
|
| 2722 | + $name = preg_replace( '/[^\w]+/i', '', $name ) ; |
|
| 2723 | + $len = strlen( $name ) ; |
|
| 2724 | + $maxLen = empty($this->maxNameLengths[$type]) ? $this->maxNameLengths[$type]['column'] : $this->maxNameLengths[$type]; |
|
| 2725 | + if ($len <= $maxLen && !$force) { |
|
| 2726 | + return strtolower($name); |
|
| 2727 | + } |
|
| 2728 | + if ($ensureUnique) { |
|
| 2729 | + $md5str = md5($name); |
|
| 2730 | + $tail = substr ( $name, -11) ; |
|
| 2731 | + $temp = substr($md5str , strlen($md5str)-4 ); |
|
| 2732 | + $result = substr( $name, 0, 10) . $temp . $tail ; |
|
| 2733 | + } else { |
|
| 2734 | + $result = substr( $name, 0, 11) . substr( $name, 11 - $maxLen); |
|
| 2423 | 2735 | } |
| 2424 | - return $return; |
|
| 2425 | - } else { |
|
| 2426 | - return false; |
|
| 2427 | - } |
|
| 2428 | - } |
|
| 2429 | - |
|
| 2430 | - /** |
|
| 2431 | - * Returns the defintion for a single column |
|
| 2432 | - * |
|
| 2433 | - * @param array $fieldDef Vardef-format field def |
|
| 2434 | - * @param bool $ignoreRequired Optional, true if we should ignore this being a required field |
|
| 2435 | - * @param string $table Optional, table name |
|
| 2436 | - * @param bool $return_as_array Optional, true if we should return the result as an array instead of sql |
|
| 2437 | - * @return string or array if $return_as_array is true |
|
| 2438 | - */ |
|
| 2439 | - protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
|
| 2440 | - { |
|
| 2441 | - $name = $fieldDef['name']; |
|
| 2442 | - $type = $this->getFieldType($fieldDef); |
|
| 2443 | - $colType = $this->getColumnType($type); |
|
| 2444 | 2736 | |
| 2445 | - if($parts = $this->getTypeParts($colType)) |
|
| 2446 | - { |
|
| 2447 | - $colBaseType = $parts['baseType']; |
|
| 2448 | - $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2737 | + return strtolower( $result ) ; |
|
| 2449 | 2738 | } |
| 2739 | + } |
|
| 2450 | 2740 | |
| 2451 | - if(!empty($fieldDef['len'])) { |
|
| 2452 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2453 | - 'clob', 'blob', 'text'))) { |
|
| 2454 | - $colType = "$colBaseType(${fieldDef['len']})"; |
|
| 2455 | - } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
|
| 2456 | - if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | - if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | - $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | - }else{ |
|
| 2460 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2461 | - } |
|
| 2462 | - else |
|
| 2463 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2464 | - } |
|
| 2465 | - } else { |
|
| 2466 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2467 | - $colType = "$colBaseType($defLen)"; |
|
| 2468 | - } |
|
| 2469 | - } |
|
| 2741 | + /** |
|
| 2742 | + * Returns the valid type for a column given the type in fieldDef |
|
| 2743 | + * |
|
| 2744 | + * @param string $type field type |
|
| 2745 | + * @return string valid type for the given field |
|
| 2746 | + */ |
|
| 2747 | + public function getColumnType($type) |
|
| 2748 | + { |
|
| 2749 | + return isset($this->type_map[$type])?$this->type_map[$type]:$type; |
|
| 2750 | + } |
|
| 2470 | 2751 | |
| 2471 | - $default = ''; |
|
| 2752 | + /** |
|
| 2753 | + * Checks to see if passed array is truely an array of defitions |
|
| 2754 | + * |
|
| 2755 | + * Such an array may have type as a key but it will point to an array |
|
| 2756 | + * for a true array of definitions an to a col type for a definition only |
|
| 2757 | + * |
|
| 2758 | + * @param mixed $defArray |
|
| 2759 | + * @return bool |
|
| 2760 | + */ |
|
| 2761 | + public function isFieldArray($defArray) |
|
| 2762 | + { |
|
| 2763 | + if ( !is_array($defArray) ) |
|
| 2764 | + return false; |
|
| 2472 | 2765 | |
| 2473 | - // Bug #52610 We should have ability don't add DEFAULT part to query for boolean fields |
|
| 2474 | - if (!empty($fieldDef['no_default'])) |
|
| 2475 | - { |
|
| 2476 | - // nothing to do |
|
| 2477 | - } |
|
| 2478 | - elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2479 | - { |
|
| 2480 | - $default = " DEFAULT ".$this->quoted($fieldDef['default']); |
|
| 2481 | - } |
|
| 2482 | - elseif (!isset($default) && $type == 'bool') |
|
| 2483 | - { |
|
| 2484 | - $default = " DEFAULT 0 "; |
|
| 2766 | + if ( isset($defArray['type']) ){ |
|
| 2767 | + // type key exists. May be an array of defs or a simple definition |
|
| 2768 | + return is_array($defArray['type']); // type is not an array => definition else array |
|
| 2485 | 2769 | } |
| 2486 | 2770 | |
| 2487 | - $auto_increment = ''; |
|
| 2488 | - if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | - $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2490 | - |
|
| 2491 | - $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2492 | - //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
|
| 2493 | - if ((empty($fieldDef['isnull']) || strtolower($fieldDef['isnull']) == 'false') && |
|
| 2494 | - (!empty($auto_increment) || $name == 'id' || ($fieldDef['type'] == 'id' && !empty($fieldDef['required'])))) { |
|
| 2495 | - $required = "NOT NULL"; |
|
| 2496 | - } |
|
| 2497 | - // If the field is marked both required & isnull=>false - alwqys make it not null |
|
| 2498 | - // Use this to ensure primary key fields never defined as null |
|
| 2499 | - if(isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2500 | - && !empty($fieldDef['required'])) { |
|
| 2501 | - $required = "NOT NULL"; |
|
| 2502 | - } |
|
| 2503 | - if ($ignoreRequired) |
|
| 2504 | - $required = ""; |
|
| 2505 | - |
|
| 2506 | - if ( $return_as_array ) { |
|
| 2507 | - return array( |
|
| 2508 | - 'name' => $name, |
|
| 2509 | - 'colType' => $colType, |
|
| 2510 | - 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2511 | - 'default' => $default, |
|
| 2512 | - 'required' => $required, |
|
| 2513 | - 'auto_increment' => $auto_increment, |
|
| 2514 | - 'full' => "$name $colType $default $required $auto_increment", |
|
| 2515 | - ); |
|
| 2516 | - } else { |
|
| 2517 | - return "$name $colType $default $required $auto_increment"; |
|
| 2518 | - } |
|
| 2519 | - } |
|
| 2520 | - |
|
| 2521 | - /** |
|
| 2522 | - * Returns SQL defintions for all columns in a table |
|
| 2523 | - * |
|
| 2524 | - * @param array $fieldDefs Vardef-format field def |
|
| 2525 | - * @param bool $ignoreRequired Optional, true if we should ignor this being a required field |
|
| 2526 | - * @param string $tablename Optional, table name |
|
| 2527 | - * @return string SQL column definitions |
|
| 2528 | - */ |
|
| 2529 | - protected function columnSQLRep($fieldDefs, $ignoreRequired = false, $tablename) |
|
| 2530 | - { |
|
| 2531 | - $columns = array(); |
|
| 2532 | - |
|
| 2533 | - if ($this->isFieldArray($fieldDefs)) { |
|
| 2534 | - foreach ($fieldDefs as $fieldDef) { |
|
| 2535 | - if(!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | - $columns[] = $this->oneColumnSQLRep($fieldDef,false, $tablename); |
|
| 2537 | - } |
|
| 2538 | - } |
|
| 2539 | - $columns = implode(",", $columns); |
|
| 2540 | - } |
|
| 2541 | - else { |
|
| 2542 | - $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
|
| 2543 | - } |
|
| 2544 | - |
|
| 2545 | - return $columns; |
|
| 2546 | - } |
|
| 2547 | - |
|
| 2548 | - /** |
|
| 2549 | - * Returns the next value for an auto increment |
|
| 2550 | - * @abstract |
|
| 2551 | - * @param string $table Table name |
|
| 2552 | - * @param string $field_name Field name |
|
| 2553 | - * @return string |
|
| 2554 | - */ |
|
| 2555 | - public function getAutoIncrement($table, $field_name) |
|
| 2556 | - { |
|
| 2557 | - return ""; |
|
| 2558 | - } |
|
| 2559 | - |
|
| 2560 | - /** |
|
| 2561 | - * Returns the sql for the next value in a sequence |
|
| 2562 | - * @abstract |
|
| 2563 | - * @param string $table Table name |
|
| 2564 | - * @param string $field_name Field name |
|
| 2565 | - * @return string |
|
| 2566 | - */ |
|
| 2567 | - public function getAutoIncrementSQL($table, $field_name) |
|
| 2568 | - { |
|
| 2569 | - return ""; |
|
| 2570 | - } |
|
| 2571 | - |
|
| 2572 | - /** |
|
| 2573 | - * Either creates an auto increment through queries or returns sql for auto increment |
|
| 2574 | - * that can be appended to the end of column defination (mysql) |
|
| 2575 | - * @abstract |
|
| 2576 | - * @param string $table Table name |
|
| 2577 | - * @param string $field_name Field name |
|
| 2578 | - * @return string |
|
| 2579 | - */ |
|
| 2580 | - protected function setAutoIncrement($table, $field_name) |
|
| 2581 | - { |
|
| 2582 | - $this->deleteAutoIncrement($table, $field_name); |
|
| 2583 | - return ""; |
|
| 2584 | - } |
|
| 2771 | + // type does not exist. Must be array of definitions |
|
| 2772 | + return true; |
|
| 2773 | + } |
|
| 2585 | 2774 | |
| 2586 | 2775 | /** |
| 2587 | - * Sets the next auto-increment value of a column to a specific value. |
|
| 2588 | - * @abstract |
|
| 2589 | - * @param string $table Table name |
|
| 2590 | - * @param string $field_name Field name |
|
| 2591 | - * @param int $start_value Starting autoincrement value |
|
| 2592 | - * @return string |
|
| 2776 | + * returns true if the type can be mapped to a valid column type |
|
| 2593 | 2777 | * |
| 2778 | + * @param string $type |
|
| 2779 | + * @return bool |
|
| 2594 | 2780 | */ |
| 2595 | - public function setAutoIncrementStart($table, $field_name, $start_value) |
|
| 2596 | - { |
|
| 2597 | - return ""; |
|
| 2598 | - } |
|
| 2599 | - |
|
| 2600 | - /** |
|
| 2601 | - * Deletes an auto increment |
|
| 2602 | - * @abstract |
|
| 2603 | - * @param string $table tablename |
|
| 2604 | - * @param string $field_name |
|
| 2605 | - */ |
|
| 2606 | - public function deleteAutoIncrement($table, $field_name) |
|
| 2607 | - { |
|
| 2608 | - return; |
|
| 2609 | - } |
|
| 2610 | - |
|
| 2611 | - /** |
|
| 2612 | - * This method generates sql for adding a column to table identified by field def. |
|
| 2613 | - * |
|
| 2614 | - * @param string $tablename |
|
| 2615 | - * @param array $fieldDefs |
|
| 2616 | - * @return string SQL statement |
|
| 2617 | - */ |
|
| 2618 | - public function addColumnSQL($tablename, $fieldDefs) |
|
| 2619 | - { |
|
| 2620 | - return $this->changeColumnSQL($tablename, $fieldDefs, 'add'); |
|
| 2621 | - } |
|
| 2622 | - |
|
| 2623 | - /** |
|
| 2624 | - * This method genrates sql for altering old column identified by oldFieldDef to new fieldDef. |
|
| 2625 | - * |
|
| 2626 | - * @param string $tablename |
|
| 2627 | - * @param array $newFieldDefs |
|
| 2628 | - * @param bool $ignorerequired Optional, true if we should ignor this being a required field |
|
| 2629 | - * @return string|array SQL statement(s) |
|
| 2630 | - */ |
|
| 2631 | - public function alterColumnSQL($tablename, $newFieldDefs, $ignorerequired = false) |
|
| 2632 | - { |
|
| 2633 | - return $this->changeColumnSQL($tablename, $newFieldDefs, 'modify', $ignorerequired); |
|
| 2634 | - } |
|
| 2635 | - |
|
| 2636 | - /** |
|
| 2637 | - * Generates SQL for dropping a table. |
|
| 2638 | - * |
|
| 2639 | - * @param SugarBean $bean Sugarbean instance |
|
| 2640 | - * @return string SQL statement |
|
| 2641 | - */ |
|
| 2642 | - public function dropTableSQL(SugarBean $bean) |
|
| 2643 | - { |
|
| 2644 | - return $this->dropTableNameSQL($bean->getTableName()); |
|
| 2645 | - } |
|
| 2646 | - |
|
| 2647 | - /** |
|
| 2648 | - * Generates SQL for dropping a table. |
|
| 2649 | - * |
|
| 2650 | - * @param string $name table name |
|
| 2651 | - * @return string SQL statement |
|
| 2652 | - */ |
|
| 2653 | - public function dropTableNameSQL($name) |
|
| 2654 | - { |
|
| 2655 | - return "DROP TABLE ".$name; |
|
| 2656 | - } |
|
| 2657 | - |
|
| 2658 | - /** |
|
| 2659 | - * Generates SQL for truncating a table. |
|
| 2660 | - * @param string $name table name |
|
| 2661 | - * @return string |
|
| 2662 | - */ |
|
| 2663 | - public function truncateTableSQL($name) |
|
| 2664 | - { |
|
| 2665 | - return "TRUNCATE $name"; |
|
| 2666 | - } |
|
| 2667 | - |
|
| 2668 | - /** |
|
| 2669 | - * This method generates sql that deletes a column identified by fieldDef. |
|
| 2670 | - * |
|
| 2671 | - * @param SugarBean $bean Sugarbean instance |
|
| 2672 | - * @param array $fieldDefs |
|
| 2673 | - * @return string SQL statement |
|
| 2674 | - */ |
|
| 2675 | - public function deleteColumnSQL(SugarBean $bean, $fieldDefs) |
|
| 2676 | - { |
|
| 2677 | - return $this->dropColumnSQL($bean->getTableName(), $fieldDefs); |
|
| 2678 | - } |
|
| 2679 | - |
|
| 2680 | - /** |
|
| 2681 | - * This method generates sql that drops a column identified by fieldDef. |
|
| 2682 | - * Designed to work like the other addColumnSQL() and alterColumnSQL() functions |
|
| 2683 | - * |
|
| 2684 | - * @param string $tablename |
|
| 2685 | - * @param array $fieldDefs |
|
| 2686 | - * @return string SQL statement |
|
| 2687 | - */ |
|
| 2688 | - public function dropColumnSQL($tablename, $fieldDefs) |
|
| 2689 | - { |
|
| 2690 | - return $this->changeColumnSQL($tablename, $fieldDefs, 'drop'); |
|
| 2691 | - } |
|
| 2781 | + protected function validColumnType($type) |
|
| 2782 | + { |
|
| 2783 | + $type = $this->getColumnType($type); |
|
| 2784 | + return !empty($type); |
|
| 2785 | + } |
|
| 2692 | 2786 | |
| 2693 | 2787 | /** |
| 2694 | - * Return a version of $proposed that can be used as a column name in any of our supported databases |
|
| 2695 | - * Practically this means no longer than 25 characters as the smallest identifier length for our supported DBs is 30 chars for Oracle plus we add on at least four characters in some places (for indicies for example) |
|
| 2696 | - * @param string|array $name Proposed name for the column |
|
| 2697 | - * @param bool|string $ensureUnique Ensure the name is unique |
|
| 2698 | - * @param string $type Name type (table, column) |
|
| 2699 | - * @param bool $force Force new name |
|
| 2700 | - * @return string|array Valid column name trimmed to right length and with invalid characters removed |
|
| 2701 | - */ |
|
| 2702 | - public function getValidDBName($name, $ensureUnique = false, $type = 'column', $force = false) |
|
| 2703 | - { |
|
| 2704 | - if(is_array($name)) { |
|
| 2705 | - $result = array(); |
|
| 2706 | - foreach($name as $field) { |
|
| 2707 | - $result[] = $this->getValidDBName($field, $ensureUnique, $type); |
|
| 2708 | - } |
|
| 2709 | - return $result; |
|
| 2710 | - } else { |
|
| 2711 | - if(strchr($name, ".")) { |
|
| 2712 | - // this is a compound name with dots, handle separately |
|
| 2713 | - $parts = explode(".", $name); |
|
| 2714 | - if(count($parts) > 2) { |
|
| 2715 | - // some weird name, cut to table.name |
|
| 2716 | - array_splice($parts, 0, count($parts)-2); |
|
| 2717 | - } |
|
| 2718 | - $parts = $this->getValidDBName($parts, $ensureUnique, $type, $force); |
|
| 2719 | - return join(".", $parts); |
|
| 2720 | - } |
|
| 2721 | - // first strip any invalid characters - all but word chars (which is alphanumeric and _) |
|
| 2722 | - $name = preg_replace( '/[^\w]+/i', '', $name ) ; |
|
| 2723 | - $len = strlen( $name ) ; |
|
| 2724 | - $maxLen = empty($this->maxNameLengths[$type]) ? $this->maxNameLengths[$type]['column'] : $this->maxNameLengths[$type]; |
|
| 2725 | - if ($len <= $maxLen && !$force) { |
|
| 2726 | - return strtolower($name); |
|
| 2727 | - } |
|
| 2728 | - if ($ensureUnique) { |
|
| 2729 | - $md5str = md5($name); |
|
| 2730 | - $tail = substr ( $name, -11) ; |
|
| 2731 | - $temp = substr($md5str , strlen($md5str)-4 ); |
|
| 2732 | - $result = substr( $name, 0, 10) . $temp . $tail ; |
|
| 2733 | - } else { |
|
| 2734 | - $result = substr( $name, 0, 11) . substr( $name, 11 - $maxLen); |
|
| 2735 | - } |
|
| 2736 | - |
|
| 2737 | - return strtolower( $result ) ; |
|
| 2738 | - } |
|
| 2739 | - } |
|
| 2740 | - |
|
| 2741 | - /** |
|
| 2742 | - * Returns the valid type for a column given the type in fieldDef |
|
| 2743 | - * |
|
| 2744 | - * @param string $type field type |
|
| 2745 | - * @return string valid type for the given field |
|
| 2746 | - */ |
|
| 2747 | - public function getColumnType($type) |
|
| 2748 | - { |
|
| 2749 | - return isset($this->type_map[$type])?$this->type_map[$type]:$type; |
|
| 2750 | - } |
|
| 2751 | - |
|
| 2752 | - /** |
|
| 2753 | - * Checks to see if passed array is truely an array of defitions |
|
| 2754 | - * |
|
| 2755 | - * Such an array may have type as a key but it will point to an array |
|
| 2756 | - * for a true array of definitions an to a col type for a definition only |
|
| 2757 | - * |
|
| 2758 | - * @param mixed $defArray |
|
| 2759 | - * @return bool |
|
| 2760 | - */ |
|
| 2761 | - public function isFieldArray($defArray) |
|
| 2762 | - { |
|
| 2763 | - if ( !is_array($defArray) ) |
|
| 2764 | - return false; |
|
| 2765 | - |
|
| 2766 | - if ( isset($defArray['type']) ){ |
|
| 2767 | - // type key exists. May be an array of defs or a simple definition |
|
| 2768 | - return is_array($defArray['type']); // type is not an array => definition else array |
|
| 2769 | - } |
|
| 2770 | - |
|
| 2771 | - // type does not exist. Must be array of definitions |
|
| 2772 | - return true; |
|
| 2773 | - } |
|
| 2774 | - |
|
| 2775 | - /** |
|
| 2776 | - * returns true if the type can be mapped to a valid column type |
|
| 2777 | - * |
|
| 2778 | - * @param string $type |
|
| 2779 | - * @return bool |
|
| 2780 | - */ |
|
| 2781 | - protected function validColumnType($type) |
|
| 2782 | - { |
|
| 2783 | - $type = $this->getColumnType($type); |
|
| 2784 | - return !empty($type); |
|
| 2785 | - } |
|
| 2786 | - |
|
| 2787 | - /** |
|
| 2788 | - * Generate query for audit table |
|
| 2789 | - * @param SugarBean $bean SugarBean that was changed |
|
| 2790 | - * @param array $changes List of changes, contains 'before' and 'after' |
|
| 2788 | + * Generate query for audit table |
|
| 2789 | + * @param SugarBean $bean SugarBean that was changed |
|
| 2790 | + * @param array $changes List of changes, contains 'before' and 'after' |
|
| 2791 | 2791 | * @return string Audit table INSERT query |
| 2792 | 2792 | */ |
| 2793 | - protected function auditSQL(SugarBean $bean, $changes) |
|
| 2794 | - { |
|
| 2795 | - global $current_user; |
|
| 2796 | - $sql = "INSERT INTO ".$bean->get_audit_table_name(); |
|
| 2797 | - //get field defs for the audit table. |
|
| 2798 | - require('metadata/audit_templateMetaData.php'); |
|
| 2799 | - $fieldDefs = $dictionary['audit']['fields']; |
|
| 2800 | - |
|
| 2801 | - $values=array(); |
|
| 2802 | - $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']); |
|
| 2803 | - $values['parent_id']= $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | - $values['field_name']= $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2805 | - $values['data_type'] = $this->massageValue($changes['data_type'], $fieldDefs['data_type']); |
|
| 2806 | - if ($changes['data_type']=='text') { |
|
| 2807 | - $values['before_value_text'] = $this->massageValue($changes['before'], $fieldDefs['before_value_text']); |
|
| 2808 | - $values['after_value_text'] = $this->massageValue($changes['after'], $fieldDefs['after_value_text']); |
|
| 2809 | - } else { |
|
| 2810 | - $values['before_value_string'] = $this->massageValue($changes['before'], $fieldDefs['before_value_string']); |
|
| 2811 | - $values['after_value_string'] = $this->massageValue($changes['after'], $fieldDefs['after_value_string']); |
|
| 2812 | - } |
|
| 2813 | - $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created'] ); |
|
| 2814 | - $values['created_by'] = $this->massageValue($current_user->id, $fieldDefs['created_by']); |
|
| 2815 | - |
|
| 2816 | - $sql .= "(".implode(",", array_keys($values)).") "; |
|
| 2817 | - $sql .= "VALUES(".implode(",", $values).")"; |
|
| 2818 | - return $sql; |
|
| 2819 | - } |
|
| 2793 | + protected function auditSQL(SugarBean $bean, $changes) |
|
| 2794 | + { |
|
| 2795 | + global $current_user; |
|
| 2796 | + $sql = "INSERT INTO ".$bean->get_audit_table_name(); |
|
| 2797 | + //get field defs for the audit table. |
|
| 2798 | + require('metadata/audit_templateMetaData.php'); |
|
| 2799 | + $fieldDefs = $dictionary['audit']['fields']; |
|
| 2800 | + |
|
| 2801 | + $values=array(); |
|
| 2802 | + $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']); |
|
| 2803 | + $values['parent_id']= $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | + $values['field_name']= $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2805 | + $values['data_type'] = $this->massageValue($changes['data_type'], $fieldDefs['data_type']); |
|
| 2806 | + if ($changes['data_type']=='text') { |
|
| 2807 | + $values['before_value_text'] = $this->massageValue($changes['before'], $fieldDefs['before_value_text']); |
|
| 2808 | + $values['after_value_text'] = $this->massageValue($changes['after'], $fieldDefs['after_value_text']); |
|
| 2809 | + } else { |
|
| 2810 | + $values['before_value_string'] = $this->massageValue($changes['before'], $fieldDefs['before_value_string']); |
|
| 2811 | + $values['after_value_string'] = $this->massageValue($changes['after'], $fieldDefs['after_value_string']); |
|
| 2812 | + } |
|
| 2813 | + $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created'] ); |
|
| 2814 | + $values['created_by'] = $this->massageValue($current_user->id, $fieldDefs['created_by']); |
|
| 2815 | + |
|
| 2816 | + $sql .= "(".implode(",", array_keys($values)).") "; |
|
| 2817 | + $sql .= "VALUES(".implode(",", $values).")"; |
|
| 2818 | + return $sql; |
|
| 2819 | + } |
|
| 2820 | 2820 | |
| 2821 | 2821 | /** |
| 2822 | 2822 | * Saves changes to module's audit table |
@@ -2826,10 +2826,10 @@ discard block |
||
| 2826 | 2826 | * @return bool query result |
| 2827 | 2827 | * |
| 2828 | 2828 | */ |
| 2829 | - public function save_audit_records(SugarBean $bean, $changes) |
|
| 2830 | - { |
|
| 2831 | - return $this->query($this->auditSQL($bean, $changes)); |
|
| 2832 | - } |
|
| 2829 | + public function save_audit_records(SugarBean $bean, $changes) |
|
| 2830 | + { |
|
| 2831 | + return $this->query($this->auditSQL($bean, $changes)); |
|
| 2832 | + } |
|
| 2833 | 2833 | |
| 2834 | 2834 | /** |
| 2835 | 2835 | * Finds fields whose value has changed. |
@@ -2841,7 +2841,7 @@ discard block |
||
| 2841 | 2841 | * @return array |
| 2842 | 2842 | */ |
| 2843 | 2843 | public function getDataChanges(SugarBean &$bean, array $field_filter = null) |
| 2844 | - { |
|
| 2844 | + { |
|
| 2845 | 2845 | $changed_values=array(); |
| 2846 | 2846 | |
| 2847 | 2847 | $fetched_row = array(); |
@@ -2918,10 +2918,10 @@ discard block |
||
| 2918 | 2918 | } |
| 2919 | 2919 | } |
| 2920 | 2920 | } |
| 2921 | - } |
|
| 2922 | - } |
|
| 2923 | - return $changed_values; |
|
| 2924 | - } |
|
| 2921 | + } |
|
| 2922 | + } |
|
| 2923 | + return $changed_values; |
|
| 2924 | + } |
|
| 2925 | 2925 | |
| 2926 | 2926 | /** |
| 2927 | 2927 | * Uses the audit enabled fields array to find fields whose value has changed. |
@@ -2937,40 +2937,40 @@ discard block |
||
| 2937 | 2937 | return $this->getDataChanges($bean, array_keys($audit_fields)); |
| 2938 | 2938 | } |
| 2939 | 2939 | |
| 2940 | - /** |
|
| 2941 | - * Setup FT indexing |
|
| 2942 | - * @abstract |
|
| 2943 | - */ |
|
| 2944 | - public function full_text_indexing_setup() |
|
| 2945 | - { |
|
| 2946 | - // Most DBs have nothing to setup, so provide default empty function |
|
| 2947 | - } |
|
| 2948 | - |
|
| 2949 | - /** |
|
| 2950 | - * Quotes a string for storing in the database |
|
| 2951 | - * @deprecated |
|
| 2952 | - * Return value will be not surrounded by quotes |
|
| 2953 | - * |
|
| 2954 | - * @param string $string |
|
| 2955 | - * @return string |
|
| 2956 | - */ |
|
| 2957 | - public function escape_quote($string) |
|
| 2958 | - { |
|
| 2959 | - return $this->quote($string); |
|
| 2960 | - } |
|
| 2961 | - |
|
| 2962 | - /** |
|
| 2963 | - * Quotes a string for storing in the database |
|
| 2964 | - * @deprecated |
|
| 2965 | - * Return value will be not surrounded by quotes |
|
| 2966 | - * |
|
| 2967 | - * @param string $string |
|
| 2968 | - * @return string |
|
| 2969 | - */ |
|
| 2970 | - public function quoteFormEmail($string) |
|
| 2971 | - { |
|
| 2972 | - return $this->quote($string); |
|
| 2973 | - } |
|
| 2940 | + /** |
|
| 2941 | + * Setup FT indexing |
|
| 2942 | + * @abstract |
|
| 2943 | + */ |
|
| 2944 | + public function full_text_indexing_setup() |
|
| 2945 | + { |
|
| 2946 | + // Most DBs have nothing to setup, so provide default empty function |
|
| 2947 | + } |
|
| 2948 | + |
|
| 2949 | + /** |
|
| 2950 | + * Quotes a string for storing in the database |
|
| 2951 | + * @deprecated |
|
| 2952 | + * Return value will be not surrounded by quotes |
|
| 2953 | + * |
|
| 2954 | + * @param string $string |
|
| 2955 | + * @return string |
|
| 2956 | + */ |
|
| 2957 | + public function escape_quote($string) |
|
| 2958 | + { |
|
| 2959 | + return $this->quote($string); |
|
| 2960 | + } |
|
| 2961 | + |
|
| 2962 | + /** |
|
| 2963 | + * Quotes a string for storing in the database |
|
| 2964 | + * @deprecated |
|
| 2965 | + * Return value will be not surrounded by quotes |
|
| 2966 | + * |
|
| 2967 | + * @param string $string |
|
| 2968 | + * @return string |
|
| 2969 | + */ |
|
| 2970 | + public function quoteFormEmail($string) |
|
| 2971 | + { |
|
| 2972 | + return $this->quote($string); |
|
| 2973 | + } |
|
| 2974 | 2974 | |
| 2975 | 2975 | /** |
| 2976 | 2976 | * Renames an index using fields definition |
@@ -2980,49 +2980,49 @@ discard block |
||
| 2980 | 2980 | * @param string $table_name |
| 2981 | 2981 | * @return string SQL statement |
| 2982 | 2982 | */ |
| 2983 | - public function renameIndexDefs($old_definition, $new_definition, $table_name) |
|
| 2984 | - { |
|
| 2985 | - return array($this->add_drop_constraint($table_name,$old_definition,true), |
|
| 2986 | - $this->add_drop_constraint($table_name,$new_definition), false); |
|
| 2987 | - } |
|
| 2983 | + public function renameIndexDefs($old_definition, $new_definition, $table_name) |
|
| 2984 | + { |
|
| 2985 | + return array($this->add_drop_constraint($table_name,$old_definition,true), |
|
| 2986 | + $this->add_drop_constraint($table_name,$new_definition), false); |
|
| 2987 | + } |
|
| 2988 | 2988 | |
| 2989 | - /** |
|
| 2990 | - * Check if type is boolean |
|
| 2991 | - * @param string $type |
|
| 2989 | + /** |
|
| 2990 | + * Check if type is boolean |
|
| 2991 | + * @param string $type |
|
| 2992 | 2992 | * @return bool |
| 2993 | 2993 | */ |
| 2994 | - public function isBooleanType($type) |
|
| 2995 | - { |
|
| 2996 | - return 'bool' == $type; |
|
| 2997 | - } |
|
| 2994 | + public function isBooleanType($type) |
|
| 2995 | + { |
|
| 2996 | + return 'bool' == $type; |
|
| 2997 | + } |
|
| 2998 | 2998 | |
| 2999 | - /** |
|
| 3000 | - * Get truth value for boolean type |
|
| 3001 | - * Allows 'off' to mean false, along with all 'empty' values |
|
| 3002 | - * @param mixed $val |
|
| 2999 | + /** |
|
| 3000 | + * Get truth value for boolean type |
|
| 3001 | + * Allows 'off' to mean false, along with all 'empty' values |
|
| 3002 | + * @param mixed $val |
|
| 3003 | 3003 | * @return bool |
| 3004 | - */ |
|
| 3005 | - protected function _getBooleanValue($val) |
|
| 3006 | - { |
|
| 3007 | - //need to put the === sign here otherwise true == 'non empty string' |
|
| 3008 | - if (empty($val) or $val==='off') |
|
| 3009 | - return false; |
|
| 3010 | - |
|
| 3011 | - return true; |
|
| 3012 | - } |
|
| 3013 | - |
|
| 3014 | - /** |
|
| 3015 | - * Check if type is a number |
|
| 3016 | - * @param string $type |
|
| 3004 | + */ |
|
| 3005 | + protected function _getBooleanValue($val) |
|
| 3006 | + { |
|
| 3007 | + //need to put the === sign here otherwise true == 'non empty string' |
|
| 3008 | + if (empty($val) or $val==='off') |
|
| 3009 | + return false; |
|
| 3010 | + |
|
| 3011 | + return true; |
|
| 3012 | + } |
|
| 3013 | + |
|
| 3014 | + /** |
|
| 3015 | + * Check if type is a number |
|
| 3016 | + * @param string $type |
|
| 3017 | 3017 | * @return bool |
| 3018 | - */ |
|
| 3019 | - public function isNumericType($type) |
|
| 3020 | - { |
|
| 3021 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3022 | - return true; |
|
| 3023 | - } |
|
| 3024 | - return false; |
|
| 3025 | - } |
|
| 3018 | + */ |
|
| 3019 | + public function isNumericType($type) |
|
| 3020 | + { |
|
| 3021 | + if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3022 | + return true; |
|
| 3023 | + } |
|
| 3024 | + return false; |
|
| 3025 | + } |
|
| 3026 | 3026 | |
| 3027 | 3027 | /** |
| 3028 | 3028 | * Check if the value is empty value for this type |
@@ -3030,272 +3030,272 @@ discard block |
||
| 3030 | 3030 | * @param string $type Type (one of vardef types) |
| 3031 | 3031 | * @return bool true if the value if empty |
| 3032 | 3032 | */ |
| 3033 | - protected function _emptyValue($val, $type) |
|
| 3034 | - { |
|
| 3035 | - if (empty($val)) |
|
| 3036 | - return true; |
|
| 3037 | - |
|
| 3038 | - if($this->emptyValue($type) == $val) { |
|
| 3039 | - return true; |
|
| 3040 | - } |
|
| 3041 | - switch ($type) { |
|
| 3042 | - case 'decimal': |
|
| 3043 | - case 'decimal2': |
|
| 3044 | - case 'int': |
|
| 3045 | - case 'double': |
|
| 3046 | - case 'float': |
|
| 3047 | - case 'uint': |
|
| 3048 | - case 'ulong': |
|
| 3049 | - case 'long': |
|
| 3050 | - case 'short': |
|
| 3051 | - return ($val == 0); |
|
| 3052 | - case 'date': |
|
| 3053 | - if ($val == '0000-00-00') |
|
| 3054 | - return true; |
|
| 3055 | - if ($val == 'NULL') |
|
| 3056 | - return true; |
|
| 3057 | - return false; |
|
| 3058 | - } |
|
| 3059 | - |
|
| 3060 | - return false; |
|
| 3061 | - } |
|
| 3062 | - |
|
| 3063 | - /** |
|
| 3033 | + protected function _emptyValue($val, $type) |
|
| 3034 | + { |
|
| 3035 | + if (empty($val)) |
|
| 3036 | + return true; |
|
| 3037 | + |
|
| 3038 | + if($this->emptyValue($type) == $val) { |
|
| 3039 | + return true; |
|
| 3040 | + } |
|
| 3041 | + switch ($type) { |
|
| 3042 | + case 'decimal': |
|
| 3043 | + case 'decimal2': |
|
| 3044 | + case 'int': |
|
| 3045 | + case 'double': |
|
| 3046 | + case 'float': |
|
| 3047 | + case 'uint': |
|
| 3048 | + case 'ulong': |
|
| 3049 | + case 'long': |
|
| 3050 | + case 'short': |
|
| 3051 | + return ($val == 0); |
|
| 3052 | + case 'date': |
|
| 3053 | + if ($val == '0000-00-00') |
|
| 3054 | + return true; |
|
| 3055 | + if ($val == 'NULL') |
|
| 3056 | + return true; |
|
| 3057 | + return false; |
|
| 3058 | + } |
|
| 3059 | + |
|
| 3060 | + return false; |
|
| 3061 | + } |
|
| 3062 | + |
|
| 3063 | + /** |
|
| 3064 | 3064 | * @abstract |
| 3065 | - * Does this type represent text (i.e., non-varchar) value? |
|
| 3066 | - * @param string $type |
|
| 3065 | + * Does this type represent text (i.e., non-varchar) value? |
|
| 3066 | + * @param string $type |
|
| 3067 | 3067 | * @return bool |
| 3068 | - */ |
|
| 3069 | - public function isTextType($type) |
|
| 3070 | - { |
|
| 3071 | - return false; |
|
| 3072 | - } |
|
| 3073 | - |
|
| 3074 | - /** |
|
| 3075 | - * Check if this DB supports certain capability |
|
| 3076 | - * See $this->capabilities for the list |
|
| 3077 | - * @param string $cap |
|
| 3068 | + */ |
|
| 3069 | + public function isTextType($type) |
|
| 3070 | + { |
|
| 3071 | + return false; |
|
| 3072 | + } |
|
| 3073 | + |
|
| 3074 | + /** |
|
| 3075 | + * Check if this DB supports certain capability |
|
| 3076 | + * See $this->capabilities for the list |
|
| 3077 | + * @param string $cap |
|
| 3078 | 3078 | * @return bool |
| 3079 | - */ |
|
| 3080 | - public function supports($cap) |
|
| 3081 | - { |
|
| 3082 | - return !empty($this->capabilities[$cap]); |
|
| 3083 | - } |
|
| 3084 | - |
|
| 3085 | - /** |
|
| 3086 | - * Create ORDER BY clause for ENUM type field |
|
| 3087 | - * @param string $order_by Field name |
|
| 3088 | - * @param array $values Possible enum value |
|
| 3089 | - * @param string $order_dir Order direction, ASC or DESC |
|
| 3079 | + */ |
|
| 3080 | + public function supports($cap) |
|
| 3081 | + { |
|
| 3082 | + return !empty($this->capabilities[$cap]); |
|
| 3083 | + } |
|
| 3084 | + |
|
| 3085 | + /** |
|
| 3086 | + * Create ORDER BY clause for ENUM type field |
|
| 3087 | + * @param string $order_by Field name |
|
| 3088 | + * @param array $values Possible enum value |
|
| 3089 | + * @param string $order_dir Order direction, ASC or DESC |
|
| 3090 | 3090 | * @return string |
| 3091 | 3091 | */ |
| 3092 | - public function orderByEnum($order_by, $values, $order_dir) |
|
| 3093 | - { |
|
| 3094 | - $i = 0; |
|
| 3095 | - $order_by_arr = array(); |
|
| 3096 | - foreach ($values as $key => $value) { |
|
| 3097 | - if($key == '') { |
|
| 3098 | - $order_by_arr[] = "WHEN ($order_by='' OR $order_by IS NULL) THEN $i"; |
|
| 3099 | - } else { |
|
| 3100 | - $order_by_arr[] = "WHEN $order_by=".$this->quoted($key)." THEN $i"; |
|
| 3101 | - } |
|
| 3102 | - $i++; |
|
| 3103 | - } |
|
| 3104 | - return "CASE ".implode("\n", $order_by_arr)." ELSE $i END $order_dir\n"; |
|
| 3105 | - } |
|
| 3106 | - |
|
| 3107 | - /** |
|
| 3108 | - * Return representation of an empty value depending on type |
|
| 3109 | - * The value is fully quoted, converted, etc. |
|
| 3110 | - * @param string $type |
|
| 3092 | + public function orderByEnum($order_by, $values, $order_dir) |
|
| 3093 | + { |
|
| 3094 | + $i = 0; |
|
| 3095 | + $order_by_arr = array(); |
|
| 3096 | + foreach ($values as $key => $value) { |
|
| 3097 | + if($key == '') { |
|
| 3098 | + $order_by_arr[] = "WHEN ($order_by='' OR $order_by IS NULL) THEN $i"; |
|
| 3099 | + } else { |
|
| 3100 | + $order_by_arr[] = "WHEN $order_by=".$this->quoted($key)." THEN $i"; |
|
| 3101 | + } |
|
| 3102 | + $i++; |
|
| 3103 | + } |
|
| 3104 | + return "CASE ".implode("\n", $order_by_arr)." ELSE $i END $order_dir\n"; |
|
| 3105 | + } |
|
| 3106 | + |
|
| 3107 | + /** |
|
| 3108 | + * Return representation of an empty value depending on type |
|
| 3109 | + * The value is fully quoted, converted, etc. |
|
| 3110 | + * @param string $type |
|
| 3111 | 3111 | * @return mixed Empty value |
| 3112 | 3112 | */ |
| 3113 | - public function emptyValue($type) |
|
| 3114 | - { |
|
| 3115 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3116 | - return 0; |
|
| 3117 | - } |
|
| 3113 | + public function emptyValue($type) |
|
| 3114 | + { |
|
| 3115 | + if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3116 | + return 0; |
|
| 3117 | + } |
|
| 3118 | 3118 | |
| 3119 | - return "''"; |
|
| 3120 | - } |
|
| 3119 | + return "''"; |
|
| 3120 | + } |
|
| 3121 | 3121 | |
| 3122 | - /** |
|
| 3123 | - * List of available collation settings |
|
| 3122 | + /** |
|
| 3123 | + * List of available collation settings |
|
| 3124 | 3124 | * @abstract |
| 3125 | - * @return string |
|
| 3126 | - */ |
|
| 3127 | - public function getDefaultCollation() |
|
| 3128 | - { |
|
| 3129 | - return null; |
|
| 3130 | - } |
|
| 3131 | - |
|
| 3132 | - /** |
|
| 3133 | - * List of available collation settings |
|
| 3125 | + * @return string |
|
| 3126 | + */ |
|
| 3127 | + public function getDefaultCollation() |
|
| 3128 | + { |
|
| 3129 | + return null; |
|
| 3130 | + } |
|
| 3131 | + |
|
| 3132 | + /** |
|
| 3133 | + * List of available collation settings |
|
| 3134 | 3134 | * @abstract |
| 3135 | - * @return array |
|
| 3136 | - */ |
|
| 3137 | - public function getCollationList() |
|
| 3138 | - { |
|
| 3139 | - return null; |
|
| 3140 | - } |
|
| 3141 | - |
|
| 3142 | - /** |
|
| 3143 | - * Returns the number of columns in a table |
|
| 3144 | - * |
|
| 3145 | - * @param string $table_name |
|
| 3146 | - * @return int |
|
| 3147 | - */ |
|
| 3148 | - public function number_of_columns($table_name) |
|
| 3149 | - { |
|
| 3150 | - $table = $this->getTableDescription($table_name); |
|
| 3151 | - return count($table); |
|
| 3152 | - } |
|
| 3153 | - |
|
| 3154 | - /** |
|
| 3155 | - * Return limit query based on given query |
|
| 3156 | - * @param string $sql |
|
| 3157 | - * @param int $start |
|
| 3158 | - * @param int $count |
|
| 3159 | - * @param bool $dieOnError |
|
| 3160 | - * @param string $msg |
|
| 3135 | + * @return array |
|
| 3136 | + */ |
|
| 3137 | + public function getCollationList() |
|
| 3138 | + { |
|
| 3139 | + return null; |
|
| 3140 | + } |
|
| 3141 | + |
|
| 3142 | + /** |
|
| 3143 | + * Returns the number of columns in a table |
|
| 3144 | + * |
|
| 3145 | + * @param string $table_name |
|
| 3146 | + * @return int |
|
| 3147 | + */ |
|
| 3148 | + public function number_of_columns($table_name) |
|
| 3149 | + { |
|
| 3150 | + $table = $this->getTableDescription($table_name); |
|
| 3151 | + return count($table); |
|
| 3152 | + } |
|
| 3153 | + |
|
| 3154 | + /** |
|
| 3155 | + * Return limit query based on given query |
|
| 3156 | + * @param string $sql |
|
| 3157 | + * @param int $start |
|
| 3158 | + * @param int $count |
|
| 3159 | + * @param bool $dieOnError |
|
| 3160 | + * @param string $msg |
|
| 3161 | 3161 | * @return resource|bool query result |
| 3162 | 3162 | * @see DBManager::limitQuery() |
| 3163 | - */ |
|
| 3164 | - public function limitQuerySql($sql, $start, $count, $dieOnError=false, $msg='') |
|
| 3165 | - { |
|
| 3166 | - return $this->limitQuery($sql,$start,$count,$dieOnError,$msg,false); |
|
| 3167 | - } |
|
| 3168 | - |
|
| 3169 | - /** |
|
| 3170 | - * Return current time in format fit for insertion into DB (with quotes) |
|
| 3171 | - * @return string |
|
| 3172 | - */ |
|
| 3173 | - public function now() |
|
| 3174 | - { |
|
| 3175 | - return $this->convert($this->quoted(TimeDate::getInstance()->nowDb()), "datetime"); |
|
| 3176 | - } |
|
| 3177 | - |
|
| 3178 | - /** |
|
| 3179 | - * Check if connecting user has certain privilege |
|
| 3180 | - * @param string $privilege |
|
| 3163 | + */ |
|
| 3164 | + public function limitQuerySql($sql, $start, $count, $dieOnError=false, $msg='') |
|
| 3165 | + { |
|
| 3166 | + return $this->limitQuery($sql,$start,$count,$dieOnError,$msg,false); |
|
| 3167 | + } |
|
| 3168 | + |
|
| 3169 | + /** |
|
| 3170 | + * Return current time in format fit for insertion into DB (with quotes) |
|
| 3171 | + * @return string |
|
| 3172 | + */ |
|
| 3173 | + public function now() |
|
| 3174 | + { |
|
| 3175 | + return $this->convert($this->quoted(TimeDate::getInstance()->nowDb()), "datetime"); |
|
| 3176 | + } |
|
| 3177 | + |
|
| 3178 | + /** |
|
| 3179 | + * Check if connecting user has certain privilege |
|
| 3180 | + * @param string $privilege |
|
| 3181 | 3181 | * @return bool Privilege allowed? |
| 3182 | 3182 | */ |
| 3183 | - public function checkPrivilege($privilege) |
|
| 3184 | - { |
|
| 3185 | - switch($privilege) { |
|
| 3186 | - case "CREATE TABLE": |
|
| 3187 | - $this->query("CREATE TABLE temp (id varchar(36))"); |
|
| 3188 | - break; |
|
| 3189 | - case "DROP TABLE": |
|
| 3190 | - $sql = $this->dropTableNameSQL("temp"); |
|
| 3191 | - $this->query($sql); |
|
| 3192 | - break; |
|
| 3193 | - case "INSERT": |
|
| 3194 | - $this->query("INSERT INTO temp (id) VALUES ('abcdef0123456789abcdef0123456789abcd')"); |
|
| 3195 | - break; |
|
| 3196 | - case "UPDATE": |
|
| 3197 | - $this->query("UPDATE temp SET id = '100000000000000000000000000000000000' WHERE id = 'abcdef0123456789abcdef0123456789abcd'"); |
|
| 3198 | - break; |
|
| 3199 | - case 'SELECT': |
|
| 3200 | - return $this->getOne('SELECT id FROM temp WHERE id=\'100000000000000000000000000000000000\'', false); |
|
| 3201 | - case 'DELETE': |
|
| 3202 | - $this->query("DELETE FROM temp WHERE id = '100000000000000000000000000000000000'"); |
|
| 3203 | - break; |
|
| 3204 | - case "ADD COLUMN": |
|
| 3205 | - $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 50)); |
|
| 3206 | - $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3207 | - $this->query($sql); |
|
| 3208 | - break; |
|
| 3209 | - case "CHANGE COLUMN": |
|
| 3210 | - $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
|
| 3211 | - $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3212 | - $this->query($sql); |
|
| 3213 | - break; |
|
| 3214 | - case "DROP COLUMN": |
|
| 3215 | - $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
|
| 3216 | - $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3217 | - $this->query($sql); |
|
| 3218 | - break; |
|
| 3219 | - default: |
|
| 3220 | - return false; |
|
| 3221 | - } |
|
| 3222 | - if($this->checkError("Checking privileges")) { |
|
| 3223 | - return false; |
|
| 3224 | - } |
|
| 3225 | - return true; |
|
| 3226 | - } |
|
| 3227 | - |
|
| 3228 | - /** |
|
| 3229 | - * Check if the query is a select query |
|
| 3230 | - * @param string $query |
|
| 3183 | + public function checkPrivilege($privilege) |
|
| 3184 | + { |
|
| 3185 | + switch($privilege) { |
|
| 3186 | + case "CREATE TABLE": |
|
| 3187 | + $this->query("CREATE TABLE temp (id varchar(36))"); |
|
| 3188 | + break; |
|
| 3189 | + case "DROP TABLE": |
|
| 3190 | + $sql = $this->dropTableNameSQL("temp"); |
|
| 3191 | + $this->query($sql); |
|
| 3192 | + break; |
|
| 3193 | + case "INSERT": |
|
| 3194 | + $this->query("INSERT INTO temp (id) VALUES ('abcdef0123456789abcdef0123456789abcd')"); |
|
| 3195 | + break; |
|
| 3196 | + case "UPDATE": |
|
| 3197 | + $this->query("UPDATE temp SET id = '100000000000000000000000000000000000' WHERE id = 'abcdef0123456789abcdef0123456789abcd'"); |
|
| 3198 | + break; |
|
| 3199 | + case 'SELECT': |
|
| 3200 | + return $this->getOne('SELECT id FROM temp WHERE id=\'100000000000000000000000000000000000\'', false); |
|
| 3201 | + case 'DELETE': |
|
| 3202 | + $this->query("DELETE FROM temp WHERE id = '100000000000000000000000000000000000'"); |
|
| 3203 | + break; |
|
| 3204 | + case "ADD COLUMN": |
|
| 3205 | + $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 50)); |
|
| 3206 | + $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3207 | + $this->query($sql); |
|
| 3208 | + break; |
|
| 3209 | + case "CHANGE COLUMN": |
|
| 3210 | + $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
|
| 3211 | + $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3212 | + $this->query($sql); |
|
| 3213 | + break; |
|
| 3214 | + case "DROP COLUMN": |
|
| 3215 | + $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
|
| 3216 | + $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3217 | + $this->query($sql); |
|
| 3218 | + break; |
|
| 3219 | + default: |
|
| 3220 | + return false; |
|
| 3221 | + } |
|
| 3222 | + if($this->checkError("Checking privileges")) { |
|
| 3223 | + return false; |
|
| 3224 | + } |
|
| 3225 | + return true; |
|
| 3226 | + } |
|
| 3227 | + |
|
| 3228 | + /** |
|
| 3229 | + * Check if the query is a select query |
|
| 3230 | + * @param string $query |
|
| 3231 | 3231 | * @return bool Is query SELECT? |
| 3232 | 3232 | */ |
| 3233 | - protected function isSelect($query) |
|
| 3234 | - { |
|
| 3235 | - $query = trim($query); |
|
| 3236 | - $select_check = strpos(strtolower($query), strtolower("SELECT")); |
|
| 3237 | - //Checks to see if there is union select which is valid |
|
| 3238 | - $select_check2 = strpos(strtolower($query), strtolower("(SELECT")); |
|
| 3239 | - if($select_check==0 || $select_check2==0){ |
|
| 3240 | - //Returning false means query is ok! |
|
| 3241 | - return true; |
|
| 3242 | - } |
|
| 3243 | - return false; |
|
| 3244 | - } |
|
| 3245 | - |
|
| 3246 | - /** |
|
| 3247 | - * Parse fulltext search query with mysql syntax: |
|
| 3248 | - * terms quoted by "" |
|
| 3249 | - * + means the term must be included |
|
| 3250 | - * - means the term must be excluded |
|
| 3251 | - * * or % at the end means wildcard |
|
| 3252 | - * @param string $query |
|
| 3253 | - * @return array of 3 elements - query terms, mandatory terms and excluded terms |
|
| 3254 | - */ |
|
| 3255 | - public function parseFulltextQuery($query) |
|
| 3256 | - { |
|
| 3257 | - /* split on space or comma, double quotes with \ for escape */ |
|
| 3258 | - if(strpbrk($query, " ,")) { |
|
| 3259 | - // ("([^"]*?)"|[^" ,]+)((, )+)? |
|
| 3260 | - // '/([^" ,]+|".*?[^\\\\]")(,|\s)\s*/' |
|
| 3261 | - if(!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3262 | - return false; |
|
| 3263 | - } |
|
| 3264 | - $qterms = $m[1]; |
|
| 3265 | - } else { |
|
| 3266 | - $qterms = array($query); |
|
| 3267 | - } |
|
| 3268 | - $terms = $must_terms = $not_terms = array(); |
|
| 3269 | - foreach($qterms as $item) { |
|
| 3270 | - if($item[0] == '"') { |
|
| 3271 | - $item = trim($item, '"'); |
|
| 3272 | - } |
|
| 3273 | - if($item[0] == '+') { |
|
| 3233 | + protected function isSelect($query) |
|
| 3234 | + { |
|
| 3235 | + $query = trim($query); |
|
| 3236 | + $select_check = strpos(strtolower($query), strtolower("SELECT")); |
|
| 3237 | + //Checks to see if there is union select which is valid |
|
| 3238 | + $select_check2 = strpos(strtolower($query), strtolower("(SELECT")); |
|
| 3239 | + if($select_check==0 || $select_check2==0){ |
|
| 3240 | + //Returning false means query is ok! |
|
| 3241 | + return true; |
|
| 3242 | + } |
|
| 3243 | + return false; |
|
| 3244 | + } |
|
| 3245 | + |
|
| 3246 | + /** |
|
| 3247 | + * Parse fulltext search query with mysql syntax: |
|
| 3248 | + * terms quoted by "" |
|
| 3249 | + * + means the term must be included |
|
| 3250 | + * - means the term must be excluded |
|
| 3251 | + * * or % at the end means wildcard |
|
| 3252 | + * @param string $query |
|
| 3253 | + * @return array of 3 elements - query terms, mandatory terms and excluded terms |
|
| 3254 | + */ |
|
| 3255 | + public function parseFulltextQuery($query) |
|
| 3256 | + { |
|
| 3257 | + /* split on space or comma, double quotes with \ for escape */ |
|
| 3258 | + if(strpbrk($query, " ,")) { |
|
| 3259 | + // ("([^"]*?)"|[^" ,]+)((, )+)? |
|
| 3260 | + // '/([^" ,]+|".*?[^\\\\]")(,|\s)\s*/' |
|
| 3261 | + if(!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3262 | + return false; |
|
| 3263 | + } |
|
| 3264 | + $qterms = $m[1]; |
|
| 3265 | + } else { |
|
| 3266 | + $qterms = array($query); |
|
| 3267 | + } |
|
| 3268 | + $terms = $must_terms = $not_terms = array(); |
|
| 3269 | + foreach($qterms as $item) { |
|
| 3270 | + if($item[0] == '"') { |
|
| 3271 | + $item = trim($item, '"'); |
|
| 3272 | + } |
|
| 3273 | + if($item[0] == '+') { |
|
| 3274 | 3274 | if (strlen($item) > 1) { |
| 3275 | 3275 | $must_terms[] = substr($item, 1); |
| 3276 | 3276 | } |
| 3277 | 3277 | continue; |
| 3278 | - } |
|
| 3279 | - if($item[0] == '-') { |
|
| 3278 | + } |
|
| 3279 | + if($item[0] == '-') { |
|
| 3280 | 3280 | if (strlen($item) > 1) { |
| 3281 | - $not_terms[] = substr($item, 1); |
|
| 3281 | + $not_terms[] = substr($item, 1); |
|
| 3282 | 3282 | } |
| 3283 | 3283 | continue; |
| 3284 | - } |
|
| 3285 | - $terms[] = $item; |
|
| 3286 | - } |
|
| 3287 | - return array($terms, $must_terms, $not_terms); |
|
| 3288 | - } |
|
| 3284 | + } |
|
| 3285 | + $terms[] = $item; |
|
| 3286 | + } |
|
| 3287 | + return array($terms, $must_terms, $not_terms); |
|
| 3288 | + } |
|
| 3289 | 3289 | |
| 3290 | 3290 | // Methods to check respective queries |
| 3291 | - protected $standardQueries = array( |
|
| 3292 | - 'ALTER TABLE' => 'verifyAlterTable', |
|
| 3293 | - 'DROP TABLE' => 'verifyDropTable', |
|
| 3294 | - 'CREATE TABLE' => 'verifyCreateTable', |
|
| 3295 | - 'INSERT INTO' => 'verifyInsertInto', |
|
| 3296 | - 'UPDATE' => 'verifyUpdate', |
|
| 3297 | - 'DELETE FROM' => 'verifyDeleteFrom', |
|
| 3298 | - ); |
|
| 3291 | + protected $standardQueries = array( |
|
| 3292 | + 'ALTER TABLE' => 'verifyAlterTable', |
|
| 3293 | + 'DROP TABLE' => 'verifyDropTable', |
|
| 3294 | + 'CREATE TABLE' => 'verifyCreateTable', |
|
| 3295 | + 'INSERT INTO' => 'verifyInsertInto', |
|
| 3296 | + 'UPDATE' => 'verifyUpdate', |
|
| 3297 | + 'DELETE FROM' => 'verifyDeleteFrom', |
|
| 3298 | + ); |
|
| 3299 | 3299 | |
| 3300 | 3300 | |
| 3301 | 3301 | /** |
@@ -3303,8 +3303,8 @@ discard block |
||
| 3303 | 3303 | * @param string $query SQL query |
| 3304 | 3304 | * @return string |
| 3305 | 3305 | */ |
| 3306 | - protected function extractTableName($query) |
|
| 3307 | - { |
|
| 3306 | + protected function extractTableName($query) |
|
| 3307 | + { |
|
| 3308 | 3308 | $query = preg_replace('/[^A-Za-z0-9_\s]/', "", $query); |
| 3309 | 3309 | $query = trim(str_replace(array_keys($this->standardQueries), '', $query)); |
| 3310 | 3310 | |
@@ -3313,7 +3313,7 @@ discard block |
||
| 3313 | 3313 | $table = substr($query, 0, $end); |
| 3314 | 3314 | |
| 3315 | 3315 | return $table; |
| 3316 | - } |
|
| 3316 | + } |
|
| 3317 | 3317 | |
| 3318 | 3318 | /** |
| 3319 | 3319 | * Verify SQl statement using per-DB verification function |
@@ -3322,284 +3322,284 @@ discard block |
||
| 3322 | 3322 | * @param array $skipTables List of blacklisted tables that aren't checked |
| 3323 | 3323 | * @return string |
| 3324 | 3324 | */ |
| 3325 | - public function verifySQLStatement($query, $skipTables) |
|
| 3326 | - { |
|
| 3327 | - $query = trim($query); |
|
| 3328 | - foreach($this->standardQueries as $qstart => $check) { |
|
| 3329 | - if(strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | - if(is_callable(array($this, $check))) { |
|
| 3331 | - $table = $this->extractTableName($query); |
|
| 3332 | - if(!in_array($table, $skipTables)) { |
|
| 3333 | - return call_user_func(array($this, $check), $table, $query); |
|
| 3334 | - } else { |
|
| 3335 | - $this->log->debug("Skipping table $table as blacklisted"); |
|
| 3336 | - } |
|
| 3337 | - } else { |
|
| 3338 | - $this->log->debug("No verification for $qstart on {$this->dbType}"); |
|
| 3339 | - } |
|
| 3340 | - break; |
|
| 3341 | - } |
|
| 3342 | - } |
|
| 3343 | - return ""; |
|
| 3344 | - } |
|
| 3345 | - |
|
| 3346 | - /** |
|
| 3347 | - * Tests an CREATE TABLE query |
|
| 3348 | - * @param string $table The table name to get DDL |
|
| 3349 | - * @param string $query The query to test. |
|
| 3350 | - * @return string Non-empty if error found |
|
| 3351 | - */ |
|
| 3352 | - protected function verifyCreateTable($table, $query) |
|
| 3353 | - { |
|
| 3354 | - $this->log->debug('verifying CREATE statement...'); |
|
| 3355 | - |
|
| 3356 | - // rewrite DDL with _temp name |
|
| 3357 | - $this->log->debug('testing query: ['.$query.']'); |
|
| 3358 | - $tempname = $table."__uw_temp"; |
|
| 3359 | - $tempTableQuery = str_replace("CREATE TABLE {$table}", "CREATE TABLE $tempname", $query); |
|
| 3360 | - |
|
| 3361 | - if(strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3362 | - return 'Could not use a temp table to test query!'; |
|
| 3363 | - } |
|
| 3364 | - |
|
| 3365 | - $this->query($tempTableQuery, false, "Preflight Failed for: {$query}"); |
|
| 3366 | - |
|
| 3367 | - $error = $this->lastError(); // empty on no-errors |
|
| 3368 | - if(!empty($error)) { |
|
| 3369 | - return $error; |
|
| 3370 | - } |
|
| 3371 | - |
|
| 3372 | - // check if table exists |
|
| 3373 | - $this->log->debug('testing for table: '.$table); |
|
| 3374 | - if(!$this->tableExists($tempname)) { |
|
| 3375 | - return "Failed to create temp table!"; |
|
| 3376 | - } |
|
| 3377 | - |
|
| 3378 | - $this->dropTableName($tempname); |
|
| 3379 | - return ''; |
|
| 3380 | - } |
|
| 3381 | - |
|
| 3382 | - /** |
|
| 3383 | - * Execute multiple queries one after another |
|
| 3384 | - * @param array $sqls Queries |
|
| 3385 | - * @param bool $dieOnError Die on error, passed to query() |
|
| 3386 | - * @param string $msg Error message, passed to query() |
|
| 3387 | - * @param bool $suppress Supress errors, passed to query() |
|
| 3388 | - * @return resource|bool result set or success/failure bool |
|
| 3389 | - */ |
|
| 3390 | - public function queryArray(array $sqls, $dieOnError = false, $msg = '', $suppress = false) |
|
| 3391 | - { |
|
| 3392 | - $last = true; |
|
| 3393 | - foreach($sqls as $sql) { |
|
| 3394 | - if(!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3395 | - break; |
|
| 3396 | - } |
|
| 3397 | - } |
|
| 3398 | - return $last; |
|
| 3399 | - } |
|
| 3400 | - |
|
| 3401 | - /** |
|
| 3402 | - * Fetches the next row in the query result into an associative array |
|
| 3403 | - * |
|
| 3404 | - * @param resource $result |
|
| 3405 | - * @param bool $encode Need to HTML-encode the result? |
|
| 3406 | - * @return array returns false if there are no more rows available to fetch |
|
| 3407 | - */ |
|
| 3408 | - public function fetchByAssoc($result, $encode = true) |
|
| 3409 | - { |
|
| 3410 | - if (empty($result)) return false; |
|
| 3411 | - |
|
| 3412 | - if(is_int($encode) && func_num_args() == 3) { |
|
| 3413 | - // old API: $result, $rowNum, $encode |
|
| 3414 | - $GLOBALS['log']->deprecated("Using row number in fetchByAssoc is not portable and no longer supported. Please fix your code."); |
|
| 3415 | - $encode = func_get_arg(2); |
|
| 3416 | - } |
|
| 3417 | - $row = $this->fetchRow($result); |
|
| 3418 | - if (!empty($row) && $encode && $this->encode) { |
|
| 3419 | - return array_map('to_html', $row); |
|
| 3420 | - } else { |
|
| 3421 | - return $row; |
|
| 3422 | - } |
|
| 3423 | - } |
|
| 3424 | - |
|
| 3425 | - /** |
|
| 3426 | - * Get DB driver name used for install/upgrade scripts |
|
| 3427 | - * @return string |
|
| 3428 | - */ |
|
| 3429 | - public function getScriptName() |
|
| 3430 | - { |
|
| 3431 | - // Usually the same name as dbType |
|
| 3432 | - return $this->dbType; |
|
| 3433 | - } |
|
| 3434 | - |
|
| 3435 | - /** |
|
| 3436 | - * Set database options |
|
| 3437 | - * Options are usually db-dependant and derive from $config['dbconfigoption'] |
|
| 3438 | - * @param array $options |
|
| 3439 | - * @return DBManager |
|
| 3440 | - */ |
|
| 3441 | - public function setOptions($options) |
|
| 3442 | - { |
|
| 3443 | - $this->options = $options; |
|
| 3444 | - return $this; |
|
| 3445 | - } |
|
| 3446 | - |
|
| 3447 | - /** |
|
| 3448 | - * Get DB options |
|
| 3449 | - * @return array |
|
| 3450 | - */ |
|
| 3451 | - public function getOptions() |
|
| 3452 | - { |
|
| 3453 | - return $this->options; |
|
| 3454 | - } |
|
| 3455 | - |
|
| 3456 | - /** |
|
| 3457 | - * Get DB option by name |
|
| 3458 | - * @param string $option Option name |
|
| 3459 | - * @return mixed Option value or null if doesn't exist |
|
| 3460 | - */ |
|
| 3461 | - public function getOption($option) |
|
| 3462 | - { |
|
| 3463 | - if(isset($this->options[$option])) { |
|
| 3464 | - return $this->options[$option]; |
|
| 3465 | - } |
|
| 3466 | - return null; |
|
| 3467 | - } |
|
| 3468 | - |
|
| 3469 | - /** |
|
| 3470 | - * Commits pending changes to the database when the driver is setup to support transactions. |
|
| 3471 | - * Note that the default implementation is applicable for transaction-less or auto commit scenarios. |
|
| 3472 | - * @abstract |
|
| 3473 | - * @return bool true if commit succeeded, false if it failed |
|
| 3474 | - */ |
|
| 3475 | - public function commit() |
|
| 3476 | - { |
|
| 3477 | - $this->log->info("DBManager.commit() stub"); |
|
| 3478 | - return true; |
|
| 3479 | - } |
|
| 3480 | - |
|
| 3481 | - /** |
|
| 3482 | - * Rollsback pending changes to the database when the driver is setup to support transactions. |
|
| 3483 | - * Note that the default implementation is applicable for transaction-less or auto commit scenarios. |
|
| 3484 | - * Since rollbacks cannot be done, this implementation always returns false. |
|
| 3485 | - * @abstract |
|
| 3486 | - * @return bool true if rollback succeeded, false if it failed |
|
| 3487 | - */ |
|
| 3488 | - public function rollback() |
|
| 3489 | - { |
|
| 3490 | - $this->log->info("DBManager.rollback() stub"); |
|
| 3491 | - return false; |
|
| 3492 | - } |
|
| 3493 | - |
|
| 3494 | - /** |
|
| 3495 | - * Check if this DB name is valid |
|
| 3496 | - * |
|
| 3497 | - * @param string $name |
|
| 3498 | - * @return bool |
|
| 3499 | - */ |
|
| 3500 | - public function isDatabaseNameValid($name) |
|
| 3501 | - { |
|
| 3502 | - // Generic case - no slashes, no dots |
|
| 3503 | - return preg_match('#[/.\\\\]#', $name)==0; |
|
| 3504 | - } |
|
| 3505 | - |
|
| 3506 | - /** |
|
| 3507 | - * Check special requirements for DB installation. |
|
| 3508 | - * @abstract |
|
| 3509 | - * If everything is OK, return true. |
|
| 3510 | - * If something's wrong, return array of error code and parameters |
|
| 3511 | - * @return mixed |
|
| 3512 | - */ |
|
| 3513 | - public function canInstall() |
|
| 3514 | - { |
|
| 3515 | - return true; |
|
| 3516 | - } |
|
| 3517 | - |
|
| 3518 | - /** |
|
| 3519 | - * @abstract |
|
| 3325 | + public function verifySQLStatement($query, $skipTables) |
|
| 3326 | + { |
|
| 3327 | + $query = trim($query); |
|
| 3328 | + foreach($this->standardQueries as $qstart => $check) { |
|
| 3329 | + if(strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | + if(is_callable(array($this, $check))) { |
|
| 3331 | + $table = $this->extractTableName($query); |
|
| 3332 | + if(!in_array($table, $skipTables)) { |
|
| 3333 | + return call_user_func(array($this, $check), $table, $query); |
|
| 3334 | + } else { |
|
| 3335 | + $this->log->debug("Skipping table $table as blacklisted"); |
|
| 3336 | + } |
|
| 3337 | + } else { |
|
| 3338 | + $this->log->debug("No verification for $qstart on {$this->dbType}"); |
|
| 3339 | + } |
|
| 3340 | + break; |
|
| 3341 | + } |
|
| 3342 | + } |
|
| 3343 | + return ""; |
|
| 3344 | + } |
|
| 3345 | + |
|
| 3346 | + /** |
|
| 3347 | + * Tests an CREATE TABLE query |
|
| 3348 | + * @param string $table The table name to get DDL |
|
| 3349 | + * @param string $query The query to test. |
|
| 3350 | + * @return string Non-empty if error found |
|
| 3351 | + */ |
|
| 3352 | + protected function verifyCreateTable($table, $query) |
|
| 3353 | + { |
|
| 3354 | + $this->log->debug('verifying CREATE statement...'); |
|
| 3355 | + |
|
| 3356 | + // rewrite DDL with _temp name |
|
| 3357 | + $this->log->debug('testing query: ['.$query.']'); |
|
| 3358 | + $tempname = $table."__uw_temp"; |
|
| 3359 | + $tempTableQuery = str_replace("CREATE TABLE {$table}", "CREATE TABLE $tempname", $query); |
|
| 3360 | + |
|
| 3361 | + if(strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3362 | + return 'Could not use a temp table to test query!'; |
|
| 3363 | + } |
|
| 3364 | + |
|
| 3365 | + $this->query($tempTableQuery, false, "Preflight Failed for: {$query}"); |
|
| 3366 | + |
|
| 3367 | + $error = $this->lastError(); // empty on no-errors |
|
| 3368 | + if(!empty($error)) { |
|
| 3369 | + return $error; |
|
| 3370 | + } |
|
| 3371 | + |
|
| 3372 | + // check if table exists |
|
| 3373 | + $this->log->debug('testing for table: '.$table); |
|
| 3374 | + if(!$this->tableExists($tempname)) { |
|
| 3375 | + return "Failed to create temp table!"; |
|
| 3376 | + } |
|
| 3377 | + |
|
| 3378 | + $this->dropTableName($tempname); |
|
| 3379 | + return ''; |
|
| 3380 | + } |
|
| 3381 | + |
|
| 3382 | + /** |
|
| 3383 | + * Execute multiple queries one after another |
|
| 3384 | + * @param array $sqls Queries |
|
| 3385 | + * @param bool $dieOnError Die on error, passed to query() |
|
| 3386 | + * @param string $msg Error message, passed to query() |
|
| 3387 | + * @param bool $suppress Supress errors, passed to query() |
|
| 3388 | + * @return resource|bool result set or success/failure bool |
|
| 3389 | + */ |
|
| 3390 | + public function queryArray(array $sqls, $dieOnError = false, $msg = '', $suppress = false) |
|
| 3391 | + { |
|
| 3392 | + $last = true; |
|
| 3393 | + foreach($sqls as $sql) { |
|
| 3394 | + if(!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3395 | + break; |
|
| 3396 | + } |
|
| 3397 | + } |
|
| 3398 | + return $last; |
|
| 3399 | + } |
|
| 3400 | + |
|
| 3401 | + /** |
|
| 3402 | + * Fetches the next row in the query result into an associative array |
|
| 3403 | + * |
|
| 3404 | + * @param resource $result |
|
| 3405 | + * @param bool $encode Need to HTML-encode the result? |
|
| 3406 | + * @return array returns false if there are no more rows available to fetch |
|
| 3407 | + */ |
|
| 3408 | + public function fetchByAssoc($result, $encode = true) |
|
| 3409 | + { |
|
| 3410 | + if (empty($result)) return false; |
|
| 3411 | + |
|
| 3412 | + if(is_int($encode) && func_num_args() == 3) { |
|
| 3413 | + // old API: $result, $rowNum, $encode |
|
| 3414 | + $GLOBALS['log']->deprecated("Using row number in fetchByAssoc is not portable and no longer supported. Please fix your code."); |
|
| 3415 | + $encode = func_get_arg(2); |
|
| 3416 | + } |
|
| 3417 | + $row = $this->fetchRow($result); |
|
| 3418 | + if (!empty($row) && $encode && $this->encode) { |
|
| 3419 | + return array_map('to_html', $row); |
|
| 3420 | + } else { |
|
| 3421 | + return $row; |
|
| 3422 | + } |
|
| 3423 | + } |
|
| 3424 | + |
|
| 3425 | + /** |
|
| 3426 | + * Get DB driver name used for install/upgrade scripts |
|
| 3427 | + * @return string |
|
| 3428 | + */ |
|
| 3429 | + public function getScriptName() |
|
| 3430 | + { |
|
| 3431 | + // Usually the same name as dbType |
|
| 3432 | + return $this->dbType; |
|
| 3433 | + } |
|
| 3434 | + |
|
| 3435 | + /** |
|
| 3436 | + * Set database options |
|
| 3437 | + * Options are usually db-dependant and derive from $config['dbconfigoption'] |
|
| 3438 | + * @param array $options |
|
| 3439 | + * @return DBManager |
|
| 3440 | + */ |
|
| 3441 | + public function setOptions($options) |
|
| 3442 | + { |
|
| 3443 | + $this->options = $options; |
|
| 3444 | + return $this; |
|
| 3445 | + } |
|
| 3446 | + |
|
| 3447 | + /** |
|
| 3448 | + * Get DB options |
|
| 3449 | + * @return array |
|
| 3450 | + */ |
|
| 3451 | + public function getOptions() |
|
| 3452 | + { |
|
| 3453 | + return $this->options; |
|
| 3454 | + } |
|
| 3455 | + |
|
| 3456 | + /** |
|
| 3457 | + * Get DB option by name |
|
| 3458 | + * @param string $option Option name |
|
| 3459 | + * @return mixed Option value or null if doesn't exist |
|
| 3460 | + */ |
|
| 3461 | + public function getOption($option) |
|
| 3462 | + { |
|
| 3463 | + if(isset($this->options[$option])) { |
|
| 3464 | + return $this->options[$option]; |
|
| 3465 | + } |
|
| 3466 | + return null; |
|
| 3467 | + } |
|
| 3468 | + |
|
| 3469 | + /** |
|
| 3470 | + * Commits pending changes to the database when the driver is setup to support transactions. |
|
| 3471 | + * Note that the default implementation is applicable for transaction-less or auto commit scenarios. |
|
| 3472 | + * @abstract |
|
| 3473 | + * @return bool true if commit succeeded, false if it failed |
|
| 3474 | + */ |
|
| 3475 | + public function commit() |
|
| 3476 | + { |
|
| 3477 | + $this->log->info("DBManager.commit() stub"); |
|
| 3478 | + return true; |
|
| 3479 | + } |
|
| 3480 | + |
|
| 3481 | + /** |
|
| 3482 | + * Rollsback pending changes to the database when the driver is setup to support transactions. |
|
| 3483 | + * Note that the default implementation is applicable for transaction-less or auto commit scenarios. |
|
| 3484 | + * Since rollbacks cannot be done, this implementation always returns false. |
|
| 3485 | + * @abstract |
|
| 3486 | + * @return bool true if rollback succeeded, false if it failed |
|
| 3487 | + */ |
|
| 3488 | + public function rollback() |
|
| 3489 | + { |
|
| 3490 | + $this->log->info("DBManager.rollback() stub"); |
|
| 3491 | + return false; |
|
| 3492 | + } |
|
| 3493 | + |
|
| 3494 | + /** |
|
| 3495 | + * Check if this DB name is valid |
|
| 3496 | + * |
|
| 3497 | + * @param string $name |
|
| 3498 | + * @return bool |
|
| 3499 | + */ |
|
| 3500 | + public function isDatabaseNameValid($name) |
|
| 3501 | + { |
|
| 3502 | + // Generic case - no slashes, no dots |
|
| 3503 | + return preg_match('#[/.\\\\]#', $name)==0; |
|
| 3504 | + } |
|
| 3505 | + |
|
| 3506 | + /** |
|
| 3507 | + * Check special requirements for DB installation. |
|
| 3508 | + * @abstract |
|
| 3509 | + * If everything is OK, return true. |
|
| 3510 | + * If something's wrong, return array of error code and parameters |
|
| 3511 | + * @return mixed |
|
| 3512 | + */ |
|
| 3513 | + public function canInstall() |
|
| 3514 | + { |
|
| 3515 | + return true; |
|
| 3516 | + } |
|
| 3517 | + |
|
| 3518 | + /** |
|
| 3519 | + * @abstract |
|
| 3520 | 3520 | * Code run on new database before installing |
| 3521 | - */ |
|
| 3522 | - public function preInstall() |
|
| 3523 | - { |
|
| 3524 | - } |
|
| 3521 | + */ |
|
| 3522 | + public function preInstall() |
|
| 3523 | + { |
|
| 3524 | + } |
|
| 3525 | + |
|
| 3526 | + /** |
|
| 3527 | + * @abstract |
|
| 3528 | + * Code run on new database after installing |
|
| 3529 | + */ |
|
| 3530 | + public function postInstall() |
|
| 3531 | + { |
|
| 3532 | + } |
|
| 3533 | + |
|
| 3534 | + /** |
|
| 3535 | + * Disable keys on the table |
|
| 3536 | + * @abstract |
|
| 3537 | + * @param string $tableName |
|
| 3538 | + */ |
|
| 3539 | + public function disableKeys($tableName) |
|
| 3540 | + { |
|
| 3541 | + } |
|
| 3525 | 3542 | |
| 3526 | - /** |
|
| 3543 | + /** |
|
| 3544 | + * Re-enable keys on the table |
|
| 3527 | 3545 | * @abstract |
| 3528 | - * Code run on new database after installing |
|
| 3529 | - */ |
|
| 3530 | - public function postInstall() |
|
| 3531 | - { |
|
| 3532 | - } |
|
| 3533 | - |
|
| 3534 | - /** |
|
| 3535 | - * Disable keys on the table |
|
| 3536 | - * @abstract |
|
| 3537 | - * @param string $tableName |
|
| 3538 | - */ |
|
| 3539 | - public function disableKeys($tableName) |
|
| 3540 | - { |
|
| 3541 | - } |
|
| 3542 | - |
|
| 3543 | - /** |
|
| 3544 | - * Re-enable keys on the table |
|
| 3545 | - * @abstract |
|
| 3546 | - * @param string $tableName |
|
| 3547 | - */ |
|
| 3548 | - public function enableKeys($tableName) |
|
| 3549 | - { |
|
| 3550 | - } |
|
| 3551 | - |
|
| 3552 | - /** |
|
| 3553 | - * Quote string in DB-specific manner |
|
| 3554 | - * @param string $string |
|
| 3555 | - * @return string |
|
| 3556 | - */ |
|
| 3557 | - abstract public function quote($string); |
|
| 3546 | + * @param string $tableName |
|
| 3547 | + */ |
|
| 3548 | + public function enableKeys($tableName) |
|
| 3549 | + { |
|
| 3550 | + } |
|
| 3551 | + |
|
| 3552 | + /** |
|
| 3553 | + * Quote string in DB-specific manner |
|
| 3554 | + * @param string $string |
|
| 3555 | + * @return string |
|
| 3556 | + */ |
|
| 3557 | + abstract public function quote($string); |
|
| 3558 | 3558 | |
| 3559 | 3559 | abstract public function quoteIdentifier($string); |
| 3560 | 3560 | |
| 3561 | - /** |
|
| 3562 | - * Use when you need to convert a database string to a different value; this function does it in a |
|
| 3563 | - * database-backend aware way |
|
| 3564 | - * Supported conversions: |
|
| 3565 | - * today return current date |
|
| 3566 | - * left Take substring from the left |
|
| 3567 | - * date_format Format date as string, supports %Y-%m-%d, %Y-%m, %Y |
|
| 3561 | + /** |
|
| 3562 | + * Use when you need to convert a database string to a different value; this function does it in a |
|
| 3563 | + * database-backend aware way |
|
| 3564 | + * Supported conversions: |
|
| 3565 | + * today return current date |
|
| 3566 | + * left Take substring from the left |
|
| 3567 | + * date_format Format date as string, supports %Y-%m-%d, %Y-%m, %Y |
|
| 3568 | 3568 | * time_format Format time as string |
| 3569 | 3569 | * date Convert date string to datetime value |
| 3570 | 3570 | * time Convert time string to datetime value |
| 3571 | - * datetime Convert datetime string to datetime value |
|
| 3572 | - * ifnull If var is null, use default value |
|
| 3573 | - * concat Concatenate strings |
|
| 3574 | - * quarter Quarter number of the date |
|
| 3575 | - * length Length of string |
|
| 3576 | - * month Month number of the date |
|
| 3577 | - * add_date Add specified interval to a date |
|
| 3571 | + * datetime Convert datetime string to datetime value |
|
| 3572 | + * ifnull If var is null, use default value |
|
| 3573 | + * concat Concatenate strings |
|
| 3574 | + * quarter Quarter number of the date |
|
| 3575 | + * length Length of string |
|
| 3576 | + * month Month number of the date |
|
| 3577 | + * add_date Add specified interval to a date |
|
| 3578 | 3578 | * add_time Add time interval to a date |
| 3579 | 3579 | * text2char Convert text field to varchar |
| 3580 | - * |
|
| 3581 | - * @param string $string database string to convert |
|
| 3582 | - * @param string $type type of conversion to do |
|
| 3583 | - * @param array $additional_parameters optional, additional parameters to pass to the db function |
|
| 3584 | - * @return string |
|
| 3585 | - */ |
|
| 3586 | - abstract public function convert($string, $type, array $additional_parameters = array()); |
|
| 3587 | - |
|
| 3588 | - /** |
|
| 3589 | - * Converts from Database data to app data |
|
| 3590 | - * |
|
| 3591 | - * Supported types |
|
| 3592 | - * - date |
|
| 3593 | - * - time |
|
| 3594 | - * - datetime |
|
| 3580 | + * |
|
| 3581 | + * @param string $string database string to convert |
|
| 3582 | + * @param string $type type of conversion to do |
|
| 3583 | + * @param array $additional_parameters optional, additional parameters to pass to the db function |
|
| 3584 | + * @return string |
|
| 3585 | + */ |
|
| 3586 | + abstract public function convert($string, $type, array $additional_parameters = array()); |
|
| 3587 | + |
|
| 3588 | + /** |
|
| 3589 | + * Converts from Database data to app data |
|
| 3590 | + * |
|
| 3591 | + * Supported types |
|
| 3592 | + * - date |
|
| 3593 | + * - time |
|
| 3594 | + * - datetime |
|
| 3595 | 3595 | * - datetimecombo |
| 3596 | 3596 | * - timestamp |
| 3597 | - * |
|
| 3598 | - * @param string $string database string to convert |
|
| 3599 | - * @param string $type type of conversion to do |
|
| 3600 | - * @return string |
|
| 3601 | - */ |
|
| 3602 | - abstract public function fromConvert($string, $type); |
|
| 3597 | + * |
|
| 3598 | + * @param string $string database string to convert |
|
| 3599 | + * @param string $type type of conversion to do |
|
| 3600 | + * @return string |
|
| 3601 | + */ |
|
| 3602 | + abstract public function fromConvert($string, $type); |
|
| 3603 | 3603 | |
| 3604 | 3604 | /** |
| 3605 | 3605 | * Parses and runs queries |
@@ -3611,7 +3611,7 @@ discard block |
||
| 3611 | 3611 | * @param bool $keepResult Keep query result in the object? |
| 3612 | 3612 | * @return resource|bool result set or success/failure bool |
| 3613 | 3613 | */ |
| 3614 | - abstract public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false); |
|
| 3614 | + abstract public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false); |
|
| 3615 | 3615 | |
| 3616 | 3616 | /** |
| 3617 | 3617 | * Runs a limit query: one where we specify where to start getting records and how many to get |
@@ -3624,173 +3624,173 @@ discard block |
||
| 3624 | 3624 | * @param bool $execute Execute or return SQL? |
| 3625 | 3625 | * @return resource query result |
| 3626 | 3626 | */ |
| 3627 | - abstract function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true); |
|
| 3628 | - |
|
| 3629 | - |
|
| 3630 | - /** |
|
| 3631 | - * Free Database result |
|
| 3632 | - * @param resource $dbResult |
|
| 3633 | - */ |
|
| 3634 | - abstract protected function freeDbResult($dbResult); |
|
| 3635 | - |
|
| 3636 | - /** |
|
| 3637 | - * Rename column in the DB |
|
| 3638 | - * @param string $tablename |
|
| 3639 | - * @param string $column |
|
| 3640 | - * @param string $newname |
|
| 3641 | - */ |
|
| 3642 | - abstract function renameColumnSQL($tablename, $column, $newname); |
|
| 3643 | - |
|
| 3644 | - /** |
|
| 3645 | - * Returns definitions of all indies for passed table. |
|
| 3646 | - * |
|
| 3647 | - * return will is a multi-dimensional array that |
|
| 3648 | - * categorizes the index definition by types, unique, primary and index. |
|
| 3649 | - * <code> |
|
| 3650 | - * <?php |
|
| 3651 | - * array( O |
|
| 3652 | - * 'index1'=> array ( |
|
| 3653 | - * 'name' => 'index1', |
|
| 3654 | - * 'type' => 'primary', |
|
| 3655 | - * 'fields' => array('field1','field2') |
|
| 3656 | - * ) |
|
| 3657 | - * ) |
|
| 3658 | - * ?> |
|
| 3659 | - * </code> |
|
| 3660 | - * This format is similar to how indicies are defined in vardef file. |
|
| 3661 | - * |
|
| 3662 | - * @param string $tablename |
|
| 3663 | - * @return array |
|
| 3664 | - */ |
|
| 3665 | - abstract public function get_indices($tablename); |
|
| 3666 | - |
|
| 3667 | - /** |
|
| 3668 | - * Returns definitions of all indies for passed table. |
|
| 3669 | - * |
|
| 3670 | - * return will is a multi-dimensional array that |
|
| 3671 | - * categorizes the index definition by types, unique, primary and index. |
|
| 3672 | - * <code> |
|
| 3673 | - * <?php |
|
| 3674 | - * array( |
|
| 3675 | - * 'field1'=> array ( |
|
| 3676 | - * 'name' => 'field1', |
|
| 3677 | - * 'type' => 'varchar', |
|
| 3678 | - * 'len' => '200' |
|
| 3679 | - * ) |
|
| 3680 | - * ) |
|
| 3681 | - * ?> |
|
| 3682 | - * </code> |
|
| 3683 | - * This format is similar to how indicies are defined in vardef file. |
|
| 3684 | - * |
|
| 3685 | - * @param string $tablename |
|
| 3686 | - * @return array |
|
| 3687 | - */ |
|
| 3688 | - abstract public function get_columns($tablename); |
|
| 3689 | - |
|
| 3690 | - /** |
|
| 3691 | - * Generates alter constraint statement given a table name and vardef definition. |
|
| 3692 | - * |
|
| 3693 | - * Supports both adding and droping a constraint. |
|
| 3694 | - * |
|
| 3695 | - * @param string $table tablename |
|
| 3696 | - * @param array $definition field definition |
|
| 3697 | - * @param bool $drop true if we are dropping the constraint, false if we are adding it |
|
| 3698 | - * @return string SQL statement |
|
| 3699 | - */ |
|
| 3700 | - abstract public function add_drop_constraint($table, $definition, $drop = false); |
|
| 3701 | - |
|
| 3702 | - /** |
|
| 3703 | - * Returns the description of fields based on the result |
|
| 3704 | - * |
|
| 3705 | - * @param resource $result |
|
| 3706 | - * @param boolean $make_lower_case |
|
| 3707 | - * @return array field array |
|
| 3708 | - */ |
|
| 3709 | - abstract public function getFieldsArray($result, $make_lower_case = false); |
|
| 3710 | - |
|
| 3711 | - /** |
|
| 3712 | - * Returns an array of tables for this database |
|
| 3713 | - * |
|
| 3714 | - * @return array|false an array of with table names, false if no tables found |
|
| 3715 | - */ |
|
| 3716 | - abstract public function getTablesArray(); |
|
| 3717 | - |
|
| 3718 | - /** |
|
| 3719 | - * Return's the version of the database |
|
| 3720 | - * |
|
| 3721 | - * @return string |
|
| 3722 | - */ |
|
| 3723 | - abstract public function version(); |
|
| 3724 | - |
|
| 3725 | - /** |
|
| 3726 | - * Checks if a table with the name $tableName exists |
|
| 3727 | - * and returns true if it does or false otherwise |
|
| 3728 | - * |
|
| 3729 | - * @param string $tableName |
|
| 3730 | - * @return bool |
|
| 3731 | - */ |
|
| 3732 | - abstract public function tableExists($tableName); |
|
| 3733 | - |
|
| 3734 | - /** |
|
| 3735 | - * Fetches the next row in the query result into an associative array |
|
| 3736 | - * |
|
| 3737 | - * @param resource $result |
|
| 3738 | - * @return array returns false if there are no more rows available to fetch |
|
| 3739 | - */ |
|
| 3740 | - abstract public function fetchRow($result); |
|
| 3741 | - |
|
| 3742 | - /** |
|
| 3743 | - * Connects to the database backend |
|
| 3744 | - * |
|
| 3745 | - * Takes in the database settings and opens a database connection based on those |
|
| 3746 | - * will open either a persistent or non-persistent connection. |
|
| 3747 | - * If a persistent connection is desired but not available it will defualt to non-persistent |
|
| 3748 | - * |
|
| 3749 | - * configOptions must include |
|
| 3750 | - * db_host_name - server ip |
|
| 3751 | - * db_user_name - database user name |
|
| 3752 | - * db_password - database password |
|
| 3753 | - * |
|
| 3754 | - * @param array $configOptions |
|
| 3755 | - * @param boolean $dieOnError |
|
| 3756 | - */ |
|
| 3757 | - abstract public function connect(array $configOptions = null, $dieOnError = false); |
|
| 3758 | - |
|
| 3759 | - /** |
|
| 3760 | - * Generates sql for create table statement for a bean. |
|
| 3761 | - * |
|
| 3762 | - * @param string $tablename |
|
| 3763 | - * @param array $fieldDefs |
|
| 3764 | - * @param array $indices |
|
| 3765 | - * @return string SQL Create Table statement |
|
| 3766 | - */ |
|
| 3767 | - abstract public function createTableSQLParams($tablename, $fieldDefs, $indices); |
|
| 3768 | - |
|
| 3769 | - /** |
|
| 3770 | - * Generates the SQL for changing columns |
|
| 3771 | - * |
|
| 3772 | - * @param string $tablename |
|
| 3773 | - * @param array $fieldDefs |
|
| 3774 | - * @param string $action |
|
| 3775 | - * @param bool $ignoreRequired Optional, true if we should ignor this being a required field |
|
| 3776 | - * @return string|array |
|
| 3777 | - */ |
|
| 3778 | - abstract protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false); |
|
| 3779 | - |
|
| 3780 | - /** |
|
| 3781 | - * Disconnects from the database |
|
| 3782 | - * |
|
| 3783 | - * Also handles any cleanup needed |
|
| 3784 | - */ |
|
| 3785 | - abstract public function disconnect(); |
|
| 3786 | - |
|
| 3787 | - /** |
|
| 3788 | - * Get last database error |
|
| 3789 | - * This function should return last error as reported by DB driver |
|
| 3790 | - * and should return false if no error condition happened |
|
| 3791 | - * @return string|false Error message or false if no error happened |
|
| 3792 | - */ |
|
| 3793 | - abstract public function lastDbError(); |
|
| 3627 | + abstract function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true); |
|
| 3628 | + |
|
| 3629 | + |
|
| 3630 | + /** |
|
| 3631 | + * Free Database result |
|
| 3632 | + * @param resource $dbResult |
|
| 3633 | + */ |
|
| 3634 | + abstract protected function freeDbResult($dbResult); |
|
| 3635 | + |
|
| 3636 | + /** |
|
| 3637 | + * Rename column in the DB |
|
| 3638 | + * @param string $tablename |
|
| 3639 | + * @param string $column |
|
| 3640 | + * @param string $newname |
|
| 3641 | + */ |
|
| 3642 | + abstract function renameColumnSQL($tablename, $column, $newname); |
|
| 3643 | + |
|
| 3644 | + /** |
|
| 3645 | + * Returns definitions of all indies for passed table. |
|
| 3646 | + * |
|
| 3647 | + * return will is a multi-dimensional array that |
|
| 3648 | + * categorizes the index definition by types, unique, primary and index. |
|
| 3649 | + * <code> |
|
| 3650 | + * <?php |
|
| 3651 | + * array( O |
|
| 3652 | + * 'index1'=> array ( |
|
| 3653 | + * 'name' => 'index1', |
|
| 3654 | + * 'type' => 'primary', |
|
| 3655 | + * 'fields' => array('field1','field2') |
|
| 3656 | + * ) |
|
| 3657 | + * ) |
|
| 3658 | + * ?> |
|
| 3659 | + * </code> |
|
| 3660 | + * This format is similar to how indicies are defined in vardef file. |
|
| 3661 | + * |
|
| 3662 | + * @param string $tablename |
|
| 3663 | + * @return array |
|
| 3664 | + */ |
|
| 3665 | + abstract public function get_indices($tablename); |
|
| 3666 | + |
|
| 3667 | + /** |
|
| 3668 | + * Returns definitions of all indies for passed table. |
|
| 3669 | + * |
|
| 3670 | + * return will is a multi-dimensional array that |
|
| 3671 | + * categorizes the index definition by types, unique, primary and index. |
|
| 3672 | + * <code> |
|
| 3673 | + * <?php |
|
| 3674 | + * array( |
|
| 3675 | + * 'field1'=> array ( |
|
| 3676 | + * 'name' => 'field1', |
|
| 3677 | + * 'type' => 'varchar', |
|
| 3678 | + * 'len' => '200' |
|
| 3679 | + * ) |
|
| 3680 | + * ) |
|
| 3681 | + * ?> |
|
| 3682 | + * </code> |
|
| 3683 | + * This format is similar to how indicies are defined in vardef file. |
|
| 3684 | + * |
|
| 3685 | + * @param string $tablename |
|
| 3686 | + * @return array |
|
| 3687 | + */ |
|
| 3688 | + abstract public function get_columns($tablename); |
|
| 3689 | + |
|
| 3690 | + /** |
|
| 3691 | + * Generates alter constraint statement given a table name and vardef definition. |
|
| 3692 | + * |
|
| 3693 | + * Supports both adding and droping a constraint. |
|
| 3694 | + * |
|
| 3695 | + * @param string $table tablename |
|
| 3696 | + * @param array $definition field definition |
|
| 3697 | + * @param bool $drop true if we are dropping the constraint, false if we are adding it |
|
| 3698 | + * @return string SQL statement |
|
| 3699 | + */ |
|
| 3700 | + abstract public function add_drop_constraint($table, $definition, $drop = false); |
|
| 3701 | + |
|
| 3702 | + /** |
|
| 3703 | + * Returns the description of fields based on the result |
|
| 3704 | + * |
|
| 3705 | + * @param resource $result |
|
| 3706 | + * @param boolean $make_lower_case |
|
| 3707 | + * @return array field array |
|
| 3708 | + */ |
|
| 3709 | + abstract public function getFieldsArray($result, $make_lower_case = false); |
|
| 3710 | + |
|
| 3711 | + /** |
|
| 3712 | + * Returns an array of tables for this database |
|
| 3713 | + * |
|
| 3714 | + * @return array|false an array of with table names, false if no tables found |
|
| 3715 | + */ |
|
| 3716 | + abstract public function getTablesArray(); |
|
| 3717 | + |
|
| 3718 | + /** |
|
| 3719 | + * Return's the version of the database |
|
| 3720 | + * |
|
| 3721 | + * @return string |
|
| 3722 | + */ |
|
| 3723 | + abstract public function version(); |
|
| 3724 | + |
|
| 3725 | + /** |
|
| 3726 | + * Checks if a table with the name $tableName exists |
|
| 3727 | + * and returns true if it does or false otherwise |
|
| 3728 | + * |
|
| 3729 | + * @param string $tableName |
|
| 3730 | + * @return bool |
|
| 3731 | + */ |
|
| 3732 | + abstract public function tableExists($tableName); |
|
| 3733 | + |
|
| 3734 | + /** |
|
| 3735 | + * Fetches the next row in the query result into an associative array |
|
| 3736 | + * |
|
| 3737 | + * @param resource $result |
|
| 3738 | + * @return array returns false if there are no more rows available to fetch |
|
| 3739 | + */ |
|
| 3740 | + abstract public function fetchRow($result); |
|
| 3741 | + |
|
| 3742 | + /** |
|
| 3743 | + * Connects to the database backend |
|
| 3744 | + * |
|
| 3745 | + * Takes in the database settings and opens a database connection based on those |
|
| 3746 | + * will open either a persistent or non-persistent connection. |
|
| 3747 | + * If a persistent connection is desired but not available it will defualt to non-persistent |
|
| 3748 | + * |
|
| 3749 | + * configOptions must include |
|
| 3750 | + * db_host_name - server ip |
|
| 3751 | + * db_user_name - database user name |
|
| 3752 | + * db_password - database password |
|
| 3753 | + * |
|
| 3754 | + * @param array $configOptions |
|
| 3755 | + * @param boolean $dieOnError |
|
| 3756 | + */ |
|
| 3757 | + abstract public function connect(array $configOptions = null, $dieOnError = false); |
|
| 3758 | + |
|
| 3759 | + /** |
|
| 3760 | + * Generates sql for create table statement for a bean. |
|
| 3761 | + * |
|
| 3762 | + * @param string $tablename |
|
| 3763 | + * @param array $fieldDefs |
|
| 3764 | + * @param array $indices |
|
| 3765 | + * @return string SQL Create Table statement |
|
| 3766 | + */ |
|
| 3767 | + abstract public function createTableSQLParams($tablename, $fieldDefs, $indices); |
|
| 3768 | + |
|
| 3769 | + /** |
|
| 3770 | + * Generates the SQL for changing columns |
|
| 3771 | + * |
|
| 3772 | + * @param string $tablename |
|
| 3773 | + * @param array $fieldDefs |
|
| 3774 | + * @param string $action |
|
| 3775 | + * @param bool $ignoreRequired Optional, true if we should ignor this being a required field |
|
| 3776 | + * @return string|array |
|
| 3777 | + */ |
|
| 3778 | + abstract protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false); |
|
| 3779 | + |
|
| 3780 | + /** |
|
| 3781 | + * Disconnects from the database |
|
| 3782 | + * |
|
| 3783 | + * Also handles any cleanup needed |
|
| 3784 | + */ |
|
| 3785 | + abstract public function disconnect(); |
|
| 3786 | + |
|
| 3787 | + /** |
|
| 3788 | + * Get last database error |
|
| 3789 | + * This function should return last error as reported by DB driver |
|
| 3790 | + * and should return false if no error condition happened |
|
| 3791 | + * @return string|false Error message or false if no error happened |
|
| 3792 | + */ |
|
| 3793 | + abstract public function lastDbError(); |
|
| 3794 | 3794 | |
| 3795 | 3795 | /** |
| 3796 | 3796 | * Check if this query is valid |
@@ -3798,82 +3798,82 @@ discard block |
||
| 3798 | 3798 | * @param string $query |
| 3799 | 3799 | * @return bool |
| 3800 | 3800 | */ |
| 3801 | - abstract public function validateQuery($query); |
|
| 3802 | - |
|
| 3803 | - /** |
|
| 3804 | - * Check if this driver can be used |
|
| 3805 | - * @return bool |
|
| 3806 | - */ |
|
| 3807 | - abstract public function valid(); |
|
| 3808 | - |
|
| 3809 | - /** |
|
| 3810 | - * Check if certain database exists |
|
| 3811 | - * @param string $dbname |
|
| 3812 | - */ |
|
| 3813 | - abstract public function dbExists($dbname); |
|
| 3814 | - |
|
| 3815 | - /** |
|
| 3816 | - * Get tables like expression |
|
| 3817 | - * @param string $like Expression describing tables |
|
| 3818 | - * @return array |
|
| 3819 | - */ |
|
| 3820 | - abstract public function tablesLike($like); |
|
| 3821 | - |
|
| 3822 | - /** |
|
| 3823 | - * Create a database |
|
| 3824 | - * @param string $dbname |
|
| 3825 | - */ |
|
| 3826 | - abstract public function createDatabase($dbname); |
|
| 3827 | - |
|
| 3828 | - /** |
|
| 3829 | - * Drop a database |
|
| 3830 | - * @param string $dbname |
|
| 3831 | - */ |
|
| 3832 | - abstract public function dropDatabase($dbname); |
|
| 3833 | - |
|
| 3834 | - /** |
|
| 3835 | - * Get database configuration information (DB-dependent) |
|
| 3836 | - * @return array|null |
|
| 3837 | - */ |
|
| 3838 | - abstract public function getDbInfo(); |
|
| 3839 | - |
|
| 3840 | - /** |
|
| 3841 | - * Check if certain DB user exists |
|
| 3842 | - * @param string $username |
|
| 3843 | - */ |
|
| 3844 | - abstract public function userExists($username); |
|
| 3845 | - |
|
| 3846 | - /** |
|
| 3847 | - * Create DB user |
|
| 3848 | - * @param string $database_name |
|
| 3849 | - * @param string $host_name |
|
| 3850 | - * @param string $user |
|
| 3851 | - * @param string $password |
|
| 3852 | - */ |
|
| 3853 | - abstract public function createDbUser($database_name, $host_name, $user, $password); |
|
| 3854 | - |
|
| 3855 | - /** |
|
| 3856 | - * Check if the database supports fulltext indexing |
|
| 3857 | - * Note that database driver can be capable of supporting FT (see supports('fulltext)) |
|
| 3858 | - * but particular instance can still have it disabled |
|
| 3859 | - * @return bool |
|
| 3860 | - */ |
|
| 3861 | - abstract public function full_text_indexing_installed(); |
|
| 3862 | - |
|
| 3863 | - /** |
|
| 3864 | - * Generate fulltext query from set of terms |
|
| 3865 | - * @param string $field Field to search against |
|
| 3866 | - * @param array $terms Search terms that may be or not be in the result |
|
| 3867 | - * @param array $must_terms Search terms that have to be in the result |
|
| 3868 | - * @param array $exclude_terms Search terms that have to be not in the result |
|
| 3869 | - */ |
|
| 3870 | - abstract public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()); |
|
| 3871 | - |
|
| 3872 | - /** |
|
| 3873 | - * Get install configuration for this DB |
|
| 3874 | - * @return array |
|
| 3875 | - */ |
|
| 3876 | - abstract public function installConfig(); |
|
| 3801 | + abstract public function validateQuery($query); |
|
| 3802 | + |
|
| 3803 | + /** |
|
| 3804 | + * Check if this driver can be used |
|
| 3805 | + * @return bool |
|
| 3806 | + */ |
|
| 3807 | + abstract public function valid(); |
|
| 3808 | + |
|
| 3809 | + /** |
|
| 3810 | + * Check if certain database exists |
|
| 3811 | + * @param string $dbname |
|
| 3812 | + */ |
|
| 3813 | + abstract public function dbExists($dbname); |
|
| 3814 | + |
|
| 3815 | + /** |
|
| 3816 | + * Get tables like expression |
|
| 3817 | + * @param string $like Expression describing tables |
|
| 3818 | + * @return array |
|
| 3819 | + */ |
|
| 3820 | + abstract public function tablesLike($like); |
|
| 3821 | + |
|
| 3822 | + /** |
|
| 3823 | + * Create a database |
|
| 3824 | + * @param string $dbname |
|
| 3825 | + */ |
|
| 3826 | + abstract public function createDatabase($dbname); |
|
| 3827 | + |
|
| 3828 | + /** |
|
| 3829 | + * Drop a database |
|
| 3830 | + * @param string $dbname |
|
| 3831 | + */ |
|
| 3832 | + abstract public function dropDatabase($dbname); |
|
| 3833 | + |
|
| 3834 | + /** |
|
| 3835 | + * Get database configuration information (DB-dependent) |
|
| 3836 | + * @return array|null |
|
| 3837 | + */ |
|
| 3838 | + abstract public function getDbInfo(); |
|
| 3839 | + |
|
| 3840 | + /** |
|
| 3841 | + * Check if certain DB user exists |
|
| 3842 | + * @param string $username |
|
| 3843 | + */ |
|
| 3844 | + abstract public function userExists($username); |
|
| 3845 | + |
|
| 3846 | + /** |
|
| 3847 | + * Create DB user |
|
| 3848 | + * @param string $database_name |
|
| 3849 | + * @param string $host_name |
|
| 3850 | + * @param string $user |
|
| 3851 | + * @param string $password |
|
| 3852 | + */ |
|
| 3853 | + abstract public function createDbUser($database_name, $host_name, $user, $password); |
|
| 3854 | + |
|
| 3855 | + /** |
|
| 3856 | + * Check if the database supports fulltext indexing |
|
| 3857 | + * Note that database driver can be capable of supporting FT (see supports('fulltext)) |
|
| 3858 | + * but particular instance can still have it disabled |
|
| 3859 | + * @return bool |
|
| 3860 | + */ |
|
| 3861 | + abstract public function full_text_indexing_installed(); |
|
| 3862 | + |
|
| 3863 | + /** |
|
| 3864 | + * Generate fulltext query from set of terms |
|
| 3865 | + * @param string $field Field to search against |
|
| 3866 | + * @param array $terms Search terms that may be or not be in the result |
|
| 3867 | + * @param array $must_terms Search terms that have to be in the result |
|
| 3868 | + * @param array $exclude_terms Search terms that have to be not in the result |
|
| 3869 | + */ |
|
| 3870 | + abstract public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()); |
|
| 3871 | + |
|
| 3872 | + /** |
|
| 3873 | + * Get install configuration for this DB |
|
| 3874 | + * @return array |
|
| 3875 | + */ |
|
| 3876 | + abstract public function installConfig(); |
|
| 3877 | 3877 | |
| 3878 | 3878 | /** |
| 3879 | 3879 | * Returns a DB specific FROM clause which can be used to select against functions. |
@@ -3890,5 +3890,5 @@ discard block |
||
| 3890 | 3890 | * @abstract |
| 3891 | 3891 | * @return string |
| 3892 | 3892 | */ |
| 3893 | - abstract public function getGuidSQL(); |
|
| 3893 | + abstract public function getGuidSQL(); |
|
| 3894 | 3894 | } |
@@ -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. |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $dberror = $this->lastDbError(); |
| 317 | - if($dberror === false) { |
|
| 317 | + if ($dberror === false) { |
|
| 318 | 318 | $this->last_error = false; |
| 319 | 319 | return false; |
| 320 | 320 | } |
@@ -332,16 +332,16 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | protected function registerError($userMessage, $message, $dieOnError = false) |
| 334 | 334 | { |
| 335 | - if(!empty($message)) { |
|
| 336 | - if(!empty($userMessage)) { |
|
| 335 | + if (!empty($message)) { |
|
| 336 | + if (!empty($userMessage)) { |
|
| 337 | 337 | $message = "$userMessage: $message"; |
| 338 | 338 | } |
| 339 | - if(empty($message)) { |
|
| 339 | + if (empty($message)) { |
|
| 340 | 340 | $message = "Database error"; |
| 341 | 341 | } |
| 342 | 342 | $this->log->fatal($message); |
| 343 | 343 | if ($dieOnError || $this->dieOnError) { |
| 344 | - if(isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 344 | + if (isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 345 | 345 | sugar_die($GLOBALS['app_strings']['ERR_DB_FAIL']); |
| 346 | 346 | } else { |
| 347 | 347 | sugar_die("Database error. Please check suitecrm.log for details."); |
@@ -379,8 +379,8 @@ discard block |
||
| 379 | 379 | $slow_query_time_msec = isset($sugar_config['slow_query_time_msec']) |
| 380 | 380 | ? $sugar_config['slow_query_time_msec'] : 5000; |
| 381 | 381 | |
| 382 | - if($do_the_dump) { |
|
| 383 | - if($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 382 | + if ($do_the_dump) { |
|
| 383 | + if ($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 384 | 384 | // Then log both the query and the query time |
| 385 | 385 | $this->log->fatal('Slow Query (time:'.$this->query_time."\n".$query); |
| 386 | 386 | return true; |
@@ -412,20 +412,20 @@ discard block |
||
| 412 | 412 | $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
| 413 | 413 | |
| 414 | 414 | if (empty($indices)) { |
| 415 | - foreach ( $GLOBALS['dictionary'] as $current ) { |
|
| 416 | - if ($current['table'] == $table){ |
|
| 415 | + foreach ($GLOBALS['dictionary'] as $current) { |
|
| 416 | + if ($current['table'] == $table) { |
|
| 417 | 417 | $indices = $current['indices']; |
| 418 | 418 | break; |
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | if (empty($indices)) { |
| 423 | - $this->log->warn('CHECK QUERY: Could not find index definitions for table ' . $table); |
|
| 423 | + $this->log->warn('CHECK QUERY: Could not find index definitions for table '.$table); |
|
| 424 | 424 | return false; |
| 425 | 425 | } |
| 426 | 426 | if (!empty($match[2][0])) { |
| 427 | 427 | $orderBys = explode(' ', $match[2][0]); |
| 428 | - foreach ($orderBys as $orderBy){ |
|
| 428 | + foreach ($orderBys as $orderBy) { |
|
| 429 | 429 | $orderBy = trim($orderBy); |
| 430 | 430 | if (empty($orderBy)) |
| 431 | 431 | continue; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if ($orderBy == 'asc' || $orderBy == 'desc') |
| 434 | 434 | continue; |
| 435 | 435 | |
| 436 | - $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
|
| 436 | + $orderBy = str_replace(array($table.'.', ','), '', $orderBy); |
|
| 437 | 437 | |
| 438 | 438 | foreach ($indices as $index) |
| 439 | 439 | if (empty($index['db']) || $index['db'] == $this->dbType) |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | if ($field == $orderBy) |
| 442 | 442 | return true; |
| 443 | 443 | |
| 444 | - $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
|
| 444 | + $warning = 'Missing Index For Order By Table: '.$table.' Order By:'.$orderBy; |
|
| 445 | 445 | if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
| 446 | - $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 446 | + $this->log->fatal('CHECK QUERY:'.$warning); |
|
| 447 | 447 | else |
| 448 | - $this->log->warn('CHECK QUERY:' .$warning); |
|
| 448 | + $this->log->warn('CHECK QUERY:'.$warning); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | return false; |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | public function insert(SugarBean $bean) |
| 492 | 492 | { |
| 493 | 493 | $sql = $this->insertSQL($bean); |
| 494 | - $tablename = $bean->getTableName(); |
|
| 494 | + $tablename = $bean->getTableName(); |
|
| 495 | 495 | $msg = "Error inserting into table: $tablename:"; |
| 496 | - return $this->query($sql,true,$msg); |
|
| 496 | + return $this->query($sql, true, $msg); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | { |
| 513 | 513 | if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
| 514 | 514 | //custom fields handle there save seperatley |
| 515 | - if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 515 | + if (!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 516 | 516 | |
| 517 | - if(isset($data[$field])) { |
|
| 517 | + if (isset($data[$field])) { |
|
| 518 | 518 | // clean the incoming value.. |
| 519 | 519 | $val = from_html($data[$field]); |
| 520 | 520 | } else { |
| 521 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 521 | + if (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 522 | 522 | $val = $fieldDef['default']; |
| 523 | 523 | } else { |
| 524 | 524 | $val = null; |
@@ -528,26 +528,26 @@ discard block |
||
| 528 | 528 | //handle auto increment values here - we may have to do something like nextval for oracle |
| 529 | 529 | if (!empty($fieldDef['auto_increment'])) { |
| 530 | 530 | $auto = $this->getAutoIncrementSQL($table, $fieldDef['name']); |
| 531 | - if(!empty($auto)) { |
|
| 531 | + if (!empty($auto)) { |
|
| 532 | 532 | $values[$field] = $auto; |
| 533 | 533 | } |
| 534 | 534 | } elseif ($fieldDef['name'] == 'deleted') { |
| 535 | 535 | $values['deleted'] = (int)$val; |
| 536 | 536 | } else { |
| 537 | 537 | // need to do some thing about types of values |
| 538 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 538 | + if (!is_null($val) || !empty($fieldDef['required'])) { |
|
| 539 | 539 | $values[$field] = $this->massageValue($val, $fieldDef); |
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | if (empty($values)) |
| 545 | - return $execute?true:''; // no columns set |
|
| 545 | + return $execute ? true : ''; // no columns set |
|
| 546 | 546 | |
| 547 | 547 | // get the entire sql |
| 548 | 548 | $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
| 549 | 549 | VALUES (".implode(",", $values).")"; |
| 550 | - return $execute?$this->query($query):$query; |
|
| 550 | + return $execute ? $this->query($query) : $query; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | $sql = $this->updateSQL($bean, $where); |
| 566 | 566 | $tablename = $bean->getTableName(); |
| 567 | 567 | $msg = "Error updating table: $tablename:"; |
| 568 | - return $this->query($sql,true,$msg); |
|
| 568 | + return $this->query($sql, true, $msg); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | { |
| 582 | 582 | $sql = $this->deleteSQL($bean, $where); |
| 583 | 583 | $tableName = $bean->getTableName(); |
| 584 | - $msg = "Error deleting from table: ".$tableName. ":"; |
|
| 585 | - return $this->query($sql,true,$msg); |
|
| 584 | + $msg = "Error deleting from table: ".$tableName.":"; |
|
| 585 | + return $this->query($sql, true, $msg); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -599,8 +599,8 @@ discard block |
||
| 599 | 599 | { |
| 600 | 600 | $sql = $this->retrieveSQL($bean, $where); |
| 601 | 601 | $tableName = $bean->getTableName(); |
| 602 | - $msg = "Error retriving values from table:".$tableName. ":"; |
|
| 603 | - return $this->query($sql,true,$msg); |
|
| 602 | + $msg = "Error retriving values from table:".$tableName.":"; |
|
| 603 | + return $this->query($sql, true, $msg); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | { |
| 624 | 624 | $sql = $this->retrieveViewSQL($beans, $cols, $where); |
| 625 | 625 | $msg = "Error retriving values from View Collection:"; |
| 626 | - return $this->query($sql,true,$msg); |
|
| 626 | + return $this->query($sql, true, $msg); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -638,8 +638,8 @@ discard block |
||
| 638 | 638 | $sql = $this->createTableSQL($bean); |
| 639 | 639 | $tablename = $bean->getTableName(); |
| 640 | 640 | $msg = "Error creating table: $tablename:"; |
| 641 | - $this->query($sql,true,$msg); |
|
| 642 | - if(!$this->supports("inline_keys")) { |
|
| 641 | + $this->query($sql, true, $msg); |
|
| 642 | + if (!$this->supports("inline_keys")) { |
|
| 643 | 643 | // handle constraints and indices |
| 644 | 644 | $indicesArr = $this->createConstraintSql($bean); |
| 645 | 645 | if (count($indicesArr) > 0) |
@@ -676,9 +676,9 @@ discard block |
||
| 676 | 676 | $res = true; |
| 677 | 677 | if ($sql) { |
| 678 | 678 | $msg = "Error creating table: $tablename"; |
| 679 | - $res = ($res and $this->query($sql,true,$msg)); |
|
| 679 | + $res = ($res and $this->query($sql, true, $msg)); |
|
| 680 | 680 | } |
| 681 | - if(!$this->supports("inline_keys")) { |
|
| 681 | + if (!$this->supports("inline_keys")) { |
|
| 682 | 682 | // handle constraints and indices |
| 683 | 683 | $indicesArr = $this->getConstraintSql($indices, $tablename); |
| 684 | 684 | if (count($indicesArr) > 0) |
@@ -705,20 +705,20 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | //Clean the indexes to prevent duplicate definitions |
| 707 | 707 | $new_index = array(); |
| 708 | - foreach($indices as $ind_def){ |
|
| 708 | + foreach ($indices as $ind_def) { |
|
| 709 | 709 | $new_index[$ind_def['name']] = $ind_def; |
| 710 | 710 | } |
| 711 | 711 | //jc: added this for beans that do not actually have a table, namely |
| 712 | 712 | //ForecastOpportunities |
| 713 | - if($tablename == 'does_not_exist' || $tablename == '') |
|
| 713 | + if ($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | 714 | return ''; |
| 715 | 715 | |
| 716 | 716 | global $dictionary; |
| 717 | - $engine=null; |
|
| 718 | - if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 717 | + $engine = null; |
|
| 718 | + if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine'])) |
|
| 719 | 719 | $engine = $dictionary[$bean->getObjectName()]['engine']; |
| 720 | 720 | |
| 721 | - return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
|
| 721 | + return $this->repairTableParams($tablename, $fielddefs, $new_index, $execute, $engine); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -730,12 +730,12 @@ discard block |
||
| 730 | 730 | protected function isNullable($vardef) |
| 731 | 731 | { |
| 732 | 732 | |
| 733 | - if(isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 733 | + if (isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 734 | 734 | && !empty($vardef['required'])) { |
| 735 | 735 | /* required + is_null=false => not null */ |
| 736 | 736 | return false; |
| 737 | 737 | } |
| 738 | - if(empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 738 | + if (empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 739 | 739 | && (empty($vardef['dbType']) || $vardef['dbType'] != 'id') |
| 740 | 740 | && (empty($vardef['name']) || ($vardef['name'] != 'id' && $vardef['name'] != 'deleted')) |
| 741 | 741 | ) { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * @todo: refactor engine param to be more generic |
| 757 | 757 | * @return string |
| 758 | 758 | */ |
| 759 | - public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 759 | + public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 760 | 760 | { |
| 761 | 761 | //jc: had a bug when running the repair if the tablename is blank the repair will |
| 762 | 762 | //fail when it tries to create a repair table |
@@ -766,13 +766,13 @@ discard block |
||
| 766 | 766 | //if the table does not exist create it and we are done |
| 767 | 767 | $sql = "/* Table : $tablename */\n"; |
| 768 | 768 | if (!$this->tableExists($tablename)) { |
| 769 | - $createtablesql = $this->createTableSQLParams($tablename,$fielddefs,$indices,$engine); |
|
| 770 | - if($execute && $createtablesql){ |
|
| 771 | - $this->createTableParams($tablename,$fielddefs,$indices,$engine); |
|
| 769 | + $createtablesql = $this->createTableSQLParams($tablename, $fielddefs, $indices, $engine); |
|
| 770 | + if ($execute && $createtablesql) { |
|
| 771 | + $this->createTableParams($tablename, $fielddefs, $indices, $engine); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | $sql .= "/* MISSING TABLE: {$tablename} */\n"; |
| 775 | - $sql .= $createtablesql . "\n"; |
|
| 775 | + $sql .= $createtablesql."\n"; |
|
| 776 | 776 | return $sql; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | $take_action = false; |
| 783 | 783 | |
| 784 | 784 | // do column comparisons |
| 785 | - $sql .= "/*COLUMNS*/\n"; |
|
| 785 | + $sql .= "/*COLUMNS*/\n"; |
|
| 786 | 786 | foreach ($fielddefs as $name => $value) { |
| 787 | 787 | if (isset($value['source']) && $value['source'] != 'db') |
| 788 | 788 | continue; |
@@ -801,9 +801,9 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $name = strtolower($value['name']); |
| 803 | 803 | // add or fix the field defs per what the DB is expected to give us back |
| 804 | - $this->massageFieldDef($value,$tablename); |
|
| 804 | + $this->massageFieldDef($value, $tablename); |
|
| 805 | 805 | |
| 806 | - $ignorerequired=false; |
|
| 806 | + $ignorerequired = false; |
|
| 807 | 807 | |
| 808 | 808 | //Do not track requiredness in the DB, auto_increment, ID, |
| 809 | 809 | // and deleted fields are always required in the DB, so don't force those |
@@ -819,32 +819,32 @@ discard block |
||
| 819 | 819 | $value['required'] = $compareFieldDefs[$name]['required']; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - if ( !isset($compareFieldDefs[$name]) ) { |
|
| 822 | + if (!isset($compareFieldDefs[$name])) { |
|
| 823 | 823 | // ok we need this field lets create it |
| 824 | - $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | - $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
|
| 824 | + $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | + $sql .= $this->addColumnSQL($tablename, $value)."\n"; |
|
| 826 | 826 | if ($execute) |
| 827 | 827 | $this->addColumn($tablename, $value); |
| 828 | 828 | $take_action = true; |
| 829 | - } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
|
| 829 | + } elseif (!$this->compareVarDefs($compareFieldDefs[$name], $value)) { |
|
| 830 | 830 | //fields are different lets alter it |
| 831 | - $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | - foreach($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 831 | + $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | + foreach ($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 834 | 834 | } |
| 835 | - $sql .= "*/\n"; |
|
| 836 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | - foreach($value as $rKey => $rValue) { |
|
| 838 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 835 | + $sql .= "*/\n"; |
|
| 836 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | + foreach ($value as $rKey => $rValue) { |
|
| 838 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 839 | 839 | } |
| 840 | - $sql .= "*/\n"; |
|
| 840 | + $sql .= "*/\n"; |
|
| 841 | 841 | |
| 842 | 842 | //jc: oracle will complain if you try to execute a statement that sets a column to (not) null |
| 843 | 843 | //when it is already (not) null |
| 844 | - if ( isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 844 | + if (isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 845 | 845 | $value['isnull'] === $compareFieldDefs[$name]['isnull']) { |
| 846 | 846 | unset($value['required']); |
| 847 | - $ignorerequired=true; |
|
| 847 | + $ignorerequired = true; |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | //dwheeler: Once a column has been defined as null, we cannot try to force it back to !null |
@@ -853,12 +853,12 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $ignorerequired = true; |
| 855 | 855 | } |
| 856 | - $altersql = $this->alterColumnSQL($tablename, $value,$ignorerequired); |
|
| 857 | - if(is_array($altersql)) { |
|
| 856 | + $altersql = $this->alterColumnSQL($tablename, $value, $ignorerequired); |
|
| 857 | + if (is_array($altersql)) { |
|
| 858 | 858 | $altersql = join("\n", $altersql); |
| 859 | 859 | } |
| 860 | - $sql .= $altersql . "\n"; |
|
| 861 | - if($execute){ |
|
| 860 | + $sql .= $altersql."\n"; |
|
| 861 | + if ($execute) { |
|
| 862 | 862 | $this->alterColumn($tablename, $value, $ignorerequired); |
| 863 | 863 | } |
| 864 | 864 | $take_action = true; |
@@ -866,13 +866,13 @@ discard block |
||
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | // do index comparisons |
| 869 | - $sql .= "/* INDEXES */\n"; |
|
| 869 | + $sql .= "/* INDEXES */\n"; |
|
| 870 | 870 | $correctedIndexs = array(); |
| 871 | 871 | |
| 872 | 872 | $compareIndices_case_insensitive = array(); |
| 873 | 873 | |
| 874 | 874 | // do indices comparisons case-insensitive |
| 875 | - foreach($compareIndices as $k => $value){ |
|
| 875 | + foreach ($compareIndices as $k => $value) { |
|
| 876 | 876 | $value['name'] = strtolower($value['name']); |
| 877 | 877 | $compareIndices_case_insensitive[strtolower($k)] = $value; |
| 878 | 878 | } |
@@ -899,59 +899,59 @@ discard block |
||
| 899 | 899 | continue; |
| 900 | 900 | |
| 901 | 901 | //database helpers do not know how to handle full text indices |
| 902 | - if ($value['type']=='fulltext') |
|
| 902 | + if ($value['type'] == 'fulltext') |
|
| 903 | 903 | continue; |
| 904 | 904 | |
| 905 | - if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 905 | + if (in_array($value['type'], array('alternate_key', 'foreign'))) |
|
| 906 | 906 | $value['type'] = 'index'; |
| 907 | 907 | |
| 908 | - if ( !isset($compareIndices[$name]) ) { |
|
| 908 | + if (!isset($compareIndices[$name])) { |
|
| 909 | 909 | //First check if an index exists that doesn't match our name, if so, try to rename it |
| 910 | 910 | $found = false; |
| 911 | 911 | foreach ($compareIndices as $ex_name => $ex_value) { |
| 912 | - if($this->compareVarDefs($ex_value, $value, true)) { |
|
| 912 | + if ($this->compareVarDefs($ex_value, $value, true)) { |
|
| 913 | 913 | $found = $ex_name; |
| 914 | 914 | break; |
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | if ($found) { |
| 918 | - $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 918 | + $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 919 | 919 | $rename = $this->renameIndexDefs($ex_value, $value, $tablename); |
| 920 | - if($execute) { |
|
| 920 | + if ($execute) { |
|
| 921 | 921 | $this->query($rename, true, "Cannot rename index"); |
| 922 | 922 | } |
| 923 | - $sql .= is_array($rename)?join("\n", $rename). "\n":$rename."\n"; |
|
| 923 | + $sql .= is_array($rename) ? join("\n", $rename)."\n" : $rename."\n"; |
|
| 924 | 924 | |
| 925 | 925 | } else { |
| 926 | 926 | // ok we need this field lets create it |
| 927 | - $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | - $sql .= $this->addIndexes($tablename,array($value), $execute) . "\n"; |
|
| 927 | + $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | + $sql .= $this->addIndexes($tablename, array($value), $execute)."\n"; |
|
| 929 | 929 | } |
| 930 | 930 | $take_action = true; |
| 931 | 931 | $correctedIndexs[$name] = true; |
| 932 | - } elseif ( !$this->compareVarDefs($compareIndices[$name],$value) ) { |
|
| 932 | + } elseif (!$this->compareVarDefs($compareIndices[$name], $value)) { |
|
| 933 | 933 | // fields are different lets alter it |
| 934 | - $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 934 | + $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 935 | 935 | foreach ($compareIndices[$name] as $n1 => $t1) { |
| 936 | - $sql .= "<$n1>"; |
|
| 937 | - if ( $n1 == 'fields' ) |
|
| 938 | - foreach($t1 as $rKey => $rValue) |
|
| 936 | + $sql .= "<$n1>"; |
|
| 937 | + if ($n1 == 'fields') |
|
| 938 | + foreach ($t1 as $rKey => $rValue) |
|
| 939 | 939 | $sql .= "[$rKey] => '$rValue' "; |
| 940 | 940 | else |
| 941 | 941 | $sql .= " $t1 "; |
| 942 | 942 | } |
| 943 | - $sql .= "*/\n"; |
|
| 944 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 943 | + $sql .= "*/\n"; |
|
| 944 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 945 | 945 | foreach ($value as $n1 => $t1) { |
| 946 | - $sql .= "<$n1>"; |
|
| 947 | - if ( $n1 == 'fields' ) |
|
| 946 | + $sql .= "<$n1>"; |
|
| 947 | + if ($n1 == 'fields') |
|
| 948 | 948 | foreach ($t1 as $rKey => $rValue) |
| 949 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 949 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 950 | 950 | else |
| 951 | 951 | $sql .= " $t1 "; |
| 952 | 952 | } |
| 953 | - $sql .= "*/\n"; |
|
| 954 | - $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
|
| 953 | + $sql .= "*/\n"; |
|
| 954 | + $sql .= $this->modifyIndexes($tablename, array($value), $execute)."\n"; |
|
| 955 | 955 | $take_action = true; |
| 956 | 956 | $correctedIndexs[$name] = true; |
| 957 | 957 | } |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
| 972 | 972 | { |
| 973 | - foreach ( $fielddef1 as $key => $value ) { |
|
| 973 | + foreach ($fielddef1 as $key => $value) { |
|
| 974 | 974 | if ($key == 'name' && $ignoreName) |
| 975 | 975 | continue; |
| 976 | 976 | if (isset($fielddef2[$key])) |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | } |
| 985 | 985 | else |
| 986 | 986 | { |
| 987 | - if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower',$fielddef2[$key])) |
|
| 987 | + if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower', $fielddef2[$key])) |
|
| 988 | 988 | { |
| 989 | 989 | continue; |
| 990 | 990 | } |
@@ -1033,9 +1033,9 @@ discard block |
||
| 1033 | 1033 | } |
| 1034 | 1034 | else { |
| 1035 | 1035 | $returnArray['msg'] = 'match'; |
| 1036 | - foreach($row1 as $key => $value){ |
|
| 1036 | + foreach ($row1 as $key => $value) { |
|
| 1037 | 1037 | //ignore keys when checking we will check them when we do the index check |
| 1038 | - if( !isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])){ |
|
| 1038 | + if (!isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])) { |
|
| 1039 | 1039 | $returnArray['msg'] = 'no_match'; |
| 1040 | 1040 | } |
| 1041 | 1041 | } |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | $sql = $this->createIndexSQL($bean, $fieldDefs, $name, $unique); |
| 1112 | 1112 | $tablename = $bean->getTableName(); |
| 1113 | 1113 | $msg = "Error creating index $name on table: $tablename:"; |
| 1114 | - return $this->query($sql,true,$msg); |
|
| 1114 | + return $this->query($sql, true, $msg); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | /** |
@@ -1128,14 +1128,14 @@ discard block |
||
| 1128 | 1128 | $columns = array(); |
| 1129 | 1129 | |
| 1130 | 1130 | foreach ($indices as $index) { |
| 1131 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1131 | + if (!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | 1132 | continue; |
| 1133 | 1133 | if (isset($index['source']) && $index['source'] != 'db') |
| 1134 | 1134 | continue; |
| 1135 | 1135 | |
| 1136 | 1136 | $sql = $this->add_drop_constraint($table, $index); |
| 1137 | 1137 | |
| 1138 | - if(!empty($sql)) { |
|
| 1138 | + if (!empty($sql)) { |
|
| 1139 | 1139 | $columns[] = $sql; |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
@@ -1155,11 +1155,11 @@ discard block |
||
| 1155 | 1155 | { |
| 1156 | 1156 | $alters = $this->getConstraintSql($indexes, $tablename); |
| 1157 | 1157 | if ($execute) { |
| 1158 | - foreach($alters as $sql) { |
|
| 1158 | + foreach ($alters as $sql) { |
|
| 1159 | 1159 | $this->query($sql, true, "Error adding index: "); |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | - if(!empty($alters)) { |
|
| 1162 | + if (!empty($alters)) { |
|
| 1163 | 1163 | $sql = join(";\n", $alters).";\n"; |
| 1164 | 1164 | } else { |
| 1165 | 1165 | $sql = ''; |
@@ -1179,17 +1179,17 @@ discard block |
||
| 1179 | 1179 | { |
| 1180 | 1180 | $sqls = array(); |
| 1181 | 1181 | foreach ($indexes as $index) { |
| 1182 | - $name =$index['name']; |
|
| 1183 | - $sqls[$name] = $this->add_drop_constraint($tablename,$index,true); |
|
| 1182 | + $name = $index['name']; |
|
| 1183 | + $sqls[$name] = $this->add_drop_constraint($tablename, $index, true); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | if (!empty($sqls) && $execute) { |
| 1186 | - foreach($sqls as $name => $sql) { |
|
| 1186 | + foreach ($sqls as $name => $sql) { |
|
| 1187 | 1187 | unset(self::$index_descriptions[$tablename][$name]); |
| 1188 | 1188 | $this->query($sql); |
| 1189 | 1189 | } |
| 1190 | 1190 | } |
| 1191 | - if(!empty($sqls)) { |
|
| 1192 | - return join(";\n",$sqls).";"; |
|
| 1191 | + if (!empty($sqls)) { |
|
| 1192 | + return join(";\n", $sqls).";"; |
|
| 1193 | 1193 | } else { |
| 1194 | 1194 | return ''; |
| 1195 | 1195 | } |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | public function addColumn($tablename, $fieldDefs) |
| 1220 | 1220 | { |
| 1221 | 1221 | $sql = $this->addColumnSQL($tablename, $fieldDefs); |
| 1222 | - if ($this->isFieldArray($fieldDefs)){ |
|
| 1222 | + if ($this->isFieldArray($fieldDefs)) { |
|
| 1223 | 1223 | $columns = array(); |
| 1224 | 1224 | foreach ($fieldDefs as $fieldDef) |
| 1225 | 1225 | $columns[] = $fieldDef['name']; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | $columns = $fieldDefs['name']; |
| 1230 | 1230 | } |
| 1231 | 1231 | $msg = "Error adding column(s) $columns on table: $tablename:"; |
| 1232 | - return $this->query($sql,true,$msg); |
|
| 1232 | + return $this->query($sql, true, $msg); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | */ |
| 1243 | 1243 | public function alterColumn($tablename, $newFieldDef, $ignoreRequired = false) |
| 1244 | 1244 | { |
| 1245 | - $sql = $this->alterColumnSQL($tablename, $newFieldDef,$ignoreRequired); |
|
| 1246 | - if ($this->isFieldArray($newFieldDef)){ |
|
| 1245 | + $sql = $this->alterColumnSQL($tablename, $newFieldDef, $ignoreRequired); |
|
| 1246 | + if ($this->isFieldArray($newFieldDef)) { |
|
| 1247 | 1247 | $columns = array(); |
| 1248 | 1248 | foreach ($newFieldDef as $fieldDef) { |
| 1249 | 1249 | $columns[] = $fieldDef['name']; |
@@ -1255,8 +1255,8 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | $msg = "Error altering column(s) $columns on table: $tablename:"; |
| 1258 | - $res = $this->query($sql,true,$msg); |
|
| 1259 | - if($res) { |
|
| 1258 | + $res = $this->query($sql, true, $msg); |
|
| 1259 | + if ($res) { |
|
| 1260 | 1260 | $this->getTableDescription($tablename, true); // reload table description after altering |
| 1261 | 1261 | } |
| 1262 | 1262 | return $res; |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | public function dropTableName($name) |
| 1283 | 1283 | { |
| 1284 | 1284 | $sql = $this->dropTableNameSQL($name); |
| 1285 | - return $this->query($sql,true,"Error dropping table $name:"); |
|
| 1285 | + return $this->query($sql, true, "Error dropping table $name:"); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | /** |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | $tablename = $bean->getTableName(); |
| 1298 | 1298 | $sql = $this->dropColumnSQL($tablename, $fieldDefs); |
| 1299 | 1299 | $msg = "Error deleting column(s) on table: $tablename:"; |
| 1300 | - return $this->query($sql,true,$msg); |
|
| 1300 | + return $this->query($sql, true, $msg); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1320,18 +1320,18 @@ discard block |
||
| 1320 | 1320 | |
| 1321 | 1321 | $rows_found = 0; |
| 1322 | 1322 | $count_query = $bean->create_list_count_query($select_query); |
| 1323 | - if(!empty($count_query)) |
|
| 1323 | + if (!empty($count_query)) |
|
| 1324 | 1324 | { |
| 1325 | 1325 | // We have a count query. Run it and get the results. |
| 1326 | 1326 | $result = $this->query($count_query, true, "Error running count query for $this->object_name List: "); |
| 1327 | 1327 | $assoc = $this->fetchByAssoc($result); |
| 1328 | - if(!empty($assoc['c'])) |
|
| 1328 | + if (!empty($assoc['c'])) |
|
| 1329 | 1329 | { |
| 1330 | 1330 | $rows_found = $assoc['c']; |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | - if($count == -1){ |
|
| 1334 | - $count = $sugar_config['list_max_entries_per_page']; |
|
| 1333 | + if ($count == -1) { |
|
| 1334 | + $count = $sugar_config['list_max_entries_per_page']; |
|
| 1335 | 1335 | } |
| 1336 | 1336 | $next_offset = $start + $count; |
| 1337 | 1337 | |
@@ -1344,13 +1344,13 @@ discard block |
||
| 1344 | 1344 | $fields = $bean->getFieldDefinitions(); |
| 1345 | 1345 | $custom_fields = array(); |
| 1346 | 1346 | |
| 1347 | - if($bean->hasCustomFields()){ |
|
| 1348 | - foreach ($fields as $fieldDef){ |
|
| 1349 | - if($fieldDef['source'] == 'custom_fields'){ |
|
| 1347 | + if ($bean->hasCustomFields()) { |
|
| 1348 | + foreach ($fields as $fieldDef) { |
|
| 1349 | + if ($fieldDef['source'] == 'custom_fields') { |
|
| 1350 | 1350 | $custom_fields[$fieldDef['name']] = $fieldDef['name']; |
| 1351 | 1351 | } |
| 1352 | 1352 | } |
| 1353 | - if(!empty($custom_fields)){ |
|
| 1353 | + if (!empty($custom_fields)) { |
|
| 1354 | 1354 | $custom_fields['id_c'] = 'id_c'; |
| 1355 | 1355 | $id_field = array('name' => 'id_c', 'custom_type' => 'id',); |
| 1356 | 1356 | $fields[] = $id_field; |
@@ -1363,50 +1363,50 @@ discard block |
||
| 1363 | 1363 | $cstm_row_array = array(); |
| 1364 | 1364 | $cstm_columns = array(); |
| 1365 | 1365 | $built_columns = false; |
| 1366 | - while(($row = $this->fetchByAssoc($result)) != null) |
|
| 1366 | + while (($row = $this->fetchByAssoc($result)) != null) |
|
| 1367 | 1367 | { |
| 1368 | 1368 | $values = array(); |
| 1369 | 1369 | $cstm_values = array(); |
| 1370 | - if(!$is_related_query){ |
|
| 1370 | + if (!$is_related_query) { |
|
| 1371 | 1371 | foreach ($fields as $fieldDef) |
| 1372 | 1372 | { |
| 1373 | - if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1373 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1374 | 1374 | $val = $row[$fieldDef['name']]; |
| 1375 | 1375 | |
| 1376 | 1376 | //handle auto increment values here only need to do this on insert not create |
| 1377 | - if ($fieldDef['name'] == 'deleted'){ |
|
| 1377 | + if ($fieldDef['name'] == 'deleted') { |
|
| 1378 | 1378 | $values['deleted'] = $val; |
| 1379 | - if(!$built_columns){ |
|
| 1379 | + if (!$built_columns) { |
|
| 1380 | 1380 | $columns[] = 'deleted'; |
| 1381 | 1381 | } |
| 1382 | 1382 | } |
| 1383 | 1383 | else |
| 1384 | 1384 | { |
| 1385 | 1385 | $type = $fieldDef['type']; |
| 1386 | - if(!empty($fieldDef['custom_type'])){ |
|
| 1386 | + if (!empty($fieldDef['custom_type'])) { |
|
| 1387 | 1387 | $type = $fieldDef['custom_type']; |
| 1388 | 1388 | } |
| 1389 | 1389 | // need to do some thing about types of values |
| 1390 | - if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
|
| 1391 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1390 | + if ($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')) { |
|
| 1391 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | 1392 | $cstm_values[$fieldDef['name']] = 'null'; |
| 1393 | 1393 | else |
| 1394 | 1394 | $values[$fieldDef['name']] = 'null'; |
| 1395 | - }else{ |
|
| 1396 | - if(isset($type) && $type=='int') { |
|
| 1397 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1395 | + } else { |
|
| 1396 | + if (isset($type) && $type == 'int') { |
|
| 1397 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | 1398 | $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
| 1399 | 1399 | else |
| 1400 | 1400 | $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
| 1401 | 1401 | } else { |
| 1402 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1402 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | 1403 | $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
| 1404 | 1404 | else |
| 1405 | 1405 | $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
| 1406 | 1406 | } |
| 1407 | 1407 | } |
| 1408 | - if(!$built_columns){ |
|
| 1409 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1408 | + if (!$built_columns) { |
|
| 1409 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | 1410 | $cstm_columns[] = $fieldDef['name']; |
| 1411 | 1411 | else |
| 1412 | 1412 | $columns[] = $fieldDef['name']; |
@@ -1417,19 +1417,19 @@ discard block |
||
| 1417 | 1417 | } else { |
| 1418 | 1418 | foreach ($row as $key=>$val) |
| 1419 | 1419 | { |
| 1420 | - if($key != 'orc_row'){ |
|
| 1420 | + if ($key != 'orc_row') { |
|
| 1421 | 1421 | $values[$key] = "'$val'"; |
| 1422 | - if(!$built_columns){ |
|
| 1422 | + if (!$built_columns) { |
|
| 1423 | 1423 | $columns[] = $key; |
| 1424 | 1424 | } |
| 1425 | 1425 | } |
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | $built_columns = true; |
| 1429 | - if(!empty($values)){ |
|
| 1429 | + if (!empty($values)) { |
|
| 1430 | 1430 | $row_array[] = $values; |
| 1431 | 1431 | } |
| 1432 | - if(!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)){ |
|
| 1432 | + if (!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)) { |
|
| 1433 | 1433 | $cstm_row_array[] = $cstm_values; |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
@@ -1439,9 +1439,9 @@ discard block |
||
| 1439 | 1439 | // get the entire sql |
| 1440 | 1440 | $sql .= "(".implode(",", $columns).") "; |
| 1441 | 1441 | $sql .= "VALUES"; |
| 1442 | - for($i = 0; $i < count($row_array); $i++){ |
|
| 1442 | + for ($i = 0; $i < count($row_array); $i++) { |
|
| 1443 | 1443 | $sql .= " (".implode(",", $row_array[$i]).")"; |
| 1444 | - if($i < (count($row_array) - 1)){ |
|
| 1444 | + if ($i < (count($row_array) - 1)) { |
|
| 1445 | 1445 | $sql .= ", "; |
| 1446 | 1446 | } |
| 1447 | 1447 | } |
@@ -1450,9 +1450,9 @@ discard block |
||
| 1450 | 1450 | $custom_sql .= "(".implode(",", $cstm_columns).") "; |
| 1451 | 1451 | $custom_sql .= "VALUES"; |
| 1452 | 1452 | |
| 1453 | - for($i = 0; $i < count($cstm_row_array); $i++){ |
|
| 1453 | + for ($i = 0; $i < count($cstm_row_array); $i++) { |
|
| 1454 | 1454 | $custom_sql .= " (".implode(",", $cstm_row_array[$i]).")"; |
| 1455 | - if($i < (count($cstm_row_array) - 1)){ |
|
| 1455 | + if ($i < (count($cstm_row_array) - 1)) { |
|
| 1456 | 1456 | $custom_sql .= ", "; |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
@@ -1545,17 +1545,17 @@ discard block |
||
| 1545 | 1545 | */ |
| 1546 | 1546 | public function quoteType($type, $value) |
| 1547 | 1547 | { |
| 1548 | - if($type == 'date') { |
|
| 1548 | + if ($type == 'date') { |
|
| 1549 | 1549 | return $this->convert($this->quoted($value), "date"); |
| 1550 | 1550 | } |
| 1551 | - if($type == 'time') { |
|
| 1551 | + if ($type == 'time') { |
|
| 1552 | 1552 | return $this->convert($this->quoted($value), "time"); |
| 1553 | 1553 | } |
| 1554 | - if(isset($this->type_class[$type]) && $this->type_class[$type] == "date") { |
|
| 1554 | + if (isset($this->type_class[$type]) && $this->type_class[$type] == "date") { |
|
| 1555 | 1555 | return $this->convert($this->quoted($value), "datetime"); |
| 1556 | 1556 | } |
| 1557 | - if($this->isNumericType($type)) { |
|
| 1558 | - return 0+$value; // ensure it's numeric |
|
| 1557 | + if ($this->isNumericType($type)) { |
|
| 1558 | + return 0 + $value; // ensure it's numeric |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | return $this->quoted($value); |
@@ -1571,7 +1571,7 @@ discard block |
||
| 1571 | 1571 | */ |
| 1572 | 1572 | public function arrayQuote(array &$array) |
| 1573 | 1573 | { |
| 1574 | - foreach($array as &$val) { |
|
| 1574 | + foreach ($array as &$val) { |
|
| 1575 | 1575 | $val = $this->quote($val); |
| 1576 | 1576 | } |
| 1577 | 1577 | return $array; |
@@ -1584,10 +1584,10 @@ discard block |
||
| 1584 | 1584 | */ |
| 1585 | 1585 | protected function freeResult($result = false) |
| 1586 | 1586 | { |
| 1587 | - if($result) { |
|
| 1587 | + if ($result) { |
|
| 1588 | 1588 | $this->freeDbResult($result); |
| 1589 | 1589 | } |
| 1590 | - if($this->lastResult) { |
|
| 1590 | + if ($this->lastResult) { |
|
| 1591 | 1591 | $this->freeDbResult($this->lastResult); |
| 1592 | 1592 | $this->lastResult = null; |
| 1593 | 1593 | } |
@@ -1616,17 +1616,17 @@ discard block |
||
| 1616 | 1616 | public function getOne($sql, $dieOnError = false, $msg = '') |
| 1617 | 1617 | { |
| 1618 | 1618 | $this->log->info("Get One: |$sql|"); |
| 1619 | - if(!$this->hasLimit($sql)) { |
|
| 1619 | + if (!$this->hasLimit($sql)) { |
|
| 1620 | 1620 | $queryresult = $this->limitQuery($sql, 0, 1, $dieOnError, $msg); |
| 1621 | 1621 | } else { |
| 1622 | 1622 | // support old code that passes LIMIT to sql |
| 1623 | 1623 | // works only for mysql, so do not rely on this |
| 1624 | 1624 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1625 | 1625 | } |
| 1626 | - $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
|
| 1626 | + $this->checkError($msg.' Get One Failed:'.$sql, $dieOnError); |
|
| 1627 | 1627 | if (!$queryresult) return false; |
| 1628 | 1628 | $row = $this->fetchByAssoc($queryresult); |
| 1629 | - if(!empty($row)) { |
|
| 1629 | + if (!empty($row)) { |
|
| 1630 | 1630 | return array_shift($row); |
| 1631 | 1631 | } |
| 1632 | 1632 | return false; |
@@ -1646,12 +1646,12 @@ discard block |
||
| 1646 | 1646 | $this->log->info("Fetch One: |$sql|"); |
| 1647 | 1647 | $this->checkConnection(); |
| 1648 | 1648 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1649 | - $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
|
| 1649 | + $this->checkError($msg.' Fetch One Failed:'.$sql, $dieOnError); |
|
| 1650 | 1650 | |
| 1651 | 1651 | if (!$queryresult) return false; |
| 1652 | 1652 | |
| 1653 | 1653 | $row = $this->fetchByAssoc($queryresult); |
| 1654 | - if ( !$row ) return false; |
|
| 1654 | + if (!$row) return false; |
|
| 1655 | 1655 | |
| 1656 | 1656 | $this->freeResult($queryresult); |
| 1657 | 1657 | return $row; |
@@ -1692,7 +1692,7 @@ discard block |
||
| 1692 | 1692 | */ |
| 1693 | 1693 | public function getTableDescription($tablename, $reload = false) |
| 1694 | 1694 | { |
| 1695 | - if($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1695 | + if ($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1696 | 1696 | self::$table_descriptions[$tablename] = $this->get_columns($tablename); |
| 1697 | 1697 | } |
| 1698 | 1698 | return self::$table_descriptions[$tablename]; |
@@ -1708,12 +1708,12 @@ discard block |
||
| 1708 | 1708 | protected function describeField($name, $tablename) |
| 1709 | 1709 | { |
| 1710 | 1710 | $table = $this->getTableDescription($tablename); |
| 1711 | - if(!empty($table) && isset($table[$name])) |
|
| 1711 | + if (!empty($table) && isset($table[$name])) |
|
| 1712 | 1712 | return $table[$name]; |
| 1713 | 1713 | |
| 1714 | 1714 | $table = $this->getTableDescription($tablename, true); |
| 1715 | 1715 | |
| 1716 | - if(isset($table[$name])) |
|
| 1716 | + if (isset($table[$name])) |
|
| 1717 | 1717 | return $table[$name]; |
| 1718 | 1718 | |
| 1719 | 1719 | return array(); |
@@ -1728,13 +1728,13 @@ discard block |
||
| 1728 | 1728 | */ |
| 1729 | 1729 | protected function describeIndex($name, $tablename) |
| 1730 | 1730 | { |
| 1731 | - if(isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1731 | + if (isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])) { |
|
| 1732 | 1732 | return self::$index_descriptions[$tablename][$name]; |
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | 1735 | self::$index_descriptions[$tablename] = $this->get_indices($tablename); |
| 1736 | 1736 | |
| 1737 | - if(isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1737 | + if (isset(self::$index_descriptions[$tablename][$name])) { |
|
| 1738 | 1738 | return self::$index_descriptions[$tablename][$name]; |
| 1739 | 1739 | } |
| 1740 | 1740 | |
@@ -1751,9 +1751,9 @@ discard block |
||
| 1751 | 1751 | */ |
| 1752 | 1752 | public function truncate($string, $len) |
| 1753 | 1753 | { |
| 1754 | - if ( is_numeric($len) && $len > 0) |
|
| 1754 | + if (is_numeric($len) && $len > 0) |
|
| 1755 | 1755 | { |
| 1756 | - $string = mb_substr($string,0,(int) $len, "UTF-8"); |
|
| 1756 | + $string = mb_substr($string, 0, (int)$len, "UTF-8"); |
|
| 1757 | 1757 | } |
| 1758 | 1758 | return $string; |
| 1759 | 1759 | } |
@@ -1768,11 +1768,11 @@ discard block |
||
| 1768 | 1768 | */ |
| 1769 | 1769 | public function concat($table, array $fields, $space = ' ') |
| 1770 | 1770 | { |
| 1771 | - if(empty($fields)) return ''; |
|
| 1771 | + if (empty($fields)) return ''; |
|
| 1772 | 1772 | $elems = array(); |
| 1773 | 1773 | $space = $this->quoted($space); |
| 1774 | - foreach ( $fields as $field ) { |
|
| 1775 | - if(!empty($elems)) $elems[] = $space; |
|
| 1774 | + foreach ($fields as $field) { |
|
| 1775 | + if (!empty($elems)) $elems[] = $space; |
|
| 1776 | 1776 | $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
| 1777 | 1777 | } |
| 1778 | 1778 | $first = array_shift($elems); |
@@ -1829,8 +1829,8 @@ discard block |
||
| 1829 | 1829 | */ |
| 1830 | 1830 | public function executePreparedQuery($stmt, $data = array()) |
| 1831 | 1831 | { |
| 1832 | - if(!empty($this->preparedTokens[$stmt])){ |
|
| 1833 | - if(!is_array($data)){ |
|
| 1832 | + if (!empty($this->preparedTokens[$stmt])) { |
|
| 1833 | + if (!is_array($data)) { |
|
| 1834 | 1834 | $data = array($data); |
| 1835 | 1835 | } |
| 1836 | 1836 | |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | |
| 1839 | 1839 | //ensure that the number of data elements matches the number of replacement tokens |
| 1840 | 1840 | //we found in prepare(). |
| 1841 | - if(count($data) != $pTokens['tokenCount']){ |
|
| 1841 | + if (count($data) != $pTokens['tokenCount']) { |
|
| 1842 | 1842 | //error the data count did not match the token count |
| 1843 | 1843 | return false; |
| 1844 | 1844 | } |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | }//switch |
| 1865 | 1865 | }//foreach |
| 1866 | 1866 | return $this->query($query); |
| 1867 | - }else{ |
|
| 1867 | + } else { |
|
| 1868 | 1868 | return false; |
| 1869 | 1869 | } |
| 1870 | 1870 | } |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | { |
| 1909 | 1909 | // get column names and values |
| 1910 | 1910 | $sql = $this->insertParams($bean->getTableName(), $bean->getFieldDefinitions(), get_object_vars($bean), |
| 1911 | - isset($bean->field_name_map)?$bean->field_name_map:null, false); |
|
| 1911 | + isset($bean->field_name_map) ? $bean->field_name_map : null, false); |
|
| 1912 | 1912 | return $sql; |
| 1913 | 1913 | } |
| 1914 | 1914 | |
@@ -1936,48 +1936,48 @@ discard block |
||
| 1936 | 1936 | if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
| 1937 | 1937 | |
| 1938 | 1938 | //custom fields handle their save separately |
| 1939 | - if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1939 | + if (isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1940 | 1940 | |
| 1941 | 1941 | // no need to clear deleted since we only update not deleted records anyway |
| 1942 | - if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1942 | + if ($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1943 | 1943 | |
| 1944 | - if(isset($bean->$field)) { |
|
| 1944 | + if (isset($bean->$field)) { |
|
| 1945 | 1945 | $val = from_html($bean->$field); |
| 1946 | 1946 | } else { |
| 1947 | 1947 | continue; |
| 1948 | 1948 | } |
| 1949 | 1949 | |
| 1950 | - if(!empty($fieldDef['type']) && $fieldDef['type'] == 'bool'){ |
|
| 1950 | + if (!empty($fieldDef['type']) && $fieldDef['type'] == 'bool') { |
|
| 1951 | 1951 | $val = $bean->getFieldValue($field); |
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | - if(strlen($val) == 0) { |
|
| 1955 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1954 | + if (strlen($val) == 0) { |
|
| 1955 | + if (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1956 | 1956 | $val = $fieldDef['default']; |
| 1957 | 1957 | } else { |
| 1958 | 1958 | $val = null; |
| 1959 | 1959 | } |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1962 | + if (!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1963 | 1963 | $val = $this->truncate($val, $fieldDef['len']); |
| 1964 | 1964 | } |
| 1965 | 1965 | $columnName = $this->quoteIdentifier($fieldDef['name']); |
| 1966 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1966 | + if (!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1967 | 1967 | $columns[] = "{$columnName}=".$this->massageValue($val, $fieldDef); |
| 1968 | - } elseif($this->isNullable($fieldDef)) { |
|
| 1968 | + } elseif ($this->isNullable($fieldDef)) { |
|
| 1969 | 1969 | $columns[] = "{$columnName}=NULL"; |
| 1970 | 1970 | } else { |
| 1971 | 1971 | $columns[] = "{$columnName}=".$this->emptyValue($fieldDef['type']); |
| 1972 | 1972 | } |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | - if ( sizeof($columns) == 0 ) |
|
| 1975 | + if (sizeof($columns) == 0) |
|
| 1976 | 1976 | return ""; // no columns set |
| 1977 | 1977 | |
| 1978 | 1978 | // build where clause |
| 1979 | 1979 | $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
| 1980 | - if(isset($fields['deleted'])) { |
|
| 1980 | + if (isset($fields['deleted'])) { |
|
| 1981 | 1981 | $where .= " AND deleted=0"; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | $primaryColumn = $fieldDef['name']; |
| 2002 | 2002 | |
| 2003 | 2003 | $val = $bean->getFieldValue($fieldDef['name']); |
| 2004 | - if ($val != FALSE){ |
|
| 2004 | + if ($val != FALSE) { |
|
| 2005 | 2005 | $where[$primaryColumn] = $val; |
| 2006 | 2006 | } |
| 2007 | 2007 | } |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | if (is_array($val)) { |
| 2028 | 2028 | $op = "IN"; |
| 2029 | 2029 | $temp = array(); |
| 2030 | - foreach ($val as $tval){ |
|
| 2030 | + foreach ($val as $tval) { |
|
| 2031 | 2031 | $temp[] = $this->quoted($tval); |
| 2032 | 2032 | } |
| 2033 | 2033 | $val = implode(",", $temp); |
@@ -2053,9 +2053,9 @@ discard block |
||
| 2053 | 2053 | * @param array $whereArray Optional, where conditions in an array |
| 2054 | 2054 | * @return string |
| 2055 | 2055 | */ |
| 2056 | - protected function getWhereClause(SugarBean $bean, array $whereArray=array()) |
|
| 2056 | + protected function getWhereClause(SugarBean $bean, array $whereArray = array()) |
|
| 2057 | 2057 | { |
| 2058 | - return " WHERE " . $this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2058 | + return " WHERE ".$this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2059 | 2059 | } |
| 2060 | 2060 | |
| 2061 | 2061 | /** |
@@ -2069,13 +2069,13 @@ discard block |
||
| 2069 | 2069 | { |
| 2070 | 2070 | $type = $this->getFieldType($fieldDef); |
| 2071 | 2071 | |
| 2072 | - if(isset($this->type_class[$type])) { |
|
| 2072 | + if (isset($this->type_class[$type])) { |
|
| 2073 | 2073 | // handle some known types |
| 2074 | - switch($this->type_class[$type]) { |
|
| 2074 | + switch ($this->type_class[$type]) { |
|
| 2075 | 2075 | case 'bool': |
| 2076 | 2076 | case 'int': |
| 2077 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2078 | - if (isset($fieldDef['default'])){ |
|
| 2077 | + if (!empty($fieldDef['required']) && $val == '') { |
|
| 2078 | + if (isset($fieldDef['default'])) { |
|
| 2079 | 2079 | return $fieldDef['default']; |
| 2080 | 2080 | } |
| 2081 | 2081 | return 0; |
@@ -2083,16 +2083,16 @@ discard block |
||
| 2083 | 2083 | return intval($val); |
| 2084 | 2084 | case 'bigint' : |
| 2085 | 2085 | $val = (float)$val; |
| 2086 | - if (!empty($fieldDef['required']) && $val == false){ |
|
| 2087 | - if (isset($fieldDef['default'])){ |
|
| 2086 | + if (!empty($fieldDef['required']) && $val == false) { |
|
| 2087 | + if (isset($fieldDef['default'])) { |
|
| 2088 | 2088 | return $fieldDef['default']; |
| 2089 | 2089 | } |
| 2090 | 2090 | return 0; |
| 2091 | 2091 | } |
| 2092 | 2092 | return $val; |
| 2093 | 2093 | case 'float': |
| 2094 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2095 | - if (isset($fieldDef['default'])){ |
|
| 2094 | + if (!empty($fieldDef['required']) && $val == '') { |
|
| 2095 | + if (isset($fieldDef['default'])) { |
|
| 2096 | 2096 | return $fieldDef['default']; |
| 2097 | 2097 | } |
| 2098 | 2098 | return 0; |
@@ -2101,7 +2101,7 @@ discard block |
||
| 2101 | 2101 | case 'time': |
| 2102 | 2102 | case 'date': |
| 2103 | 2103 | // empty date can't be '', so convert it to either NULL or empty date value |
| 2104 | - if($val == '') { |
|
| 2104 | + if ($val == '') { |
|
| 2105 | 2105 | if (!empty($fieldDef['required'])) { |
| 2106 | 2106 | if (isset($fieldDef['default'])) { |
| 2107 | 2107 | return $fieldDef['default']; |
@@ -2113,14 +2113,14 @@ discard block |
||
| 2113 | 2113 | break; |
| 2114 | 2114 | } |
| 2115 | 2115 | } else { |
| 2116 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2116 | + if (!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2117 | 2117 | $val = $this->truncate($val, $fieldDef['len']); |
| 2118 | 2118 | } |
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | - if ( is_null($val) ) { |
|
| 2122 | - if(!empty($fieldDef['required'])) { |
|
| 2123 | - if (isset($fieldDef['default']) && $fieldDef['default'] != ''){ |
|
| 2121 | + if (is_null($val)) { |
|
| 2122 | + if (!empty($fieldDef['required'])) { |
|
| 2123 | + if (isset($fieldDef['default']) && $fieldDef['default'] != '') { |
|
| 2124 | 2124 | return $fieldDef['default']; |
| 2125 | 2125 | } |
| 2126 | 2126 | return $this->emptyValue($type); |
@@ -2128,7 +2128,7 @@ discard block |
||
| 2128 | 2128 | return "NULL"; |
| 2129 | 2129 | } |
| 2130 | 2130 | } |
| 2131 | - if($type == "datetimecombo") { |
|
| 2131 | + if ($type == "datetimecombo") { |
|
| 2132 | 2132 | $type = "datetime"; |
| 2133 | 2133 | } |
| 2134 | 2134 | return $this->convert($this->quoted($val), $type); |
@@ -2143,23 +2143,23 @@ discard block |
||
| 2143 | 2143 | */ |
| 2144 | 2144 | public function massageFieldDef(&$fieldDef, $tablename) |
| 2145 | 2145 | { |
| 2146 | - if ( !isset($fieldDef['dbType']) ) { |
|
| 2147 | - if ( isset($fieldDef['dbtype']) ) |
|
| 2146 | + if (!isset($fieldDef['dbType'])) { |
|
| 2147 | + if (isset($fieldDef['dbtype'])) |
|
| 2148 | 2148 | $fieldDef['dbType'] = $fieldDef['dbtype']; |
| 2149 | 2149 | else |
| 2150 | 2150 | $fieldDef['dbType'] = $fieldDef['type']; |
| 2151 | 2151 | } |
| 2152 | - $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
|
| 2152 | + $type = $this->getColumnType($fieldDef['dbType'], $fieldDef['name'], $tablename); |
|
| 2153 | 2153 | $matches = array(); |
| 2154 | 2154 | // len can be a number or a string like 'max', for example, nvarchar(max) |
| 2155 | 2155 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches); |
| 2156 | - if ( isset($matches[1][0]) ) |
|
| 2156 | + if (isset($matches[1][0])) |
|
| 2157 | 2157 | $fieldDef['type'] = $matches[1][0]; |
| 2158 | - if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2158 | + if (isset($matches[2][0]) && empty($fieldDef['len'])) |
|
| 2159 | 2159 | $fieldDef['len'] = $matches[2][0]; |
| 2160 | - if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2160 | + if (!empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'], ',')) |
|
| 2161 | 2161 | $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
| 2162 | - if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
|
| 2162 | + if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required']))) { |
|
| 2163 | 2163 | $fieldDef['required'] = 'true'; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
@@ -2180,7 +2180,7 @@ discard block |
||
| 2180 | 2180 | $level = 0; |
| 2181 | 2181 | $selectField = ""; |
| 2182 | 2182 | $strLen = strlen($selectStatement); |
| 2183 | - for($i = 0; $i < $strLen; $i++) |
|
| 2183 | + for ($i = 0; $i < $strLen; $i++) |
|
| 2184 | 2184 | { |
| 2185 | 2185 | $char = $selectStatement[$i]; |
| 2186 | 2186 | |
@@ -2190,16 +2190,16 @@ discard block |
||
| 2190 | 2190 | $fields[$field] = $selectField; |
| 2191 | 2191 | $selectField = ""; |
| 2192 | 2192 | } |
| 2193 | - else if ($char == "("){ |
|
| 2193 | + else if ($char == "(") { |
|
| 2194 | 2194 | $level++; |
| 2195 | 2195 | $selectField .= $char; |
| 2196 | 2196 | } |
| 2197 | - else if($char == ")"){ |
|
| 2197 | + else if ($char == ")") { |
|
| 2198 | 2198 | $level--; |
| 2199 | 2199 | $selectField .= $char; |
| 2200 | 2200 | |
| 2201 | 2201 | |
| 2202 | - }else{ |
|
| 2202 | + } else { |
|
| 2203 | 2203 | $selectField .= $char; |
| 2204 | 2204 | } |
| 2205 | 2205 | |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | */ |
| 2216 | 2216 | protected function getFieldNameFromSelect($string) |
| 2217 | 2217 | { |
| 2218 | - if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2218 | + if (strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2219 | 2219 | $string = substr($string, 9); |
| 2220 | 2220 | } |
| 2221 | 2221 | if (stripos($string, " as ") !== false) |
@@ -2293,14 +2293,14 @@ discard block |
||
| 2293 | 2293 | foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
| 2294 | 2294 | |
| 2295 | 2295 | // build part of where clause |
| 2296 | - if (is_array($whereClause[$beanID])){ |
|
| 2296 | + if (is_array($whereClause[$beanID])) { |
|
| 2297 | 2297 | $where[] = $this->getColumnWhereClause($table, $whereClause[$beanID]); |
| 2298 | 2298 | } |
| 2299 | 2299 | // initialize so that it can be used properly in form clause generation |
| 2300 | 2300 | $table_used_in_from[$table] = false; |
| 2301 | 2301 | |
| 2302 | 2302 | $indices = $bean->getIndices(); |
| 2303 | - foreach ($indices as $index){ |
|
| 2303 | + foreach ($indices as $index) { |
|
| 2304 | 2304 | if ($index['type'] == 'foreign') { |
| 2305 | 2305 | $relationship[$table][] = array('foreignTable'=> $index['foreignTable'] |
| 2306 | 2306 | ,'foreignColumn'=>$index['foreignField'] |
@@ -2321,12 +2321,12 @@ discard block |
||
| 2321 | 2321 | // table2 is assumed to joining through primary key called id |
| 2322 | 2322 | $separator = ""; |
| 2323 | 2323 | $from = ''; $table_used_in_from = array(); |
| 2324 | - foreach ($relations as $table1 => $rightsidearray){ |
|
| 2324 | + foreach ($relations as $table1 => $rightsidearray) { |
|
| 2325 | 2325 | if ($table_used_in_from[$table1]) continue; // table has been joined |
| 2326 | 2326 | |
| 2327 | 2327 | $from .= $separator." ".$table1; |
| 2328 | 2328 | $table_used_in_from[$table1] = true; |
| 2329 | - foreach ($rightsidearray as $tablearray){ |
|
| 2329 | + foreach ($rightsidearray as $tablearray) { |
|
| 2330 | 2330 | $table2 = $tablearray['foreignTable']; // get foreign table |
| 2331 | 2331 | $tableAlias = $aliases[$table2]; // get a list of aliases for this table |
| 2332 | 2332 | foreach ($tableAlias as $table2) { |
@@ -2386,9 +2386,9 @@ discard block |
||
| 2386 | 2386 | // we do not have change a lot of existing code |
| 2387 | 2387 | // and add dbtype where type is being used for some special |
| 2388 | 2388 | // purposes like referring to foreign table etc. |
| 2389 | - if(!empty($fieldDef['dbType'])) |
|
| 2389 | + if (!empty($fieldDef['dbType'])) |
|
| 2390 | 2390 | return $fieldDef['dbType']; |
| 2391 | - if(!empty($fieldDef['dbtype'])) |
|
| 2391 | + if (!empty($fieldDef['dbtype'])) |
|
| 2392 | 2392 | return $fieldDef['dbtype']; |
| 2393 | 2393 | if (!empty($fieldDef['type'])) |
| 2394 | 2394 | return $fieldDef['type']; |
@@ -2408,17 +2408,17 @@ discard block |
||
| 2408 | 2408 | */ |
| 2409 | 2409 | public function getTypeParts($type) |
| 2410 | 2410 | { |
| 2411 | - if(preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2411 | + if (preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2412 | 2412 | { |
| 2413 | - $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2413 | + $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2414 | 2414 | $return['baseType'] = $matches['type']; |
| 2415 | - if( isset($matches['arg'])) { |
|
| 2415 | + if (isset($matches['arg'])) { |
|
| 2416 | 2416 | $return['arg'] = $matches['arg']; |
| 2417 | 2417 | } |
| 2418 | - if( isset($matches['len'])) { |
|
| 2418 | + if (isset($matches['len'])) { |
|
| 2419 | 2419 | $return['len'] = $matches['len']; |
| 2420 | 2420 | } |
| 2421 | - if( isset($matches['scale'])) { |
|
| 2421 | + if (isset($matches['scale'])) { |
|
| 2422 | 2422 | $return['scale'] = $matches['scale']; |
| 2423 | 2423 | } |
| 2424 | 2424 | return $return; |
@@ -2442,28 +2442,28 @@ discard block |
||
| 2442 | 2442 | $type = $this->getFieldType($fieldDef); |
| 2443 | 2443 | $colType = $this->getColumnType($type); |
| 2444 | 2444 | |
| 2445 | - if($parts = $this->getTypeParts($colType)) |
|
| 2445 | + if ($parts = $this->getTypeParts($colType)) |
|
| 2446 | 2446 | { |
| 2447 | 2447 | $colBaseType = $parts['baseType']; |
| 2448 | - $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2448 | + $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | - if(!empty($fieldDef['len'])) { |
|
| 2452 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2451 | + if (!empty($fieldDef['len'])) { |
|
| 2452 | + if (in_array($colBaseType, array('nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2453 | 2453 | 'clob', 'blob', 'text'))) { |
| 2454 | 2454 | $colType = "$colBaseType(${fieldDef['len']})"; |
| 2455 | - } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
|
| 2456 | - if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | - if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | - $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | - }else{ |
|
| 2460 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2455 | + } elseif (($colBaseType == 'decimal' || $colBaseType == 'float')) { |
|
| 2456 | + if (!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | + if (strpos($fieldDef['len'], ',') === false) { |
|
| 2458 | + $colType = $colBaseType."(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | + } else { |
|
| 2460 | + $colType = $colBaseType."(".$fieldDef['len'].")"; |
|
| 2461 | 2461 | } |
| 2462 | 2462 | else |
| 2463 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2463 | + $colType = $colBaseType."(".$fieldDef['len'].")"; |
|
| 2464 | 2464 | } |
| 2465 | 2465 | } else { |
| 2466 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2466 | + if (in_array($colBaseType, array('nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2467 | 2467 | $colType = "$colBaseType($defLen)"; |
| 2468 | 2468 | } |
| 2469 | 2469 | } |
@@ -2485,29 +2485,29 @@ discard block |
||
| 2485 | 2485 | } |
| 2486 | 2486 | |
| 2487 | 2487 | $auto_increment = ''; |
| 2488 | - if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | - $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2488 | + if (!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | + $auto_increment = $this->setAutoIncrement($table, $fieldDef['name']); |
|
| 2490 | 2490 | |
| 2491 | - $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2491 | + $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2492 | 2492 | //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
| 2493 | 2493 | if ((empty($fieldDef['isnull']) || strtolower($fieldDef['isnull']) == 'false') && |
| 2494 | 2494 | (!empty($auto_increment) || $name == 'id' || ($fieldDef['type'] == 'id' && !empty($fieldDef['required'])))) { |
| 2495 | - $required = "NOT NULL"; |
|
| 2495 | + $required = "NOT NULL"; |
|
| 2496 | 2496 | } |
| 2497 | 2497 | // If the field is marked both required & isnull=>false - alwqys make it not null |
| 2498 | 2498 | // Use this to ensure primary key fields never defined as null |
| 2499 | - if(isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2499 | + if (isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2500 | 2500 | && !empty($fieldDef['required'])) { |
| 2501 | - $required = "NOT NULL"; |
|
| 2501 | + $required = "NOT NULL"; |
|
| 2502 | 2502 | } |
| 2503 | 2503 | if ($ignoreRequired) |
| 2504 | 2504 | $required = ""; |
| 2505 | 2505 | |
| 2506 | - if ( $return_as_array ) { |
|
| 2506 | + if ($return_as_array) { |
|
| 2507 | 2507 | return array( |
| 2508 | 2508 | 'name' => $name, |
| 2509 | 2509 | 'colType' => $colType, |
| 2510 | - 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2510 | + 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2511 | 2511 | 'default' => $default, |
| 2512 | 2512 | 'required' => $required, |
| 2513 | 2513 | 'auto_increment' => $auto_increment, |
@@ -2532,14 +2532,14 @@ discard block |
||
| 2532 | 2532 | |
| 2533 | 2533 | if ($this->isFieldArray($fieldDefs)) { |
| 2534 | 2534 | foreach ($fieldDefs as $fieldDef) { |
| 2535 | - if(!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | - $columns[] = $this->oneColumnSQLRep($fieldDef,false, $tablename); |
|
| 2535 | + if (!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | + $columns[] = $this->oneColumnSQLRep($fieldDef, false, $tablename); |
|
| 2537 | 2537 | } |
| 2538 | 2538 | } |
| 2539 | 2539 | $columns = implode(",", $columns); |
| 2540 | 2540 | } |
| 2541 | 2541 | else { |
| 2542 | - $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
|
| 2542 | + $columns = $this->oneColumnSQLRep($fieldDefs, $ignoreRequired, $tablename); |
|
| 2543 | 2543 | } |
| 2544 | 2544 | |
| 2545 | 2545 | return $columns; |
@@ -2701,40 +2701,40 @@ discard block |
||
| 2701 | 2701 | */ |
| 2702 | 2702 | public function getValidDBName($name, $ensureUnique = false, $type = 'column', $force = false) |
| 2703 | 2703 | { |
| 2704 | - if(is_array($name)) { |
|
| 2704 | + if (is_array($name)) { |
|
| 2705 | 2705 | $result = array(); |
| 2706 | - foreach($name as $field) { |
|
| 2706 | + foreach ($name as $field) { |
|
| 2707 | 2707 | $result[] = $this->getValidDBName($field, $ensureUnique, $type); |
| 2708 | 2708 | } |
| 2709 | 2709 | return $result; |
| 2710 | 2710 | } else { |
| 2711 | - if(strchr($name, ".")) { |
|
| 2711 | + if (strchr($name, ".")) { |
|
| 2712 | 2712 | // this is a compound name with dots, handle separately |
| 2713 | 2713 | $parts = explode(".", $name); |
| 2714 | - if(count($parts) > 2) { |
|
| 2714 | + if (count($parts) > 2) { |
|
| 2715 | 2715 | // some weird name, cut to table.name |
| 2716 | - array_splice($parts, 0, count($parts)-2); |
|
| 2716 | + array_splice($parts, 0, count($parts) - 2); |
|
| 2717 | 2717 | } |
| 2718 | 2718 | $parts = $this->getValidDBName($parts, $ensureUnique, $type, $force); |
| 2719 | 2719 | return join(".", $parts); |
| 2720 | 2720 | } |
| 2721 | 2721 | // first strip any invalid characters - all but word chars (which is alphanumeric and _) |
| 2722 | - $name = preg_replace( '/[^\w]+/i', '', $name ) ; |
|
| 2723 | - $len = strlen( $name ) ; |
|
| 2722 | + $name = preg_replace('/[^\w]+/i', '', $name); |
|
| 2723 | + $len = strlen($name); |
|
| 2724 | 2724 | $maxLen = empty($this->maxNameLengths[$type]) ? $this->maxNameLengths[$type]['column'] : $this->maxNameLengths[$type]; |
| 2725 | 2725 | if ($len <= $maxLen && !$force) { |
| 2726 | 2726 | return strtolower($name); |
| 2727 | 2727 | } |
| 2728 | 2728 | if ($ensureUnique) { |
| 2729 | 2729 | $md5str = md5($name); |
| 2730 | - $tail = substr ( $name, -11) ; |
|
| 2731 | - $temp = substr($md5str , strlen($md5str)-4 ); |
|
| 2732 | - $result = substr( $name, 0, 10) . $temp . $tail ; |
|
| 2730 | + $tail = substr($name, -11); |
|
| 2731 | + $temp = substr($md5str, strlen($md5str) - 4); |
|
| 2732 | + $result = substr($name, 0, 10).$temp.$tail; |
|
| 2733 | 2733 | } else { |
| 2734 | - $result = substr( $name, 0, 11) . substr( $name, 11 - $maxLen); |
|
| 2734 | + $result = substr($name, 0, 11).substr($name, 11 - $maxLen); |
|
| 2735 | 2735 | } |
| 2736 | 2736 | |
| 2737 | - return strtolower( $result ) ; |
|
| 2737 | + return strtolower($result); |
|
| 2738 | 2738 | } |
| 2739 | 2739 | } |
| 2740 | 2740 | |
@@ -2746,7 +2746,7 @@ discard block |
||
| 2746 | 2746 | */ |
| 2747 | 2747 | public function getColumnType($type) |
| 2748 | 2748 | { |
| 2749 | - return isset($this->type_map[$type])?$this->type_map[$type]:$type; |
|
| 2749 | + return isset($this->type_map[$type]) ? $this->type_map[$type] : $type; |
|
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | 2752 | /** |
@@ -2760,10 +2760,10 @@ discard block |
||
| 2760 | 2760 | */ |
| 2761 | 2761 | public function isFieldArray($defArray) |
| 2762 | 2762 | { |
| 2763 | - if ( !is_array($defArray) ) |
|
| 2763 | + if (!is_array($defArray)) |
|
| 2764 | 2764 | return false; |
| 2765 | 2765 | |
| 2766 | - if ( isset($defArray['type']) ){ |
|
| 2766 | + if (isset($defArray['type'])) { |
|
| 2767 | 2767 | // type key exists. May be an array of defs or a simple definition |
| 2768 | 2768 | return is_array($defArray['type']); // type is not an array => definition else array |
| 2769 | 2769 | } |
@@ -2798,19 +2798,19 @@ discard block |
||
| 2798 | 2798 | require('metadata/audit_templateMetaData.php'); |
| 2799 | 2799 | $fieldDefs = $dictionary['audit']['fields']; |
| 2800 | 2800 | |
| 2801 | - $values=array(); |
|
| 2801 | + $values = array(); |
|
| 2802 | 2802 | $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']); |
| 2803 | - $values['parent_id']= $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | - $values['field_name']= $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2803 | + $values['parent_id'] = $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | + $values['field_name'] = $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2805 | 2805 | $values['data_type'] = $this->massageValue($changes['data_type'], $fieldDefs['data_type']); |
| 2806 | - if ($changes['data_type']=='text') { |
|
| 2806 | + if ($changes['data_type'] == 'text') { |
|
| 2807 | 2807 | $values['before_value_text'] = $this->massageValue($changes['before'], $fieldDefs['before_value_text']); |
| 2808 | 2808 | $values['after_value_text'] = $this->massageValue($changes['after'], $fieldDefs['after_value_text']); |
| 2809 | 2809 | } else { |
| 2810 | 2810 | $values['before_value_string'] = $this->massageValue($changes['before'], $fieldDefs['before_value_string']); |
| 2811 | 2811 | $values['after_value_string'] = $this->massageValue($changes['after'], $fieldDefs['after_value_string']); |
| 2812 | 2812 | } |
| 2813 | - $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created'] ); |
|
| 2813 | + $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created']); |
|
| 2814 | 2814 | $values['created_by'] = $this->massageValue($current_user->id, $fieldDefs['created_by']); |
| 2815 | 2815 | |
| 2816 | 2816 | $sql .= "(".implode(",", array_keys($values)).") "; |
@@ -2840,9 +2840,9 @@ discard block |
||
| 2840 | 2840 | * @param array|null $field_filter Array of filter names to be inspected (NULL means all fields) |
| 2841 | 2841 | * @return array |
| 2842 | 2842 | */ |
| 2843 | - public function getDataChanges(SugarBean &$bean, array $field_filter = null) |
|
| 2843 | + public function getDataChanges(SugarBean & $bean, array $field_filter = null) |
|
| 2844 | 2844 | { |
| 2845 | - $changed_values=array(); |
|
| 2845 | + $changed_values = array(); |
|
| 2846 | 2846 | |
| 2847 | 2847 | $fetched_row = array(); |
| 2848 | 2848 | if (is_array($bean->fetched_row)) |
@@ -2862,40 +2862,40 @@ discard block |
||
| 2862 | 2862 | $field_defs = array_intersect_key($field_defs, $fetched_row); |
| 2863 | 2863 | |
| 2864 | 2864 | // remove fields which do not exist as bean property |
| 2865 | - $field_defs = array_intersect_key($field_defs, (array) $bean); |
|
| 2865 | + $field_defs = array_intersect_key($field_defs, (array)$bean); |
|
| 2866 | 2866 | |
| 2867 | 2867 | foreach ($field_defs as $field => $properties) { |
| 2868 | 2868 | $before_value = $fetched_row[$field]; |
| 2869 | - $after_value=$bean->$field; |
|
| 2869 | + $after_value = $bean->$field; |
|
| 2870 | 2870 | if (isset($properties['type'])) { |
| 2871 | - $field_type=$properties['type']; |
|
| 2871 | + $field_type = $properties['type']; |
|
| 2872 | 2872 | } else { |
| 2873 | 2873 | if (isset($properties['dbType'])) { |
| 2874 | - $field_type=$properties['dbType']; |
|
| 2874 | + $field_type = $properties['dbType']; |
|
| 2875 | 2875 | } |
| 2876 | - else if(isset($properties['data_type'])) { |
|
| 2877 | - $field_type=$properties['data_type']; |
|
| 2876 | + else if (isset($properties['data_type'])) { |
|
| 2877 | + $field_type = $properties['data_type']; |
|
| 2878 | 2878 | } |
| 2879 | 2879 | else { |
| 2880 | - $field_type=$properties['dbtype']; |
|
| 2880 | + $field_type = $properties['dbtype']; |
|
| 2881 | 2881 | } |
| 2882 | 2882 | } |
| 2883 | 2883 | |
| 2884 | 2884 | //Because of bug #25078(sqlserver haven't 'date' type, trim extra "00:00:00" when insert into *_cstm table). |
| 2885 | 2885 | // so when we read the audit datetime field from sqlserver, we have to replace the extra "00:00:00" again. |
| 2886 | - if(!empty($field_type) && $field_type == 'date'){ |
|
| 2887 | - $before_value = $this->fromConvert($before_value , $field_type); |
|
| 2886 | + if (!empty($field_type) && $field_type == 'date') { |
|
| 2887 | + $before_value = $this->fromConvert($before_value, $field_type); |
|
| 2888 | 2888 | } |
| 2889 | 2889 | //if the type and values match, do nothing. |
| 2890 | - if (!($this->_emptyValue($before_value,$field_type) && $this->_emptyValue($after_value,$field_type))) { |
|
| 2890 | + if (!($this->_emptyValue($before_value, $field_type) && $this->_emptyValue($after_value, $field_type))) { |
|
| 2891 | 2891 | $change = false; |
| 2892 | 2892 | if (trim($before_value) !== trim($after_value)) { |
| 2893 | 2893 | // Bug #42475: Don't directly compare numeric values, instead do the subtract and see if the comparison comes out to be "close enough", it is necessary for floating point numbers. |
| 2894 | 2894 | // Manual merge of fix 95727f2eed44852f1b6bce9a9eccbe065fe6249f from DBHelper |
| 2895 | 2895 | // This fix also fixes Bug #44624 in a more generic way and therefore eliminates the need for fix 0a55125b281c4bee87eb347709af462715f33d2d in DBHelper |
| 2896 | 2896 | if ($this->isNumericType($field_type)) { |
| 2897 | - $numerator = abs(2*((trim($before_value)+0)-(trim($after_value)+0))); |
|
| 2898 | - $denominator = abs(((trim($before_value)+0)+(trim($after_value)+0))); |
|
| 2897 | + $numerator = abs(2 * ((trim($before_value) + 0) - (trim($after_value) + 0))); |
|
| 2898 | + $denominator = abs(((trim($before_value) + 0) + (trim($after_value) + 0))); |
|
| 2899 | 2899 | // detect whether to use absolute or relative error. use absolute if denominator is zero to avoid division by zero |
| 2900 | 2900 | $error = ($denominator == 0) ? $numerator : $numerator / $denominator; |
| 2901 | 2901 | if ($error >= 0.0000000001) { // Smaller than 10E-10 |
@@ -2911,7 +2911,7 @@ discard block |
||
| 2911 | 2911 | $change = true; |
| 2912 | 2912 | } |
| 2913 | 2913 | if ($change) { |
| 2914 | - $changed_values[$field]=array('field_name'=>$field, |
|
| 2914 | + $changed_values[$field] = array('field_name'=>$field, |
|
| 2915 | 2915 | 'data_type'=>$field_type, |
| 2916 | 2916 | 'before'=>$before_value, |
| 2917 | 2917 | 'after'=>$after_value); |
@@ -2982,8 +2982,8 @@ discard block |
||
| 2982 | 2982 | */ |
| 2983 | 2983 | public function renameIndexDefs($old_definition, $new_definition, $table_name) |
| 2984 | 2984 | { |
| 2985 | - return array($this->add_drop_constraint($table_name,$old_definition,true), |
|
| 2986 | - $this->add_drop_constraint($table_name,$new_definition), false); |
|
| 2985 | + return array($this->add_drop_constraint($table_name, $old_definition, true), |
|
| 2986 | + $this->add_drop_constraint($table_name, $new_definition), false); |
|
| 2987 | 2987 | } |
| 2988 | 2988 | |
| 2989 | 2989 | /** |
@@ -3005,7 +3005,7 @@ discard block |
||
| 3005 | 3005 | protected function _getBooleanValue($val) |
| 3006 | 3006 | { |
| 3007 | 3007 | //need to put the === sign here otherwise true == 'non empty string' |
| 3008 | - if (empty($val) or $val==='off') |
|
| 3008 | + if (empty($val) or $val === 'off') |
|
| 3009 | 3009 | return false; |
| 3010 | 3010 | |
| 3011 | 3011 | return true; |
@@ -3018,7 +3018,7 @@ discard block |
||
| 3018 | 3018 | */ |
| 3019 | 3019 | public function isNumericType($type) |
| 3020 | 3020 | { |
| 3021 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3021 | + if (isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3022 | 3022 | return true; |
| 3023 | 3023 | } |
| 3024 | 3024 | return false; |
@@ -3035,7 +3035,7 @@ discard block |
||
| 3035 | 3035 | if (empty($val)) |
| 3036 | 3036 | return true; |
| 3037 | 3037 | |
| 3038 | - if($this->emptyValue($type) == $val) { |
|
| 3038 | + if ($this->emptyValue($type) == $val) { |
|
| 3039 | 3039 | return true; |
| 3040 | 3040 | } |
| 3041 | 3041 | switch ($type) { |
@@ -3094,7 +3094,7 @@ discard block |
||
| 3094 | 3094 | $i = 0; |
| 3095 | 3095 | $order_by_arr = array(); |
| 3096 | 3096 | foreach ($values as $key => $value) { |
| 3097 | - if($key == '') { |
|
| 3097 | + if ($key == '') { |
|
| 3098 | 3098 | $order_by_arr[] = "WHEN ($order_by='' OR $order_by IS NULL) THEN $i"; |
| 3099 | 3099 | } else { |
| 3100 | 3100 | $order_by_arr[] = "WHEN $order_by=".$this->quoted($key)." THEN $i"; |
@@ -3112,7 +3112,7 @@ discard block |
||
| 3112 | 3112 | */ |
| 3113 | 3113 | public function emptyValue($type) |
| 3114 | 3114 | { |
| 3115 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3115 | + if (isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3116 | 3116 | return 0; |
| 3117 | 3117 | } |
| 3118 | 3118 | |
@@ -3161,9 +3161,9 @@ discard block |
||
| 3161 | 3161 | * @return resource|bool query result |
| 3162 | 3162 | * @see DBManager::limitQuery() |
| 3163 | 3163 | */ |
| 3164 | - public function limitQuerySql($sql, $start, $count, $dieOnError=false, $msg='') |
|
| 3164 | + public function limitQuerySql($sql, $start, $count, $dieOnError = false, $msg = '') |
|
| 3165 | 3165 | { |
| 3166 | - return $this->limitQuery($sql,$start,$count,$dieOnError,$msg,false); |
|
| 3166 | + return $this->limitQuery($sql, $start, $count, $dieOnError, $msg, false); |
|
| 3167 | 3167 | } |
| 3168 | 3168 | |
| 3169 | 3169 | /** |
@@ -3182,7 +3182,7 @@ discard block |
||
| 3182 | 3182 | */ |
| 3183 | 3183 | public function checkPrivilege($privilege) |
| 3184 | 3184 | { |
| 3185 | - switch($privilege) { |
|
| 3185 | + switch ($privilege) { |
|
| 3186 | 3186 | case "CREATE TABLE": |
| 3187 | 3187 | $this->query("CREATE TABLE temp (id varchar(36))"); |
| 3188 | 3188 | break; |
@@ -3203,23 +3203,23 @@ discard block |
||
| 3203 | 3203 | break; |
| 3204 | 3204 | case "ADD COLUMN": |
| 3205 | 3205 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 50)); |
| 3206 | - $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3206 | + $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3207 | 3207 | $this->query($sql); |
| 3208 | 3208 | break; |
| 3209 | 3209 | case "CHANGE COLUMN": |
| 3210 | 3210 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
| 3211 | - $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3211 | + $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3212 | 3212 | $this->query($sql); |
| 3213 | 3213 | break; |
| 3214 | 3214 | case "DROP COLUMN": |
| 3215 | 3215 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
| 3216 | - $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3216 | + $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3217 | 3217 | $this->query($sql); |
| 3218 | 3218 | break; |
| 3219 | 3219 | default: |
| 3220 | 3220 | return false; |
| 3221 | 3221 | } |
| 3222 | - if($this->checkError("Checking privileges")) { |
|
| 3222 | + if ($this->checkError("Checking privileges")) { |
|
| 3223 | 3223 | return false; |
| 3224 | 3224 | } |
| 3225 | 3225 | return true; |
@@ -3236,7 +3236,7 @@ discard block |
||
| 3236 | 3236 | $select_check = strpos(strtolower($query), strtolower("SELECT")); |
| 3237 | 3237 | //Checks to see if there is union select which is valid |
| 3238 | 3238 | $select_check2 = strpos(strtolower($query), strtolower("(SELECT")); |
| 3239 | - if($select_check==0 || $select_check2==0){ |
|
| 3239 | + if ($select_check == 0 || $select_check2 == 0) { |
|
| 3240 | 3240 | //Returning false means query is ok! |
| 3241 | 3241 | return true; |
| 3242 | 3242 | } |
@@ -3255,10 +3255,10 @@ discard block |
||
| 3255 | 3255 | public function parseFulltextQuery($query) |
| 3256 | 3256 | { |
| 3257 | 3257 | /* split on space or comma, double quotes with \ for escape */ |
| 3258 | - if(strpbrk($query, " ,")) { |
|
| 3258 | + if (strpbrk($query, " ,")) { |
|
| 3259 | 3259 | // ("([^"]*?)"|[^" ,]+)((, )+)? |
| 3260 | 3260 | // '/([^" ,]+|".*?[^\\\\]")(,|\s)\s*/' |
| 3261 | - if(!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3261 | + if (!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3262 | 3262 | return false; |
| 3263 | 3263 | } |
| 3264 | 3264 | $qterms = $m[1]; |
@@ -3266,17 +3266,17 @@ discard block |
||
| 3266 | 3266 | $qterms = array($query); |
| 3267 | 3267 | } |
| 3268 | 3268 | $terms = $must_terms = $not_terms = array(); |
| 3269 | - foreach($qterms as $item) { |
|
| 3270 | - if($item[0] == '"') { |
|
| 3269 | + foreach ($qterms as $item) { |
|
| 3270 | + if ($item[0] == '"') { |
|
| 3271 | 3271 | $item = trim($item, '"'); |
| 3272 | 3272 | } |
| 3273 | - if($item[0] == '+') { |
|
| 3273 | + if ($item[0] == '+') { |
|
| 3274 | 3274 | if (strlen($item) > 1) { |
| 3275 | 3275 | $must_terms[] = substr($item, 1); |
| 3276 | 3276 | } |
| 3277 | 3277 | continue; |
| 3278 | 3278 | } |
| 3279 | - if($item[0] == '-') { |
|
| 3279 | + if ($item[0] == '-') { |
|
| 3280 | 3280 | if (strlen($item) > 1) { |
| 3281 | 3281 | $not_terms[] = substr($item, 1); |
| 3282 | 3282 | } |
@@ -3325,11 +3325,11 @@ discard block |
||
| 3325 | 3325 | public function verifySQLStatement($query, $skipTables) |
| 3326 | 3326 | { |
| 3327 | 3327 | $query = trim($query); |
| 3328 | - foreach($this->standardQueries as $qstart => $check) { |
|
| 3329 | - if(strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | - if(is_callable(array($this, $check))) { |
|
| 3328 | + foreach ($this->standardQueries as $qstart => $check) { |
|
| 3329 | + if (strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | + if (is_callable(array($this, $check))) { |
|
| 3331 | 3331 | $table = $this->extractTableName($query); |
| 3332 | - if(!in_array($table, $skipTables)) { |
|
| 3332 | + if (!in_array($table, $skipTables)) { |
|
| 3333 | 3333 | return call_user_func(array($this, $check), $table, $query); |
| 3334 | 3334 | } else { |
| 3335 | 3335 | $this->log->debug("Skipping table $table as blacklisted"); |
@@ -3358,20 +3358,20 @@ discard block |
||
| 3358 | 3358 | $tempname = $table."__uw_temp"; |
| 3359 | 3359 | $tempTableQuery = str_replace("CREATE TABLE {$table}", "CREATE TABLE $tempname", $query); |
| 3360 | 3360 | |
| 3361 | - if(strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3361 | + if (strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3362 | 3362 | return 'Could not use a temp table to test query!'; |
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | $this->query($tempTableQuery, false, "Preflight Failed for: {$query}"); |
| 3366 | 3366 | |
| 3367 | 3367 | $error = $this->lastError(); // empty on no-errors |
| 3368 | - if(!empty($error)) { |
|
| 3368 | + if (!empty($error)) { |
|
| 3369 | 3369 | return $error; |
| 3370 | 3370 | } |
| 3371 | 3371 | |
| 3372 | 3372 | // check if table exists |
| 3373 | 3373 | $this->log->debug('testing for table: '.$table); |
| 3374 | - if(!$this->tableExists($tempname)) { |
|
| 3374 | + if (!$this->tableExists($tempname)) { |
|
| 3375 | 3375 | return "Failed to create temp table!"; |
| 3376 | 3376 | } |
| 3377 | 3377 | |
@@ -3390,8 +3390,8 @@ discard block |
||
| 3390 | 3390 | public function queryArray(array $sqls, $dieOnError = false, $msg = '', $suppress = false) |
| 3391 | 3391 | { |
| 3392 | 3392 | $last = true; |
| 3393 | - foreach($sqls as $sql) { |
|
| 3394 | - if(!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3393 | + foreach ($sqls as $sql) { |
|
| 3394 | + if (!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3395 | 3395 | break; |
| 3396 | 3396 | } |
| 3397 | 3397 | } |
@@ -3409,7 +3409,7 @@ discard block |
||
| 3409 | 3409 | { |
| 3410 | 3410 | if (empty($result)) return false; |
| 3411 | 3411 | |
| 3412 | - if(is_int($encode) && func_num_args() == 3) { |
|
| 3412 | + if (is_int($encode) && func_num_args() == 3) { |
|
| 3413 | 3413 | // old API: $result, $rowNum, $encode |
| 3414 | 3414 | $GLOBALS['log']->deprecated("Using row number in fetchByAssoc is not portable and no longer supported. Please fix your code."); |
| 3415 | 3415 | $encode = func_get_arg(2); |
@@ -3460,7 +3460,7 @@ discard block |
||
| 3460 | 3460 | */ |
| 3461 | 3461 | public function getOption($option) |
| 3462 | 3462 | { |
| 3463 | - if(isset($this->options[$option])) { |
|
| 3463 | + if (isset($this->options[$option])) { |
|
| 3464 | 3464 | return $this->options[$option]; |
| 3465 | 3465 | } |
| 3466 | 3466 | return null; |
@@ -3500,7 +3500,7 @@ discard block |
||
| 3500 | 3500 | public function isDatabaseNameValid($name) |
| 3501 | 3501 | { |
| 3502 | 3502 | // Generic case - no slashes, no dots |
| 3503 | - return preg_match('#[/.\\\\]#', $name)==0; |
|
| 3503 | + return preg_match('#[/.\\\\]#', $name) == 0; |
|
| 3504 | 3504 | } |
| 3505 | 3505 | |
| 3506 | 3506 | /** |
@@ -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. |
@@ -403,13 +405,15 @@ discard block |
||
| 403 | 405 | $match = array(); |
| 404 | 406 | preg_match_all("'.* FROM ([^ ]*).* ORDER BY (.*)'is", $sql, $match); |
| 405 | 407 | $indices = false; |
| 406 | - if (!empty($match[1][0])) |
|
| 407 | - $table = $match[1][0]; |
|
| 408 | - else |
|
| 409 | - return false; |
|
| 408 | + if (!empty($match[1][0])) { |
|
| 409 | + $table = $match[1][0]; |
|
| 410 | + } else { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 410 | 413 | |
| 411 | - if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) |
|
| 412 | - $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 414 | + if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) { |
|
| 415 | + $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 416 | + } |
|
| 413 | 417 | |
| 414 | 418 | if (empty($indices)) { |
| 415 | 419 | foreach ( $GLOBALS['dictionary'] as $current ) { |
@@ -427,25 +431,29 @@ discard block |
||
| 427 | 431 | $orderBys = explode(' ', $match[2][0]); |
| 428 | 432 | foreach ($orderBys as $orderBy){ |
| 429 | 433 | $orderBy = trim($orderBy); |
| 430 | - if (empty($orderBy)) |
|
| 431 | - continue; |
|
| 434 | + if (empty($orderBy)) { |
|
| 435 | + continue; |
|
| 436 | + } |
|
| 432 | 437 | $orderBy = strtolower($orderBy); |
| 433 | - if ($orderBy == 'asc' || $orderBy == 'desc') |
|
| 434 | - continue; |
|
| 438 | + if ($orderBy == 'asc' || $orderBy == 'desc') { |
|
| 439 | + continue; |
|
| 440 | + } |
|
| 435 | 441 | |
| 436 | 442 | $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
| 437 | 443 | |
| 438 | - foreach ($indices as $index) |
|
| 439 | - if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 444 | + foreach ($indices as $index) { |
|
| 445 | + if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 440 | 446 | foreach ($index['fields'] as $field) |
| 441 | 447 | if ($field == $orderBy) |
| 442 | 448 | return true; |
| 449 | + } |
|
| 443 | 450 | |
| 444 | 451 | $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
| 445 | - if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
|
| 446 | - $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 447 | - else |
|
| 448 | - $this->log->warn('CHECK QUERY:' .$warning); |
|
| 452 | + if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) { |
|
| 453 | + $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 454 | + } else { |
|
| 455 | + $this->log->warn('CHECK QUERY:' .$warning); |
|
| 456 | + } |
|
| 449 | 457 | } |
| 450 | 458 | } |
| 451 | 459 | return false; |
@@ -467,8 +475,9 @@ discard block |
||
| 467 | 475 | public function checkConnection() |
| 468 | 476 | { |
| 469 | 477 | $this->last_error = ''; |
| 470 | - if (!isset($this->database)) |
|
| 471 | - $this->connect(); |
|
| 478 | + if (!isset($this->database)) { |
|
| 479 | + $this->connect(); |
|
| 480 | + } |
|
| 472 | 481 | } |
| 473 | 482 | |
| 474 | 483 | /** |
@@ -510,9 +519,13 @@ discard block |
||
| 510 | 519 | $values = array(); |
| 511 | 520 | foreach ($field_defs as $field => $fieldDef) |
| 512 | 521 | { |
| 513 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 522 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') { |
|
| 523 | + continue; |
|
| 524 | + } |
|
| 514 | 525 | //custom fields handle there save seperatley |
| 515 | - if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 526 | + if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) { |
|
| 527 | + continue; |
|
| 528 | + } |
|
| 516 | 529 | |
| 517 | 530 | if(isset($data[$field])) { |
| 518 | 531 | // clean the incoming value.. |
@@ -541,8 +554,10 @@ discard block |
||
| 541 | 554 | } |
| 542 | 555 | } |
| 543 | 556 | |
| 544 | - if (empty($values)) |
|
| 545 | - return $execute?true:''; // no columns set |
|
| 557 | + if (empty($values)) { |
|
| 558 | + return $execute?true:''; |
|
| 559 | + } |
|
| 560 | + // no columns set |
|
| 546 | 561 | |
| 547 | 562 | // get the entire sql |
| 548 | 563 | $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
@@ -642,9 +657,10 @@ discard block |
||
| 642 | 657 | if(!$this->supports("inline_keys")) { |
| 643 | 658 | // handle constraints and indices |
| 644 | 659 | $indicesArr = $this->createConstraintSql($bean); |
| 645 | - if (count($indicesArr) > 0) |
|
| 646 | - foreach ($indicesArr as $indexSql) |
|
| 660 | + if (count($indicesArr) > 0) { |
|
| 661 | + foreach ($indicesArr as $indexSql) |
|
| 647 | 662 | $this->query($indexSql, true, $msg); |
| 663 | + } |
|
| 648 | 664 | } |
| 649 | 665 | } |
| 650 | 666 | |
@@ -681,9 +697,10 @@ discard block |
||
| 681 | 697 | if(!$this->supports("inline_keys")) { |
| 682 | 698 | // handle constraints and indices |
| 683 | 699 | $indicesArr = $this->getConstraintSql($indices, $tablename); |
| 684 | - if (count($indicesArr) > 0) |
|
| 685 | - foreach ($indicesArr as $indexSql) |
|
| 700 | + if (count($indicesArr) > 0) { |
|
| 701 | + foreach ($indicesArr as $indexSql) |
|
| 686 | 702 | $res = ($res and $this->query($indexSql, true, "Error creating indexes")); |
| 703 | + } |
|
| 687 | 704 | } |
| 688 | 705 | return $res; |
| 689 | 706 | } |
@@ -710,13 +727,15 @@ discard block |
||
| 710 | 727 | } |
| 711 | 728 | //jc: added this for beans that do not actually have a table, namely |
| 712 | 729 | //ForecastOpportunities |
| 713 | - if($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | - return ''; |
|
| 730 | + if($tablename == 'does_not_exist' || $tablename == '') { |
|
| 731 | + return ''; |
|
| 732 | + } |
|
| 715 | 733 | |
| 716 | 734 | global $dictionary; |
| 717 | 735 | $engine=null; |
| 718 | - if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 719 | - $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 736 | + if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) { |
|
| 737 | + $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 738 | + } |
|
| 720 | 739 | |
| 721 | 740 | return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
| 722 | 741 | } |
@@ -760,8 +779,9 @@ discard block |
||
| 760 | 779 | { |
| 761 | 780 | //jc: had a bug when running the repair if the tablename is blank the repair will |
| 762 | 781 | //fail when it tries to create a repair table |
| 763 | - if ($tablename == '' || empty($fielddefs)) |
|
| 764 | - return ''; |
|
| 782 | + if ($tablename == '' || empty($fielddefs)) { |
|
| 783 | + return ''; |
|
| 784 | + } |
|
| 765 | 785 | |
| 766 | 786 | //if the table does not exist create it and we are done |
| 767 | 787 | $sql = "/* Table : $tablename */\n"; |
@@ -784,16 +804,16 @@ discard block |
||
| 784 | 804 | // do column comparisons |
| 785 | 805 | $sql .= "/*COLUMNS*/\n"; |
| 786 | 806 | foreach ($fielddefs as $name => $value) { |
| 787 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 788 | - continue; |
|
| 807 | + if (isset($value['source']) && $value['source'] != 'db') { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 789 | 810 | |
| 790 | 811 | // Bug #42406. Skipping breaked vardef without type or name |
| 791 | 812 | if (isset($value['name']) == false || $value['name'] == false) |
| 792 | 813 | { |
| 793 | 814 | $sql .= "/* NAME IS MISSING IN VARDEF $tablename::$name */\n"; |
| 794 | 815 | continue; |
| 795 | - } |
|
| 796 | - else if (isset($value['type']) == false || $value['type'] == false) |
|
| 816 | + } else if (isset($value['type']) == false || $value['type'] == false) |
|
| 797 | 817 | { |
| 798 | 818 | $sql .= "/* TYPE IS MISSING IN VARDEF $tablename::$name */\n"; |
| 799 | 819 | continue; |
@@ -823,8 +843,9 @@ discard block |
||
| 823 | 843 | // ok we need this field lets create it |
| 824 | 844 | $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
| 825 | 845 | $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
| 826 | - if ($execute) |
|
| 827 | - $this->addColumn($tablename, $value); |
|
| 846 | + if ($execute) { |
|
| 847 | + $this->addColumn($tablename, $value); |
|
| 848 | + } |
|
| 828 | 849 | $take_action = true; |
| 829 | 850 | } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
| 830 | 851 | //fields are different lets alter it |
@@ -880,8 +901,9 @@ discard block |
||
| 880 | 901 | unset($compareIndices_case_insensitive); |
| 881 | 902 | |
| 882 | 903 | foreach ($indices as $value) { |
| 883 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 884 | - continue; |
|
| 904 | + if (isset($value['source']) && $value['source'] != 'db') { |
|
| 905 | + continue; |
|
| 906 | + } |
|
| 885 | 907 | |
| 886 | 908 | |
| 887 | 909 | $validDBName = $this->getValidDBName($value['name'], true, 'index', true); |
@@ -891,19 +913,23 @@ discard block |
||
| 891 | 913 | $name = strtolower($value['name']); |
| 892 | 914 | |
| 893 | 915 | //Don't attempt to fix the same index twice in one pass; |
| 894 | - if (isset($correctedIndexs[$name])) |
|
| 895 | - continue; |
|
| 916 | + if (isset($correctedIndexs[$name])) { |
|
| 917 | + continue; |
|
| 918 | + } |
|
| 896 | 919 | |
| 897 | 920 | //don't bother checking primary nothing we can do about them |
| 898 | - if (isset($value['type']) && $value['type'] == 'primary') |
|
| 899 | - continue; |
|
| 921 | + if (isset($value['type']) && $value['type'] == 'primary') { |
|
| 922 | + continue; |
|
| 923 | + } |
|
| 900 | 924 | |
| 901 | 925 | //database helpers do not know how to handle full text indices |
| 902 | - if ($value['type']=='fulltext') |
|
| 903 | - continue; |
|
| 926 | + if ($value['type']=='fulltext') { |
|
| 927 | + continue; |
|
| 928 | + } |
|
| 904 | 929 | |
| 905 | - if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 906 | - $value['type'] = 'index'; |
|
| 930 | + if ( in_array($value['type'],array('alternate_key','foreign')) ) { |
|
| 931 | + $value['type'] = 'index'; |
|
| 932 | + } |
|
| 907 | 933 | |
| 908 | 934 | if ( !isset($compareIndices[$name]) ) { |
| 909 | 935 | //First check if an index exists that doesn't match our name, if so, try to rename it |
@@ -934,21 +960,23 @@ discard block |
||
| 934 | 960 | $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
| 935 | 961 | foreach ($compareIndices[$name] as $n1 => $t1) { |
| 936 | 962 | $sql .= "<$n1>"; |
| 937 | - if ( $n1 == 'fields' ) |
|
| 938 | - foreach($t1 as $rKey => $rValue) |
|
| 963 | + if ( $n1 == 'fields' ) { |
|
| 964 | + foreach($t1 as $rKey => $rValue) |
|
| 939 | 965 | $sql .= "[$rKey] => '$rValue' "; |
| 940 | - else |
|
| 941 | - $sql .= " $t1 "; |
|
| 966 | + } else { |
|
| 967 | + $sql .= " $t1 "; |
|
| 968 | + } |
|
| 942 | 969 | } |
| 943 | 970 | $sql .= "*/\n"; |
| 944 | 971 | $sql .= "/* VARDEF - $name - ROW"; |
| 945 | 972 | foreach ($value as $n1 => $t1) { |
| 946 | 973 | $sql .= "<$n1>"; |
| 947 | - if ( $n1 == 'fields' ) |
|
| 948 | - foreach ($t1 as $rKey => $rValue) |
|
| 974 | + if ( $n1 == 'fields' ) { |
|
| 975 | + foreach ($t1 as $rKey => $rValue) |
|
| 949 | 976 | $sql .= "[$rKey] => '$rValue' "; |
| 950 | - else |
|
| 951 | - $sql .= " $t1 "; |
|
| 977 | + } else { |
|
| 978 | + $sql .= " $t1 "; |
|
| 979 | + } |
|
| 952 | 980 | } |
| 953 | 981 | $sql .= "*/\n"; |
| 954 | 982 | $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
@@ -971,8 +999,9 @@ discard block |
||
| 971 | 999 | public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
| 972 | 1000 | { |
| 973 | 1001 | foreach ( $fielddef1 as $key => $value ) { |
| 974 | - if ($key == 'name' && $ignoreName) |
|
| 975 | - continue; |
|
| 1002 | + if ($key == 'name' && $ignoreName) { |
|
| 1003 | + continue; |
|
| 1004 | + } |
|
| 976 | 1005 | if (isset($fielddef2[$key])) |
| 977 | 1006 | { |
| 978 | 1007 | if (!is_array($fielddef1[$key]) && !is_array($fielddef2[$key])) |
@@ -981,8 +1010,7 @@ discard block |
||
| 981 | 1010 | { |
| 982 | 1011 | continue; |
| 983 | 1012 | } |
| 984 | - } |
|
| 985 | - else |
|
| 1013 | + } else |
|
| 986 | 1014 | { |
| 987 | 1015 | if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower',$fielddef2[$key])) |
| 988 | 1016 | { |
@@ -991,8 +1019,9 @@ discard block |
||
| 991 | 1019 | } |
| 992 | 1020 | } |
| 993 | 1021 | //Ignore len if its not set in the vardef |
| 994 | - if ($key == 'len' && empty($fielddef2[$key])) |
|
| 995 | - continue; |
|
| 1022 | + if ($key == 'len' && empty($fielddef2[$key])) { |
|
| 1023 | + continue; |
|
| 1024 | + } |
|
| 996 | 1025 | // if the length in db is greather than the vardef, ignore it |
| 997 | 1026 | if ($key == 'len' && ($fielddef1[$key] >= $fielddef2[$key])) { |
| 998 | 1027 | continue; |
@@ -1026,12 +1055,10 @@ discard block |
||
| 1026 | 1055 | if (!$row2) { |
| 1027 | 1056 | // Exists on table1 but not table2 |
| 1028 | 1057 | $returnArray['msg'] = 'not_exists_table2'; |
| 1029 | - } |
|
| 1030 | - else { |
|
| 1058 | + } else { |
|
| 1031 | 1059 | if (sizeof($row1) != sizeof($row2)) { |
| 1032 | 1060 | $returnArray['msg'] = 'no_match'; |
| 1033 | - } |
|
| 1034 | - else { |
|
| 1061 | + } else { |
|
| 1035 | 1062 | $returnArray['msg'] = 'match'; |
| 1036 | 1063 | foreach($row1 as $key => $value){ |
| 1037 | 1064 | //ignore keys when checking we will check them when we do the index check |
@@ -1041,8 +1068,7 @@ discard block |
||
| 1041 | 1068 | } |
| 1042 | 1069 | } |
| 1043 | 1070 | } |
| 1044 | - } |
|
| 1045 | - else { |
|
| 1071 | + } else { |
|
| 1046 | 1072 | $returnArray['msg'] = 'not_exists_table1'; |
| 1047 | 1073 | } |
| 1048 | 1074 | |
@@ -1122,16 +1148,19 @@ discard block |
||
| 1122 | 1148 | */ |
| 1123 | 1149 | public function getConstraintSql($indices, $table) |
| 1124 | 1150 | { |
| 1125 | - if (!$this->isFieldArray($indices)) |
|
| 1126 | - $indices = array($indices); |
|
| 1151 | + if (!$this->isFieldArray($indices)) { |
|
| 1152 | + $indices = array($indices); |
|
| 1153 | + } |
|
| 1127 | 1154 | |
| 1128 | 1155 | $columns = array(); |
| 1129 | 1156 | |
| 1130 | 1157 | foreach ($indices as $index) { |
| 1131 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | - continue; |
|
| 1133 | - if (isset($index['source']) && $index['source'] != 'db') |
|
| 1134 | - continue; |
|
| 1158 | + if(!empty($index['db']) && $index['db'] != $this->dbType) { |
|
| 1159 | + continue; |
|
| 1160 | + } |
|
| 1161 | + if (isset($index['source']) && $index['source'] != 'db') { |
|
| 1162 | + continue; |
|
| 1163 | + } |
|
| 1135 | 1164 | |
| 1136 | 1165 | $sql = $this->add_drop_constraint($table, $index); |
| 1137 | 1166 | |
@@ -1221,11 +1250,11 @@ discard block |
||
| 1221 | 1250 | $sql = $this->addColumnSQL($tablename, $fieldDefs); |
| 1222 | 1251 | if ($this->isFieldArray($fieldDefs)){ |
| 1223 | 1252 | $columns = array(); |
| 1224 | - foreach ($fieldDefs as $fieldDef) |
|
| 1225 | - $columns[] = $fieldDef['name']; |
|
| 1253 | + foreach ($fieldDefs as $fieldDef) { |
|
| 1254 | + $columns[] = $fieldDef['name']; |
|
| 1255 | + } |
|
| 1226 | 1256 | $columns = implode(",", $columns); |
| 1227 | - } |
|
| 1228 | - else { |
|
| 1257 | + } else { |
|
| 1229 | 1258 | $columns = $fieldDefs['name']; |
| 1230 | 1259 | } |
| 1231 | 1260 | $msg = "Error adding column(s) $columns on table: $tablename:"; |
@@ -1249,8 +1278,7 @@ discard block |
||
| 1249 | 1278 | $columns[] = $fieldDef['name']; |
| 1250 | 1279 | } |
| 1251 | 1280 | $columns = implode(",", $columns); |
| 1252 | - } |
|
| 1253 | - else { |
|
| 1281 | + } else { |
|
| 1254 | 1282 | $columns = $newFieldDef['name']; |
| 1255 | 1283 | } |
| 1256 | 1284 | |
@@ -1370,7 +1398,9 @@ discard block |
||
| 1370 | 1398 | if(!$is_related_query){ |
| 1371 | 1399 | foreach ($fields as $fieldDef) |
| 1372 | 1400 | { |
| 1373 | - if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1401 | + if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') { |
|
| 1402 | + continue; |
|
| 1403 | + } |
|
| 1374 | 1404 | $val = $row[$fieldDef['name']]; |
| 1375 | 1405 | |
| 1376 | 1406 | //handle auto increment values here only need to do this on insert not create |
@@ -1379,8 +1409,7 @@ discard block |
||
| 1379 | 1409 | if(!$built_columns){ |
| 1380 | 1410 | $columns[] = 'deleted'; |
| 1381 | 1411 | } |
| 1382 | - } |
|
| 1383 | - else |
|
| 1412 | + } else |
|
| 1384 | 1413 | { |
| 1385 | 1414 | $type = $fieldDef['type']; |
| 1386 | 1415 | if(!empty($fieldDef['custom_type'])){ |
@@ -1388,28 +1417,32 @@ discard block |
||
| 1388 | 1417 | } |
| 1389 | 1418 | // need to do some thing about types of values |
| 1390 | 1419 | if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
| 1391 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | - $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1393 | - else |
|
| 1394 | - $values[$fieldDef['name']] = 'null'; |
|
| 1395 | - }else{ |
|
| 1420 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1421 | + $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1422 | + } else { |
|
| 1423 | + $values[$fieldDef['name']] = 'null'; |
|
| 1424 | + } |
|
| 1425 | + } else{ |
|
| 1396 | 1426 | if(isset($type) && $type=='int') { |
| 1397 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | - $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1399 | - else |
|
| 1400 | - $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1427 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1428 | + $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1429 | + } else { |
|
| 1430 | + $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1431 | + } |
|
| 1401 | 1432 | } else { |
| 1402 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | - $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1404 | - else |
|
| 1405 | - $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1433 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1434 | + $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1435 | + } else { |
|
| 1436 | + $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1437 | + } |
|
| 1406 | 1438 | } |
| 1407 | 1439 | } |
| 1408 | 1440 | if(!$built_columns){ |
| 1409 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | - $cstm_columns[] = $fieldDef['name']; |
|
| 1411 | - else |
|
| 1412 | - $columns[] = $fieldDef['name']; |
|
| 1441 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1442 | + $cstm_columns[] = $fieldDef['name']; |
|
| 1443 | + } else { |
|
| 1444 | + $columns[] = $fieldDef['name']; |
|
| 1445 | + } |
|
| 1413 | 1446 | } |
| 1414 | 1447 | } |
| 1415 | 1448 | |
@@ -1624,7 +1657,9 @@ discard block |
||
| 1624 | 1657 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1625 | 1658 | } |
| 1626 | 1659 | $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
| 1627 | - if (!$queryresult) return false; |
|
| 1660 | + if (!$queryresult) { |
|
| 1661 | + return false; |
|
| 1662 | + } |
|
| 1628 | 1663 | $row = $this->fetchByAssoc($queryresult); |
| 1629 | 1664 | if(!empty($row)) { |
| 1630 | 1665 | return array_shift($row); |
@@ -1648,10 +1683,14 @@ discard block |
||
| 1648 | 1683 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1649 | 1684 | $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
| 1650 | 1685 | |
| 1651 | - if (!$queryresult) return false; |
|
| 1686 | + if (!$queryresult) { |
|
| 1687 | + return false; |
|
| 1688 | + } |
|
| 1652 | 1689 | |
| 1653 | 1690 | $row = $this->fetchByAssoc($queryresult); |
| 1654 | - if ( !$row ) return false; |
|
| 1691 | + if ( !$row ) { |
|
| 1692 | + return false; |
|
| 1693 | + } |
|
| 1655 | 1694 | |
| 1656 | 1695 | $this->freeResult($queryresult); |
| 1657 | 1696 | return $row; |
@@ -1708,13 +1747,15 @@ discard block |
||
| 1708 | 1747 | protected function describeField($name, $tablename) |
| 1709 | 1748 | { |
| 1710 | 1749 | $table = $this->getTableDescription($tablename); |
| 1711 | - if(!empty($table) && isset($table[$name])) |
|
| 1712 | - return $table[$name]; |
|
| 1750 | + if(!empty($table) && isset($table[$name])) { |
|
| 1751 | + return $table[$name]; |
|
| 1752 | + } |
|
| 1713 | 1753 | |
| 1714 | 1754 | $table = $this->getTableDescription($tablename, true); |
| 1715 | 1755 | |
| 1716 | - if(isset($table[$name])) |
|
| 1717 | - return $table[$name]; |
|
| 1756 | + if(isset($table[$name])) { |
|
| 1757 | + return $table[$name]; |
|
| 1758 | + } |
|
| 1718 | 1759 | |
| 1719 | 1760 | return array(); |
| 1720 | 1761 | } |
@@ -1768,11 +1809,15 @@ discard block |
||
| 1768 | 1809 | */ |
| 1769 | 1810 | public function concat($table, array $fields, $space = ' ') |
| 1770 | 1811 | { |
| 1771 | - if(empty($fields)) return ''; |
|
| 1812 | + if(empty($fields)) { |
|
| 1813 | + return ''; |
|
| 1814 | + } |
|
| 1772 | 1815 | $elems = array(); |
| 1773 | 1816 | $space = $this->quoted($space); |
| 1774 | 1817 | foreach ( $fields as $field ) { |
| 1775 | - if(!empty($elems)) $elems[] = $space; |
|
| 1818 | + if(!empty($elems)) { |
|
| 1819 | + $elems[] = $space; |
|
| 1820 | + } |
|
| 1776 | 1821 | $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
| 1777 | 1822 | } |
| 1778 | 1823 | $first = array_shift($elems); |
@@ -1864,7 +1909,7 @@ discard block |
||
| 1864 | 1909 | }//switch |
| 1865 | 1910 | }//foreach |
| 1866 | 1911 | return $this->query($query); |
| 1867 | - }else{ |
|
| 1912 | + } else{ |
|
| 1868 | 1913 | return false; |
| 1869 | 1914 | } |
| 1870 | 1915 | } |
@@ -1926,20 +1971,30 @@ discard block |
||
| 1926 | 1971 | $fields = $bean->getFieldDefinitions(); |
| 1927 | 1972 | // get column names and values |
| 1928 | 1973 | foreach ($fields as $field => $fieldDef) { |
| 1929 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 1974 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') { |
|
| 1975 | + continue; |
|
| 1976 | + } |
|
| 1930 | 1977 | // Do not write out the id field on the update statement. |
| 1931 | 1978 | // We are not allowed to change ids. |
| 1932 | - if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) continue; |
|
| 1979 | + if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) { |
|
| 1980 | + continue; |
|
| 1981 | + } |
|
| 1933 | 1982 | |
| 1934 | 1983 | // If the field is an auto_increment field, then we shouldn't be setting it. This was added |
| 1935 | 1984 | // specially for Bugs and Cases which have a number associated with them. |
| 1936 | - if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
|
| 1985 | + if (!empty($bean->field_name_map[$field]['auto_increment'])) { |
|
| 1986 | + continue; |
|
| 1987 | + } |
|
| 1937 | 1988 | |
| 1938 | 1989 | //custom fields handle their save separately |
| 1939 | - if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1990 | + if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) { |
|
| 1991 | + continue; |
|
| 1992 | + } |
|
| 1940 | 1993 | |
| 1941 | 1994 | // no need to clear deleted since we only update not deleted records anyway |
| 1942 | - if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1995 | + if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) { |
|
| 1996 | + continue; |
|
| 1997 | + } |
|
| 1943 | 1998 | |
| 1944 | 1999 | if(isset($bean->$field)) { |
| 1945 | 2000 | $val = from_html($bean->$field); |
@@ -1972,8 +2027,10 @@ discard block |
||
| 1972 | 2027 | } |
| 1973 | 2028 | } |
| 1974 | 2029 | |
| 1975 | - if ( sizeof($columns) == 0 ) |
|
| 1976 | - return ""; // no columns set |
|
| 2030 | + if ( sizeof($columns) == 0 ) { |
|
| 2031 | + return ""; |
|
| 2032 | + } |
|
| 2033 | + // no columns set |
|
| 1977 | 2034 | |
| 1978 | 2035 | // build where clause |
| 1979 | 2036 | $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
@@ -2039,8 +2096,9 @@ discard block |
||
| 2039 | 2096 | $where[] = " $table.$name $op $val"; |
| 2040 | 2097 | } |
| 2041 | 2098 | |
| 2042 | - if (!empty($where)) |
|
| 2043 | - return implode(" AND ", $where); |
|
| 2099 | + if (!empty($where)) { |
|
| 2100 | + return implode(" AND ", $where); |
|
| 2101 | + } |
|
| 2044 | 2102 | |
| 2045 | 2103 | return ''; |
| 2046 | 2104 | } |
@@ -2144,21 +2202,25 @@ discard block |
||
| 2144 | 2202 | public function massageFieldDef(&$fieldDef, $tablename) |
| 2145 | 2203 | { |
| 2146 | 2204 | if ( !isset($fieldDef['dbType']) ) { |
| 2147 | - if ( isset($fieldDef['dbtype']) ) |
|
| 2148 | - $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2149 | - else |
|
| 2150 | - $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2205 | + if ( isset($fieldDef['dbtype']) ) { |
|
| 2206 | + $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2207 | + } else { |
|
| 2208 | + $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2209 | + } |
|
| 2151 | 2210 | } |
| 2152 | 2211 | $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
| 2153 | 2212 | $matches = array(); |
| 2154 | 2213 | // len can be a number or a string like 'max', for example, nvarchar(max) |
| 2155 | 2214 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches); |
| 2156 | - if ( isset($matches[1][0]) ) |
|
| 2157 | - $fieldDef['type'] = $matches[1][0]; |
|
| 2158 | - if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2159 | - $fieldDef['len'] = $matches[2][0]; |
|
| 2160 | - if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2161 | - $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2215 | + if ( isset($matches[1][0]) ) { |
|
| 2216 | + $fieldDef['type'] = $matches[1][0]; |
|
| 2217 | + } |
|
| 2218 | + if ( isset($matches[2][0]) && empty($fieldDef['len']) ) { |
|
| 2219 | + $fieldDef['len'] = $matches[2][0]; |
|
| 2220 | + } |
|
| 2221 | + if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) { |
|
| 2222 | + $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2223 | + } |
|
| 2162 | 2224 | if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
| 2163 | 2225 | $fieldDef['required'] = 'true'; |
| 2164 | 2226 | } |
@@ -2172,8 +2234,9 @@ discard block |
||
| 2172 | 2234 | public function getSelectFieldsFromQuery($selectStatement) |
| 2173 | 2235 | { |
| 2174 | 2236 | $selectStatement = trim($selectStatement); |
| 2175 | - if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") |
|
| 2176 | - $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2237 | + if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") { |
|
| 2238 | + $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2239 | + } |
|
| 2177 | 2240 | |
| 2178 | 2241 | //Due to sql functions existing in many selects, we can't use php explode |
| 2179 | 2242 | $fields = array(); |
@@ -2189,17 +2252,15 @@ discard block |
||
| 2189 | 2252 | $field = $this->getFieldNameFromSelect(trim($selectField)); |
| 2190 | 2253 | $fields[$field] = $selectField; |
| 2191 | 2254 | $selectField = ""; |
| 2192 | - } |
|
| 2193 | - else if ($char == "("){ |
|
| 2255 | + } else if ($char == "("){ |
|
| 2194 | 2256 | $level++; |
| 2195 | 2257 | $selectField .= $char; |
| 2196 | - } |
|
| 2197 | - else if($char == ")"){ |
|
| 2258 | + } else if($char == ")"){ |
|
| 2198 | 2259 | $level--; |
| 2199 | 2260 | $selectField .= $char; |
| 2200 | 2261 | |
| 2201 | 2262 | |
| 2202 | - }else{ |
|
| 2263 | + } else{ |
|
| 2203 | 2264 | $selectField .= $char; |
| 2204 | 2265 | } |
| 2205 | 2266 | |
@@ -2218,18 +2279,19 @@ discard block |
||
| 2218 | 2279 | if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
| 2219 | 2280 | $string = substr($string, 9); |
| 2220 | 2281 | } |
| 2221 | - if (stripos($string, " as ") !== false) |
|
| 2222 | - //"as" used for an alias |
|
| 2282 | + if (stripos($string, " as ") !== false) { |
|
| 2283 | + //"as" used for an alias |
|
| 2223 | 2284 | return trim(substr($string, strripos($string, " as ") + 4)); |
| 2224 | - else if (strrpos($string, " ") != 0) |
|
| 2225 | - //Space used as a delimiter for an alias |
|
| 2285 | + } else if (strrpos($string, " ") != 0) { |
|
| 2286 | + //Space used as a delimiter for an alias |
|
| 2226 | 2287 | return trim(substr($string, strrpos($string, " "))); |
| 2227 | - else if (strpos($string, ".") !== false) |
|
| 2228 | - //No alias, but a table.field format was used |
|
| 2288 | + } else if (strpos($string, ".") !== false) { |
|
| 2289 | + //No alias, but a table.field format was used |
|
| 2229 | 2290 | return substr($string, strpos($string, ".") + 1); |
| 2230 | - else |
|
| 2231 | - //Give up and assume the whole thing is the field name |
|
| 2291 | + } else { |
|
| 2292 | + //Give up and assume the whole thing is the field name |
|
| 2232 | 2293 | return $string; |
| 2294 | + } |
|
| 2233 | 2295 | } |
| 2234 | 2296 | |
| 2235 | 2297 | /** |
@@ -2289,8 +2351,9 @@ discard block |
||
| 2289 | 2351 | $aliases[$tableName][] = $table; |
| 2290 | 2352 | |
| 2291 | 2353 | // build part of select for this table |
| 2292 | - if (is_array($cols[$beanID])) |
|
| 2293 | - foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2354 | + if (is_array($cols[$beanID])) { |
|
| 2355 | + foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2356 | + } |
|
| 2294 | 2357 | |
| 2295 | 2358 | // build part of where clause |
| 2296 | 2359 | if (is_array($whereClause[$beanID])){ |
@@ -2322,7 +2385,10 @@ discard block |
||
| 2322 | 2385 | $separator = ""; |
| 2323 | 2386 | $from = ''; $table_used_in_from = array(); |
| 2324 | 2387 | foreach ($relations as $table1 => $rightsidearray){ |
| 2325 | - if ($table_used_in_from[$table1]) continue; // table has been joined |
|
| 2388 | + if ($table_used_in_from[$table1]) { |
|
| 2389 | + continue; |
|
| 2390 | + } |
|
| 2391 | + // table has been joined |
|
| 2326 | 2392 | |
| 2327 | 2393 | $from .= $separator." ".$table1; |
| 2328 | 2394 | $table_used_in_from[$table1] = true; |
@@ -2333,7 +2399,9 @@ discard block |
||
| 2333 | 2399 | //choose first alias that does not match |
| 2334 | 2400 | // we are doing this because of self joins. |
| 2335 | 2401 | // in case of self joins, the same table will have many aliases. |
| 2336 | - if ($table2 != $table1) break; |
|
| 2402 | + if ($table2 != $table1) { |
|
| 2403 | + break; |
|
| 2404 | + } |
|
| 2337 | 2405 | } |
| 2338 | 2406 | |
| 2339 | 2407 | $col = $tablearray['foreingColumn']; |
@@ -2362,11 +2430,13 @@ discard block |
||
| 2362 | 2430 | $tablename = $bean->getTableName(); |
| 2363 | 2431 | $columns = array(); |
| 2364 | 2432 | // get column names |
| 2365 | - foreach ($fields as $fieldDef) |
|
| 2366 | - $columns[] = $fieldDef['name']; |
|
| 2433 | + foreach ($fields as $fieldDef) { |
|
| 2434 | + $columns[] = $fieldDef['name']; |
|
| 2435 | + } |
|
| 2367 | 2436 | |
| 2368 | - if (empty($columns)) |
|
| 2369 | - return ""; |
|
| 2437 | + if (empty($columns)) { |
|
| 2438 | + return ""; |
|
| 2439 | + } |
|
| 2370 | 2440 | |
| 2371 | 2441 | $columns = implode(",", $columns); |
| 2372 | 2442 | |
@@ -2386,16 +2456,21 @@ discard block |
||
| 2386 | 2456 | // we do not have change a lot of existing code |
| 2387 | 2457 | // and add dbtype where type is being used for some special |
| 2388 | 2458 | // purposes like referring to foreign table etc. |
| 2389 | - if(!empty($fieldDef['dbType'])) |
|
| 2390 | - return $fieldDef['dbType']; |
|
| 2391 | - if(!empty($fieldDef['dbtype'])) |
|
| 2392 | - return $fieldDef['dbtype']; |
|
| 2393 | - if (!empty($fieldDef['type'])) |
|
| 2394 | - return $fieldDef['type']; |
|
| 2395 | - if (!empty($fieldDef['Type'])) |
|
| 2396 | - return $fieldDef['Type']; |
|
| 2397 | - if (!empty($fieldDef['data_type'])) |
|
| 2398 | - return $fieldDef['data_type']; |
|
| 2459 | + if(!empty($fieldDef['dbType'])) { |
|
| 2460 | + return $fieldDef['dbType']; |
|
| 2461 | + } |
|
| 2462 | + if(!empty($fieldDef['dbtype'])) { |
|
| 2463 | + return $fieldDef['dbtype']; |
|
| 2464 | + } |
|
| 2465 | + if (!empty($fieldDef['type'])) { |
|
| 2466 | + return $fieldDef['type']; |
|
| 2467 | + } |
|
| 2468 | + if (!empty($fieldDef['Type'])) { |
|
| 2469 | + return $fieldDef['Type']; |
|
| 2470 | + } |
|
| 2471 | + if (!empty($fieldDef['data_type'])) { |
|
| 2472 | + return $fieldDef['data_type']; |
|
| 2473 | + } |
|
| 2399 | 2474 | |
| 2400 | 2475 | return null; |
| 2401 | 2476 | } |
@@ -2453,14 +2528,15 @@ discard block |
||
| 2453 | 2528 | 'clob', 'blob', 'text'))) { |
| 2454 | 2529 | $colType = "$colBaseType(${fieldDef['len']})"; |
| 2455 | 2530 | } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
| 2456 | - if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | - if(strpos($fieldDef['len'],',') === false){ |
|
| 2531 | + if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) { |
|
| 2532 | + if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | 2533 | $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
| 2459 | - }else{ |
|
| 2460 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2461 | - } |
|
| 2462 | - else |
|
| 2534 | + } |
|
| 2535 | + } else{ |
|
| 2463 | 2536 | $colType = $colBaseType . "(".$fieldDef['len'].")"; |
| 2537 | + } else { |
|
| 2538 | + $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2539 | + } |
|
| 2464 | 2540 | } |
| 2465 | 2541 | } else { |
| 2466 | 2542 | if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
@@ -2474,19 +2550,18 @@ discard block |
||
| 2474 | 2550 | if (!empty($fieldDef['no_default'])) |
| 2475 | 2551 | { |
| 2476 | 2552 | // nothing to do |
| 2477 | - } |
|
| 2478 | - elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2553 | + } elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2479 | 2554 | { |
| 2480 | 2555 | $default = " DEFAULT ".$this->quoted($fieldDef['default']); |
| 2481 | - } |
|
| 2482 | - elseif (!isset($default) && $type == 'bool') |
|
| 2556 | + } elseif (!isset($default) && $type == 'bool') |
|
| 2483 | 2557 | { |
| 2484 | 2558 | $default = " DEFAULT 0 "; |
| 2485 | 2559 | } |
| 2486 | 2560 | |
| 2487 | 2561 | $auto_increment = ''; |
| 2488 | - if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | - $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2562 | + if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) { |
|
| 2563 | + $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2564 | + } |
|
| 2490 | 2565 | |
| 2491 | 2566 | $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
| 2492 | 2567 | //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
@@ -2500,8 +2575,9 @@ discard block |
||
| 2500 | 2575 | && !empty($fieldDef['required'])) { |
| 2501 | 2576 | $required = "NOT NULL"; |
| 2502 | 2577 | } |
| 2503 | - if ($ignoreRequired) |
|
| 2504 | - $required = ""; |
|
| 2578 | + if ($ignoreRequired) { |
|
| 2579 | + $required = ""; |
|
| 2580 | + } |
|
| 2505 | 2581 | |
| 2506 | 2582 | if ( $return_as_array ) { |
| 2507 | 2583 | return array( |
@@ -2537,8 +2613,7 @@ discard block |
||
| 2537 | 2613 | } |
| 2538 | 2614 | } |
| 2539 | 2615 | $columns = implode(",", $columns); |
| 2540 | - } |
|
| 2541 | - else { |
|
| 2616 | + } else { |
|
| 2542 | 2617 | $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
| 2543 | 2618 | } |
| 2544 | 2619 | |
@@ -2760,8 +2835,9 @@ discard block |
||
| 2760 | 2835 | */ |
| 2761 | 2836 | public function isFieldArray($defArray) |
| 2762 | 2837 | { |
| 2763 | - if ( !is_array($defArray) ) |
|
| 2764 | - return false; |
|
| 2838 | + if ( !is_array($defArray) ) { |
|
| 2839 | + return false; |
|
| 2840 | + } |
|
| 2765 | 2841 | |
| 2766 | 2842 | if ( isset($defArray['type']) ){ |
| 2767 | 2843 | // type key exists. May be an array of defs or a simple definition |
@@ -2872,11 +2948,9 @@ discard block |
||
| 2872 | 2948 | } else { |
| 2873 | 2949 | if (isset($properties['dbType'])) { |
| 2874 | 2950 | $field_type=$properties['dbType']; |
| 2875 | - } |
|
| 2876 | - else if(isset($properties['data_type'])) { |
|
| 2951 | + } else if(isset($properties['data_type'])) { |
|
| 2877 | 2952 | $field_type=$properties['data_type']; |
| 2878 | - } |
|
| 2879 | - else { |
|
| 2953 | + } else { |
|
| 2880 | 2954 | $field_type=$properties['dbtype']; |
| 2881 | 2955 | } |
| 2882 | 2956 | } |
@@ -2901,13 +2975,11 @@ discard block |
||
| 2901 | 2975 | if ($error >= 0.0000000001) { // Smaller than 10E-10 |
| 2902 | 2976 | $change = true; |
| 2903 | 2977 | } |
| 2904 | - } |
|
| 2905 | - else if ($this->isBooleanType($field_type)) { |
|
| 2978 | + } else if ($this->isBooleanType($field_type)) { |
|
| 2906 | 2979 | if ($this->_getBooleanValue($before_value) != $this->_getBooleanValue($after_value)) { |
| 2907 | 2980 | $change = true; |
| 2908 | 2981 | } |
| 2909 | - } |
|
| 2910 | - else { |
|
| 2982 | + } else { |
|
| 2911 | 2983 | $change = true; |
| 2912 | 2984 | } |
| 2913 | 2985 | if ($change) { |
@@ -3005,8 +3077,9 @@ discard block |
||
| 3005 | 3077 | protected function _getBooleanValue($val) |
| 3006 | 3078 | { |
| 3007 | 3079 | //need to put the === sign here otherwise true == 'non empty string' |
| 3008 | - if (empty($val) or $val==='off') |
|
| 3009 | - return false; |
|
| 3080 | + if (empty($val) or $val==='off') { |
|
| 3081 | + return false; |
|
| 3082 | + } |
|
| 3010 | 3083 | |
| 3011 | 3084 | return true; |
| 3012 | 3085 | } |
@@ -3032,8 +3105,9 @@ discard block |
||
| 3032 | 3105 | */ |
| 3033 | 3106 | protected function _emptyValue($val, $type) |
| 3034 | 3107 | { |
| 3035 | - if (empty($val)) |
|
| 3036 | - return true; |
|
| 3108 | + if (empty($val)) { |
|
| 3109 | + return true; |
|
| 3110 | + } |
|
| 3037 | 3111 | |
| 3038 | 3112 | if($this->emptyValue($type) == $val) { |
| 3039 | 3113 | return true; |
@@ -3050,10 +3124,12 @@ discard block |
||
| 3050 | 3124 | case 'short': |
| 3051 | 3125 | return ($val == 0); |
| 3052 | 3126 | case 'date': |
| 3053 | - if ($val == '0000-00-00') |
|
| 3054 | - return true; |
|
| 3055 | - if ($val == 'NULL') |
|
| 3056 | - return true; |
|
| 3127 | + if ($val == '0000-00-00') { |
|
| 3128 | + return true; |
|
| 3129 | + } |
|
| 3130 | + if ($val == 'NULL') { |
|
| 3131 | + return true; |
|
| 3132 | + } |
|
| 3057 | 3133 | return false; |
| 3058 | 3134 | } |
| 3059 | 3135 | |
@@ -3407,7 +3483,9 @@ discard block |
||
| 3407 | 3483 | */ |
| 3408 | 3484 | public function fetchByAssoc($result, $encode = true) |
| 3409 | 3485 | { |
| 3410 | - if (empty($result)) return false; |
|
| 3486 | + if (empty($result)) { |
|
| 3487 | + return false; |
|
| 3488 | + } |
|
| 3411 | 3489 | |
| 3412 | 3490 | if(is_int($encode) && func_num_args() == 3) { |
| 3413 | 3491 | // old API: $result, $rowNum, $encode |
@@ -98,51 +98,51 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | class MysqliManager extends MysqlManager |
| 100 | 100 | { |
| 101 | - /** |
|
| 102 | - * @see DBManager::$dbType |
|
| 103 | - */ |
|
| 104 | - public $dbType = 'mysql'; |
|
| 105 | - public $variant = 'mysqli'; |
|
| 106 | - public $priority = 10; |
|
| 107 | - public $label = 'LBL_MYSQLI'; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @see DBManager::$backendFunctions |
|
| 111 | - */ |
|
| 112 | - protected $backendFunctions = array( |
|
| 113 | - 'free_result' => 'mysqli_free_result', |
|
| 114 | - 'close' => 'mysqli_close', |
|
| 115 | - 'row_count' => 'mysqli_num_rows', |
|
| 116 | - 'affected_row_count' => 'mysqli_affected_rows', |
|
| 117 | - ); |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @see MysqlManager::query() |
|
| 121 | - */ |
|
| 122 | - public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
| 123 | - { |
|
| 124 | - if(is_array($sql)) { |
|
| 125 | - return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
|
| 101 | + /** |
|
| 102 | + * @see DBManager::$dbType |
|
| 103 | + */ |
|
| 104 | + public $dbType = 'mysql'; |
|
| 105 | + public $variant = 'mysqli'; |
|
| 106 | + public $priority = 10; |
|
| 107 | + public $label = 'LBL_MYSQLI'; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @see DBManager::$backendFunctions |
|
| 111 | + */ |
|
| 112 | + protected $backendFunctions = array( |
|
| 113 | + 'free_result' => 'mysqli_free_result', |
|
| 114 | + 'close' => 'mysqli_close', |
|
| 115 | + 'row_count' => 'mysqli_num_rows', |
|
| 116 | + 'affected_row_count' => 'mysqli_affected_rows', |
|
| 117 | + ); |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @see MysqlManager::query() |
|
| 121 | + */ |
|
| 122 | + public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
| 123 | + { |
|
| 124 | + if(is_array($sql)) { |
|
| 125 | + return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - static $queryMD5 = array(); |
|
| 128 | + static $queryMD5 = array(); |
|
| 129 | 129 | |
| 130 | - parent::countQuery($sql); |
|
| 131 | - $GLOBALS['log']->info('Query:' . $sql); |
|
| 132 | - $this->checkConnection(); |
|
| 133 | - $this->query_time = microtime(true); |
|
| 134 | - $this->lastsql = $sql; |
|
| 135 | - $result = $suppress?@mysqli_query($this->database,$sql):mysqli_query($this->database,$sql); |
|
| 136 | - $md5 = md5($sql); |
|
| 130 | + parent::countQuery($sql); |
|
| 131 | + $GLOBALS['log']->info('Query:' . $sql); |
|
| 132 | + $this->checkConnection(); |
|
| 133 | + $this->query_time = microtime(true); |
|
| 134 | + $this->lastsql = $sql; |
|
| 135 | + $result = $suppress?@mysqli_query($this->database,$sql):mysqli_query($this->database,$sql); |
|
| 136 | + $md5 = md5($sql); |
|
| 137 | 137 | |
| 138 | - if (empty($queryMD5[$md5])) |
|
| 139 | - $queryMD5[$md5] = true; |
|
| 138 | + if (empty($queryMD5[$md5])) |
|
| 139 | + $queryMD5[$md5] = true; |
|
| 140 | 140 | |
| 141 | - $this->query_time = microtime(true) - $this->query_time; |
|
| 142 | - $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
|
| 141 | + $this->query_time = microtime(true) - $this->query_time; |
|
| 142 | + $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
|
| 143 | 143 | |
| 144 | - // This is some heavy duty debugging, leave commented out unless you need this: |
|
| 145 | - /* |
|
| 144 | + // This is some heavy duty debugging, leave commented out unless you need this: |
|
| 145 | + /* |
|
| 146 | 146 | $bt = debug_backtrace(); |
| 147 | 147 | for ( $i = count($bt) ; $i-- ; $i > 0 ) { |
| 148 | 148 | if ( strpos('MysqliManager.php',$bt[$i]['file']) === false ) { |
@@ -154,228 +154,228 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | |
| 156 | 156 | |
| 157 | - if($keepResult) |
|
| 158 | - $this->lastResult = $result; |
|
| 159 | - $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
| 160 | - |
|
| 161 | - return $result; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Returns the number of rows affected by the last query |
|
| 166 | - * |
|
| 167 | - * @return int |
|
| 168 | - */ |
|
| 169 | - public function getAffectedRowCount($result) |
|
| 170 | - { |
|
| 171 | - return mysqli_affected_rows($this->getDatabase()); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Returns the number of rows returned by the result |
|
| 176 | - * |
|
| 177 | - * This function can't be reliably implemented on most DB, do not use it. |
|
| 178 | - * @abstract |
|
| 179 | - * @deprecated |
|
| 180 | - * @param resource $result |
|
| 181 | - * @return int |
|
| 182 | - */ |
|
| 183 | - public function getRowCount($result) |
|
| 184 | - { |
|
| 185 | - return mysqli_num_rows($result); |
|
| 186 | - } |
|
| 157 | + if($keepResult) |
|
| 158 | + $this->lastResult = $result; |
|
| 159 | + $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
| 187 | 160 | |
| 161 | + return $result; |
|
| 162 | + } |
|
| 188 | 163 | |
| 189 | 164 | /** |
| 190 | - * Disconnects from the database |
|
| 191 | - * |
|
| 192 | - * Also handles any cleanup needed |
|
| 193 | - */ |
|
| 194 | - public function disconnect() |
|
| 195 | - { |
|
| 196 | - if(isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) { |
|
| 197 | - $GLOBALS['log']->debug('Calling MySQLi::disconnect()'); |
|
| 198 | - } |
|
| 199 | - if(!empty($this->database)){ |
|
| 200 | - $this->freeResult(); |
|
| 201 | - mysqli_close($this->database); |
|
| 202 | - $this->database = null; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @see DBManager::freeDbResult() |
|
| 208 | - */ |
|
| 209 | - protected function freeDbResult($dbResult) |
|
| 210 | - { |
|
| 211 | - if(!empty($dbResult)) |
|
| 212 | - mysqli_free_result($dbResult); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @see DBManager::getFieldsArray() |
|
| 217 | - */ |
|
| 218 | - public function getFieldsArray($result, $make_lower_case = false) |
|
| 219 | - { |
|
| 220 | - $field_array = array(); |
|
| 221 | - |
|
| 222 | - if (!isset($result) || empty($result)) |
|
| 223 | - return 0; |
|
| 224 | - |
|
| 225 | - $i = 0; |
|
| 226 | - while ($i < mysqli_num_fields($result)) { |
|
| 227 | - $meta = mysqli_fetch_field_direct($result, $i); |
|
| 228 | - if (!$meta) |
|
| 229 | - return 0; |
|
| 230 | - |
|
| 231 | - if($make_lower_case == true) |
|
| 232 | - $meta->name = strtolower($meta->name); |
|
| 233 | - |
|
| 234 | - $field_array[] = $meta->name; |
|
| 235 | - |
|
| 236 | - $i++; |
|
| 237 | - } |
|
| 165 | + * Returns the number of rows affected by the last query |
|
| 166 | + * |
|
| 167 | + * @return int |
|
| 168 | + */ |
|
| 169 | + public function getAffectedRowCount($result) |
|
| 170 | + { |
|
| 171 | + return mysqli_affected_rows($this->getDatabase()); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Returns the number of rows returned by the result |
|
| 176 | + * |
|
| 177 | + * This function can't be reliably implemented on most DB, do not use it. |
|
| 178 | + * @abstract |
|
| 179 | + * @deprecated |
|
| 180 | + * @param resource $result |
|
| 181 | + * @return int |
|
| 182 | + */ |
|
| 183 | + public function getRowCount($result) |
|
| 184 | + { |
|
| 185 | + return mysqli_num_rows($result); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Disconnects from the database |
|
| 191 | + * |
|
| 192 | + * Also handles any cleanup needed |
|
| 193 | + */ |
|
| 194 | + public function disconnect() |
|
| 195 | + { |
|
| 196 | + if(isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) { |
|
| 197 | + $GLOBALS['log']->debug('Calling MySQLi::disconnect()'); |
|
| 198 | + } |
|
| 199 | + if(!empty($this->database)){ |
|
| 200 | + $this->freeResult(); |
|
| 201 | + mysqli_close($this->database); |
|
| 202 | + $this->database = null; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @see DBManager::freeDbResult() |
|
| 208 | + */ |
|
| 209 | + protected function freeDbResult($dbResult) |
|
| 210 | + { |
|
| 211 | + if(!empty($dbResult)) |
|
| 212 | + mysqli_free_result($dbResult); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @see DBManager::getFieldsArray() |
|
| 217 | + */ |
|
| 218 | + public function getFieldsArray($result, $make_lower_case = false) |
|
| 219 | + { |
|
| 220 | + $field_array = array(); |
|
| 221 | + |
|
| 222 | + if (!isset($result) || empty($result)) |
|
| 223 | + return 0; |
|
| 224 | + |
|
| 225 | + $i = 0; |
|
| 226 | + while ($i < mysqli_num_fields($result)) { |
|
| 227 | + $meta = mysqli_fetch_field_direct($result, $i); |
|
| 228 | + if (!$meta) |
|
| 229 | + return 0; |
|
| 230 | + |
|
| 231 | + if($make_lower_case == true) |
|
| 232 | + $meta->name = strtolower($meta->name); |
|
| 233 | + |
|
| 234 | + $field_array[] = $meta->name; |
|
| 235 | + |
|
| 236 | + $i++; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return $field_array; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @see DBManager::fetchRow() |
|
| 244 | + */ |
|
| 245 | + public function fetchRow($result) |
|
| 246 | + { |
|
| 247 | + if (empty($result)) return false; |
|
| 248 | + |
|
| 249 | + $row = mysqli_fetch_assoc($result); |
|
| 250 | + if($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers |
|
| 251 | + return $row; |
|
| 252 | + } |
|
| 238 | 253 | |
| 239 | - return $field_array; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @see DBManager::fetchRow() |
|
| 244 | - */ |
|
| 245 | - public function fetchRow($result) |
|
| 246 | - { |
|
| 247 | - if (empty($result)) return false; |
|
| 248 | - |
|
| 249 | - $row = mysqli_fetch_assoc($result); |
|
| 250 | - if($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers |
|
| 251 | - return $row; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * @see DBManager::quote() |
|
| 256 | - */ |
|
| 257 | - public function quote($string) |
|
| 258 | - { |
|
| 259 | - return mysqli_real_escape_string($this->getDatabase(),$this->quoteInternal($string)); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * @see DBManager::connect() |
|
| 264 | - */ |
|
| 265 | - public function connect(array $configOptions = null, $dieOnError = false) |
|
| 266 | - { |
|
| 267 | - global $sugar_config; |
|
| 268 | - |
|
| 269 | - if (is_null($configOptions)) |
|
| 270 | - $configOptions = $sugar_config['dbconfig']; |
|
| 271 | - |
|
| 272 | - if(!isset($this->database)) { |
|
| 273 | - |
|
| 274 | - //mysqli connector has a separate parameter for port.. We need to separate it out from the host name |
|
| 275 | - $dbhost=$configOptions['db_host_name']; |
|
| 254 | + /** |
|
| 255 | + * @see DBManager::quote() |
|
| 256 | + */ |
|
| 257 | + public function quote($string) |
|
| 258 | + { |
|
| 259 | + return mysqli_real_escape_string($this->getDatabase(),$this->quoteInternal($string)); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * @see DBManager::connect() |
|
| 264 | + */ |
|
| 265 | + public function connect(array $configOptions = null, $dieOnError = false) |
|
| 266 | + { |
|
| 267 | + global $sugar_config; |
|
| 268 | + |
|
| 269 | + if (is_null($configOptions)) |
|
| 270 | + $configOptions = $sugar_config['dbconfig']; |
|
| 271 | + |
|
| 272 | + if(!isset($this->database)) { |
|
| 273 | + |
|
| 274 | + //mysqli connector has a separate parameter for port.. We need to separate it out from the host name |
|
| 275 | + $dbhost=$configOptions['db_host_name']; |
|
| 276 | 276 | $dbport=isset($configOptions['db_port']) ? ($configOptions['db_port'] == '' ? null : $configOptions['db_port']) : null; |
| 277 | 277 | |
| 278 | - $pos=strpos($configOptions['db_host_name'],':'); |
|
| 279 | - if ($pos !== false) { |
|
| 280 | - $dbhost=substr($configOptions['db_host_name'],0,$pos); |
|
| 281 | - $dbport=substr($configOptions['db_host_name'],$pos+1); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - $this->database = @mysqli_connect($dbhost,$configOptions['db_user_name'],$configOptions['db_password'],isset($configOptions['db_name'])?$configOptions['db_name']:'',$dbport); |
|
| 285 | - if(empty($this->database)) { |
|
| 286 | - $GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port " .$dbport . ": " . mysqli_connect_error()); |
|
| 287 | - if($dieOnError) { |
|
| 288 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 289 | - sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
| 290 | - } else { |
|
| 291 | - sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
| 292 | - } |
|
| 293 | - } else { |
|
| 294 | - return false; |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - } |
|
| 278 | + $pos=strpos($configOptions['db_host_name'],':'); |
|
| 279 | + if ($pos !== false) { |
|
| 280 | + $dbhost=substr($configOptions['db_host_name'],0,$pos); |
|
| 281 | + $dbport=substr($configOptions['db_host_name'],$pos+1); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + $this->database = @mysqli_connect($dbhost,$configOptions['db_user_name'],$configOptions['db_password'],isset($configOptions['db_name'])?$configOptions['db_name']:'',$dbport); |
|
| 285 | + if(empty($this->database)) { |
|
| 286 | + $GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port " .$dbport . ": " . mysqli_connect_error()); |
|
| 287 | + if($dieOnError) { |
|
| 288 | + if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 289 | + sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
| 290 | + } else { |
|
| 291 | + sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
| 292 | + } |
|
| 293 | + } else { |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - if(!empty($configOptions['db_name']) && !@mysqli_select_db($this->database,$configOptions['db_name'])) { |
|
| 300 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysqli_connect_error()); |
|
| 301 | - if($dieOnError) { |
|
| 302 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 303 | - sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
| 304 | - } else { |
|
| 305 | - sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
| 306 | - } |
|
| 307 | - } else { |
|
| 308 | - return false; |
|
| 309 | - } |
|
| 310 | - } |
|
| 299 | + if(!empty($configOptions['db_name']) && !@mysqli_select_db($this->database,$configOptions['db_name'])) { |
|
| 300 | + $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysqli_connect_error()); |
|
| 301 | + if($dieOnError) { |
|
| 302 | + if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 303 | + sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
| 304 | + } else { |
|
| 305 | + sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
| 306 | + } |
|
| 307 | + } else { |
|
| 308 | + return false; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - // cn: using direct calls to prevent this from spamming the Logs |
|
| 312 | + // cn: using direct calls to prevent this from spamming the Logs |
|
| 313 | 313 | |
| 314 | - $collation = $this->getOption('collation'); |
|
| 315 | - if(!empty($collation)) { |
|
| 316 | - $names = "SET NAMES 'utf8' COLLATE '$collation'"; |
|
| 317 | - mysqli_query($this->database,$names); |
|
| 318 | - } |
|
| 319 | - mysqli_set_charset ($this->database , "utf8" ); |
|
| 320 | - |
|
| 321 | - if($this->checkError('Could Not Connect', $dieOnError)) |
|
| 322 | - $GLOBALS['log']->info("connected to db"); |
|
| 323 | - |
|
| 324 | - $this->connectOptions = $configOptions; |
|
| 325 | - return true; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * (non-PHPdoc) |
|
| 330 | - * @see MysqlManager::lastDbError() |
|
| 331 | - */ |
|
| 332 | - public function lastDbError() |
|
| 333 | - { |
|
| 334 | - if($this->database) { |
|
| 335 | - if(mysqli_errno($this->database)) { |
|
| 336 | - return "MySQL error ".mysqli_errno($this->database).": ".mysqli_error($this->database); |
|
| 337 | - } |
|
| 338 | - } else { |
|
| 339 | - $err = mysqli_connect_error(); |
|
| 340 | - if($err) { |
|
| 341 | - return $err; |
|
| 342 | - } |
|
| 343 | - } |
|
| 314 | + $collation = $this->getOption('collation'); |
|
| 315 | + if(!empty($collation)) { |
|
| 316 | + $names = "SET NAMES 'utf8' COLLATE '$collation'"; |
|
| 317 | + mysqli_query($this->database,$names); |
|
| 318 | + } |
|
| 319 | + mysqli_set_charset ($this->database , "utf8" ); |
|
| 344 | 320 | |
| 345 | - return false; |
|
| 346 | - } |
|
| 321 | + if($this->checkError('Could Not Connect', $dieOnError)) |
|
| 322 | + $GLOBALS['log']->info("connected to db"); |
|
| 347 | 323 | |
| 348 | - public function getDbInfo() |
|
| 349 | - { |
|
| 350 | - $charsets = $this->getCharsetInfo(); |
|
| 351 | - $charset_str = array(); |
|
| 352 | - foreach($charsets as $name => $value) { |
|
| 353 | - $charset_str[] = "$name = $value"; |
|
| 354 | - } |
|
| 355 | - return array( |
|
| 356 | - "MySQLi Version" => @mysqli_get_client_info(), |
|
| 357 | - "MySQLi Host Info" => @mysqli_get_host_info($this->database), |
|
| 358 | - "MySQLi Server Info" => @mysqli_get_server_info($this->database), |
|
| 359 | - "MySQLi Client Encoding" => @mysqli_client_encoding($this->database), |
|
| 360 | - "MySQL Character Set Settings" => join(", ", $charset_str), |
|
| 361 | - ); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Select database |
|
| 366 | - * @param string $dbname |
|
| 367 | - */ |
|
| 368 | - protected function selectDb($dbname) |
|
| 369 | - { |
|
| 370 | - return mysqli_select_db($this->getDatabase(), $dbname); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * Check if this driver can be used |
|
| 375 | - * @return bool |
|
| 376 | - */ |
|
| 377 | - public function valid() |
|
| 378 | - { |
|
| 379 | - return function_exists("mysqli_connect") && empty($GLOBALS['sugar_config']['mysqli_disabled']); |
|
| 380 | - } |
|
| 324 | + $this->connectOptions = $configOptions; |
|
| 325 | + return true; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * (non-PHPdoc) |
|
| 330 | + * @see MysqlManager::lastDbError() |
|
| 331 | + */ |
|
| 332 | + public function lastDbError() |
|
| 333 | + { |
|
| 334 | + if($this->database) { |
|
| 335 | + if(mysqli_errno($this->database)) { |
|
| 336 | + return "MySQL error ".mysqli_errno($this->database).": ".mysqli_error($this->database); |
|
| 337 | + } |
|
| 338 | + } else { |
|
| 339 | + $err = mysqli_connect_error(); |
|
| 340 | + if($err) { |
|
| 341 | + return $err; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + return false; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + public function getDbInfo() |
|
| 349 | + { |
|
| 350 | + $charsets = $this->getCharsetInfo(); |
|
| 351 | + $charset_str = array(); |
|
| 352 | + foreach($charsets as $name => $value) { |
|
| 353 | + $charset_str[] = "$name = $value"; |
|
| 354 | + } |
|
| 355 | + return array( |
|
| 356 | + "MySQLi Version" => @mysqli_get_client_info(), |
|
| 357 | + "MySQLi Host Info" => @mysqli_get_host_info($this->database), |
|
| 358 | + "MySQLi Server Info" => @mysqli_get_server_info($this->database), |
|
| 359 | + "MySQLi Client Encoding" => @mysqli_client_encoding($this->database), |
|
| 360 | + "MySQL Character Set Settings" => join(", ", $charset_str), |
|
| 361 | + ); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Select database |
|
| 366 | + * @param string $dbname |
|
| 367 | + */ |
|
| 368 | + protected function selectDb($dbname) |
|
| 369 | + { |
|
| 370 | + return mysqli_select_db($this->getDatabase(), $dbname); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Check if this driver can be used |
|
| 375 | + * @return bool |
|
| 376 | + */ |
|
| 377 | + public function valid() |
|
| 378 | + { |
|
| 379 | + return function_exists("mysqli_connect") && empty($GLOBALS['sugar_config']['mysqli_disabled']); |
|
| 380 | + } |
|
| 381 | 381 | } |
@@ -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. |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
| 123 | 123 | { |
| 124 | - if(is_array($sql)) { |
|
| 124 | + if (is_array($sql)) { |
|
| 125 | 125 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | static $queryMD5 = array(); |
| 129 | 129 | |
| 130 | 130 | parent::countQuery($sql); |
| 131 | - $GLOBALS['log']->info('Query:' . $sql); |
|
| 131 | + $GLOBALS['log']->info('Query:'.$sql); |
|
| 132 | 132 | $this->checkConnection(); |
| 133 | 133 | $this->query_time = microtime(true); |
| 134 | 134 | $this->lastsql = $sql; |
| 135 | - $result = $suppress?@mysqli_query($this->database,$sql):mysqli_query($this->database,$sql); |
|
| 135 | + $result = $suppress ? @mysqli_query($this->database, $sql) : mysqli_query($this->database, $sql); |
|
| 136 | 136 | $md5 = md5($sql); |
| 137 | 137 | |
| 138 | 138 | if (empty($queryMD5[$md5])) |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | |
| 156 | 156 | |
| 157 | - if($keepResult) |
|
| 157 | + if ($keepResult) |
|
| 158 | 158 | $this->lastResult = $result; |
| 159 | - $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
| 159 | + $this->checkError($msg.' Query Failed: '.$sql, $dieOnError); |
|
| 160 | 160 | |
| 161 | 161 | return $result; |
| 162 | 162 | } |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function disconnect() |
| 195 | 195 | { |
| 196 | - if(isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) { |
|
| 196 | + if (isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) { |
|
| 197 | 197 | $GLOBALS['log']->debug('Calling MySQLi::disconnect()'); |
| 198 | 198 | } |
| 199 | - if(!empty($this->database)){ |
|
| 199 | + if (!empty($this->database)) { |
|
| 200 | 200 | $this->freeResult(); |
| 201 | 201 | mysqli_close($this->database); |
| 202 | 202 | $this->database = null; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | protected function freeDbResult($dbResult) |
| 210 | 210 | { |
| 211 | - if(!empty($dbResult)) |
|
| 211 | + if (!empty($dbResult)) |
|
| 212 | 212 | mysqli_free_result($dbResult); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | if (!$meta) |
| 229 | 229 | return 0; |
| 230 | 230 | |
| 231 | - if($make_lower_case == true) |
|
| 231 | + if ($make_lower_case == true) |
|
| 232 | 232 | $meta->name = strtolower($meta->name); |
| 233 | 233 | |
| 234 | 234 | $field_array[] = $meta->name; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | if (empty($result)) return false; |
| 248 | 248 | |
| 249 | 249 | $row = mysqli_fetch_assoc($result); |
| 250 | - if($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers |
|
| 250 | + if ($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers |
|
| 251 | 251 | return $row; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function quote($string) |
| 258 | 258 | { |
| 259 | - return mysqli_real_escape_string($this->getDatabase(),$this->quoteInternal($string)); |
|
| 259 | + return mysqli_real_escape_string($this->getDatabase(), $this->quoteInternal($string)); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -269,23 +269,23 @@ discard block |
||
| 269 | 269 | if (is_null($configOptions)) |
| 270 | 270 | $configOptions = $sugar_config['dbconfig']; |
| 271 | 271 | |
| 272 | - if(!isset($this->database)) { |
|
| 272 | + if (!isset($this->database)) { |
|
| 273 | 273 | |
| 274 | 274 | //mysqli connector has a separate parameter for port.. We need to separate it out from the host name |
| 275 | - $dbhost=$configOptions['db_host_name']; |
|
| 276 | - $dbport=isset($configOptions['db_port']) ? ($configOptions['db_port'] == '' ? null : $configOptions['db_port']) : null; |
|
| 275 | + $dbhost = $configOptions['db_host_name']; |
|
| 276 | + $dbport = isset($configOptions['db_port']) ? ($configOptions['db_port'] == '' ? null : $configOptions['db_port']) : null; |
|
| 277 | 277 | |
| 278 | - $pos=strpos($configOptions['db_host_name'],':'); |
|
| 278 | + $pos = strpos($configOptions['db_host_name'], ':'); |
|
| 279 | 279 | if ($pos !== false) { |
| 280 | - $dbhost=substr($configOptions['db_host_name'],0,$pos); |
|
| 281 | - $dbport=substr($configOptions['db_host_name'],$pos+1); |
|
| 280 | + $dbhost = substr($configOptions['db_host_name'], 0, $pos); |
|
| 281 | + $dbport = substr($configOptions['db_host_name'], $pos + 1); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - $this->database = @mysqli_connect($dbhost,$configOptions['db_user_name'],$configOptions['db_password'],isset($configOptions['db_name'])?$configOptions['db_name']:'',$dbport); |
|
| 285 | - if(empty($this->database)) { |
|
| 286 | - $GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port " .$dbport . ": " . mysqli_connect_error()); |
|
| 287 | - if($dieOnError) { |
|
| 288 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 284 | + $this->database = @mysqli_connect($dbhost, $configOptions['db_user_name'], $configOptions['db_password'], isset($configOptions['db_name']) ? $configOptions['db_name'] : '', $dbport); |
|
| 285 | + if (empty($this->database)) { |
|
| 286 | + $GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port ".$dbport.": ".mysqli_connect_error()); |
|
| 287 | + if ($dieOnError) { |
|
| 288 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 289 | 289 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 290 | 290 | } else { |
| 291 | 291 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if(!empty($configOptions['db_name']) && !@mysqli_select_db($this->database,$configOptions['db_name'])) { |
|
| 300 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysqli_connect_error()); |
|
| 301 | - if($dieOnError) { |
|
| 302 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 299 | + if (!empty($configOptions['db_name']) && !@mysqli_select_db($this->database, $configOptions['db_name'])) { |
|
| 300 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}: ".mysqli_connect_error()); |
|
| 301 | + if ($dieOnError) { |
|
| 302 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 303 | 303 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 304 | 304 | } else { |
| 305 | 305 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | // cn: using direct calls to prevent this from spamming the Logs |
| 313 | 313 | |
| 314 | 314 | $collation = $this->getOption('collation'); |
| 315 | - if(!empty($collation)) { |
|
| 315 | + if (!empty($collation)) { |
|
| 316 | 316 | $names = "SET NAMES 'utf8' COLLATE '$collation'"; |
| 317 | - mysqli_query($this->database,$names); |
|
| 317 | + mysqli_query($this->database, $names); |
|
| 318 | 318 | } |
| 319 | - mysqli_set_charset ($this->database , "utf8" ); |
|
| 319 | + mysqli_set_charset($this->database, "utf8"); |
|
| 320 | 320 | |
| 321 | - if($this->checkError('Could Not Connect', $dieOnError)) |
|
| 321 | + if ($this->checkError('Could Not Connect', $dieOnError)) |
|
| 322 | 322 | $GLOBALS['log']->info("connected to db"); |
| 323 | 323 | |
| 324 | 324 | $this->connectOptions = $configOptions; |
@@ -331,13 +331,13 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | public function lastDbError() |
| 333 | 333 | { |
| 334 | - if($this->database) { |
|
| 335 | - if(mysqli_errno($this->database)) { |
|
| 334 | + if ($this->database) { |
|
| 335 | + if (mysqli_errno($this->database)) { |
|
| 336 | 336 | return "MySQL error ".mysqli_errno($this->database).": ".mysqli_error($this->database); |
| 337 | 337 | } |
| 338 | 338 | } else { |
| 339 | - $err = mysqli_connect_error(); |
|
| 340 | - if($err) { |
|
| 339 | + $err = mysqli_connect_error(); |
|
| 340 | + if ($err) { |
|
| 341 | 341 | return $err; |
| 342 | 342 | } |
| 343 | 343 | } |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | { |
| 350 | 350 | $charsets = $this->getCharsetInfo(); |
| 351 | 351 | $charset_str = array(); |
| 352 | - foreach($charsets as $name => $value) { |
|
| 352 | + foreach ($charsets as $name => $value) { |
|
| 353 | 353 | $charset_str[] = "$name = $value"; |
| 354 | 354 | } |
| 355 | 355 | return array( |