portal/include/utils.php
Functions
StackTraceErrorHandler(
$errno, $errstr, $errfile, $errline, $errcontext
)
:
void
Name | Type | Description |
---|---|---|
$errno | ||
$errstr | ||
$errfile | ||
$errline | ||
$errcontext |
_pp(
$mixed
)
:
void
Private helper function for displaying the contents of a given variable.
This function is only intended to be used for SugarCRM internal development. The pp stands for Pre Print.
Name | Type | Description |
---|---|---|
$mixed |
_ppd(
$mixed
)
:
void
Private helper function for displaying the contents of a given variable.
This function is only intended to be used for SugarCRM internal development. The ppd stands for Pre Print Die.
Name | Type | Description |
---|---|---|
$mixed |
_ppl(
\$mixed $mixed, \$die $die
=
false, \$displayStackTrace $displayStackTrace
=
false, $loglevel
=
"debug"
)
:
void
Private helper function for displaying the contents of a given variable in the Logger. This function is only intended to be used for SugarCRM internal development. The pp stands for Pre Print.
Name | Type | Description |
---|---|---|
$mixed | \$mixed | var to print_r() |
$die | \$die | boolean end script flow |
$displayStackTrace | \$displayStackTrace | also show stack trace |
$loglevel |
_ppt(
$mixed
)
:
void
Private helper function for displaying the contents of a given variable.
This function is only intended to be used for SugarCRM internal development. The pp stands for Pre Print Trace.
Name | Type | Description |
---|---|---|
$mixed |
_pptd(
$mixed
)
:
void
Private helper function for displaying the contents of a given variable.
This function is only intended to be used for SugarCRM internal development. The pp stands for Pre Print Trace Die.
Name | Type | Description |
---|---|---|
$mixed |
appendPortToHost(
\$url $url, \$port $port
)
:
\$resulturl
This function will take a number and system_id and format
Name | Type | Description |
---|---|---|
$url | \$url | URL containing host to append port |
$port | \$port | the port number - if '' is passed, no change to url |
Type | Description |
---|---|
\$resulturl | the new URL with the port appended to the host |
append_where_clause(
\$where_clauses $where_clauses, \$variable_name $variable_name, \$SQL_name $SQL_name
=
null
)
:
void
Creates an array of where restrictions. These are used to construct a where SQL statement on the query It looks for the variable in the $_REQUEST array. If it is set and is not "" it will create a where clause out of it.
Name | Type | Description |
---|---|---|
$where_clauses | \$where_clauses |
|
$variable_name | \$variable_name |
|
$SQL_name | \$SQL_name |
|
array_csort(
)
:
void
Very cool algorithm for sorting multi-dimensional arrays. Found at http://us2.php.net/manual/en/function.array-multisort.php Syntax: $new_array = array_csort($array [, 'col1' [, SORT_FLAG [, SORT_FLAG]]]...); Explanation: $array is the array you want to sort, 'col1' is the name of the column you want to sort, SORT_FLAGS are : SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING you can repeat the 'col',FLAG,FLAG, as often you want, the highest prioritiy is given to the first - so the array is sorted by the last given column first, then the one before ...
Example: $array = array_csort($array,'town','age',SORT_DESC,'name'); Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
check_logic_hook_file(
$module_name, $event, $action_array
)
:
void
Name | Type | Description |
---|---|---|
$module_name | ||
$event | ||
$action_array |
check_php_version(
$sys_php_version
=
''
)
:
\1
Will check if a given PHP version string is supported (tested on this ver), unsupported (results unknown), or invalid (something will break on this ver). Do not pass in any pararameter to default to a check against the current environment's PHP version.
Name | Type | Description |
---|---|---|
$sys_php_version |
Type | Description |
---|---|
\1 | implies supported, 0 implies unsupported, -1 implies invalid |
clean_superglobals(
$key, $filter
=
'STANDARD'
)
:
void
cleans the given key in superglobals $_GET, $_POST, $_REQUEST
Name | Type | Description |
---|---|---|
$key | ||
$filter |
clone_history(
$db, $from_id, $to_id, $to_type
)
:
void
Name | Type | Description |
---|---|---|
$db | ||
$from_id | ||
$to_id | ||
$to_type |
clone_relationship(
$db, $tables
=
array(), $from_column, $from_id, $to_id
)
:
void
Name | Type | Description |
---|---|---|
$db | ||
$tables | ||
$from_column | ||
$from_id | ||
$to_id |
create_guid(
)
:
String
A temporary method of generating GUIDs of the correct format for our DB.
Type | Description |
---|---|
String | contianing a GUID in the format: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________.. |
format_number_display(
\$num $num, \$system_id $system_id
)
:
\$result
This function will take a number and system_id and format
Name | Type | Description |
---|---|---|
$num | \$num | of bean |
$system_id | \$system_id | from system |
Type | Description |
---|---|
\$result | a formatted string |
generate_where_statement(
\$where_clauses $where_clauses
)
:
void
Generate the appropriate SQL based on the where clauses.
Name | Type | Description |
---|---|---|
$where_clauses | \$where_clauses |
|
- Returns
- string where_clause - The final SQL where clause to be executed. Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
getPhpInfo(
\$level $level
=
-1
)
:
\$returnInfo
This function returns an array of phpinfo() results that can be parsed and used to figure out what version we run, what modules are compiled in, etc.
Name | Type | Description |
---|---|---|
$level | \$level | int info level constant (1,2,4,8...64); |
Type | Description |
---|---|
\$returnInfo | array array of info about the PHP environment |
- Author
- original by "code at adspeed dot com" Fron php.net
- Author
- customized for Sugar by Chris N.
getTrackerSubstring(
string $name
)
:
string
returns a 20-char or less string for the Tracker to display in the header
Name | Type | Description |
---|---|---|
$name | string | name field for a given Object |
Type | Description |
---|---|
string | 20-char or less name |
get_assigned_team_name(
$assigned_team_id
)
:
void
Name | Type | Description |
---|---|---|
$assigned_team_id |
get_assigned_user_name(
$assigned_user_id, $is_group
=
' AND is_group=0 '
)
:
void
Name | Type | Description |
---|---|---|
$assigned_user_id | ||
$is_group |
get_bean_select_array(
$add_blank
=
true, $bean_name, $display_columns, $where
=
'', $order_by
=
'', $blank_is_none
=
false
)
:
void
Name | Type | Description |
---|---|---|
$add_blank | ||
$bean_name | ||
$display_columns | ||
$where | ||
$order_by | ||
$blank_is_none |
get_clear_form_js(
)
:
void
Create javascript to clear values of all elements in a form.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
get_image(
$image, $other_attributes, $width
=
"", $height
=
"", $alt
)
:
void
Name | Type | Description |
---|---|---|
$image | ||
$other_attributes | ||
$width | ||
$height | ||
$alt |
get_label(
$label_tag, $temp_module_strings
)
:
void
Name | Type | Description |
---|---|---|
$label_tag | ||
$temp_module_strings |
get_select_options(
$option_list, $selected
)
:
void
THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED; USE get_select_options_with_id() Create HTML to display select options in a dropdown list. To be used inside of a select statement in a form.
param $option_list - the array of strings to that contains the option list param $selected - the string which contains the default value Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$option_list | ||
$selected |
get_select_options_with_id(
$option_list, $selected_key
)
:
void
Create HTML to display select options in a dropdown list. To be used inside of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The values are the display strings.
param $option_list - the array of strings to that contains the option list param $selected - the string which contains the default value Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$option_list | ||
$selected_key |
get_select_options_with_id_separate_key(
$label_list, $key_list, $selected_key
)
:
void
Create HTML to display select options in a dropdown list. To be used inside of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The values are the display strings.
param $label_list - the array of strings to that contains the option list param $key_list - the array of strings to that contains the values list param $selected - the string which contains the default value Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$label_list | ||
$key_list | ||
$selected_key |
get_set_focus_js(
)
:
void
Create javascript to set the cursor focus to specific field in a form when the screen is rendered. The field name is currently hardcoded into the the function.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
get_team_array(
$add_blank
=
FALSE
)
:
void
retrieve the list of teams that this user has access to.
add_blank -- If you would like to have a blank entry in the list (to allow no selection) pass true.
Name | Type | Description |
---|---|---|
$add_blank |
get_theme_display(
$theme
)
:
void
Return the display name for a theme if it exists.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$theme |
get_themes(
)
:
void
Return an array of directory names.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
get_user_array(
$add_blank
=
true, $status
=
"Active", $assigned_user
=
"", $use_real_name
=
false, $user_name_begins
=
null, $is_group
=
' AND is_group=0 '
)
:
void
Name | Type | Description |
---|---|---|
$add_blank | ||
$status | ||
$assigned_user | ||
$use_real_name | ||
$user_name_begins | ||
$is_group |
is_admin(
$user
)
:
void
Check if user id belongs to a system admin.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$user |
lookupTimezone(
$userOffset
=
0
)
:
void
best guesses Timezone based on webserver's TZ settings
Name | Type | Description |
---|---|---|
$userOffset |
mark_delete_components(
$sub_object_array, $run_second_level
=
false, $sub_sub_array
=
""
)
:
void
Name | Type | Description |
---|---|---|
$sub_object_array | ||
$run_second_level | ||
$sub_sub_array |
parse_calendardate(
$local_format
)
:
void
Converts localized date format string to jscalendar format Example: $array = array_csort($array,'town','age',SORT_DESC,'name'); Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$local_format |
parse_list_modules(
\unknown_type $listArray
)
:
void
Name | Type | Description |
---|---|---|
$listArray | \unknown_type |
returnPhpJsonStatus(
)
:
bool
finds the correctly working versions of PHP-JSON
Type | Description |
---|---|
bool | True if NOT found or WRONG version |
return_app_list_strings_language(
$language
)
:
void
This function retrieves an application language file and returns the array of strings included in the $app_list_strings var.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________.. If you are using the current language, do not call this function unless you are loading it for the first time
Name | Type | Description |
---|---|---|
$language |
return_application_language(
$language
)
:
void
This function retrieves an application language file and returns the array of strings included.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________.. If you are using the current language, do not call this function unless you are loading it for the first time
Name | Type | Description |
---|---|---|
$language |
return_bytes(
$val
)
:
void
For translating the php.ini memory values into bytes. e.g. input value of '8M' will return 8388608.
Name | Type | Description |
---|---|---|
$val |
return_mod_list_strings_language(
$language, $module
)
:
void
This function retrieves an application language file and returns the array of strings included in the $mod_list_strings var.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________.. If you are using the current language, do not call this function unless you are loading it for the first time
Name | Type | Description |
---|---|---|
$language | ||
$module |
return_module_language(
$language, $module
)
:
void
This function retrieves a module's language file and returns the array of strings included.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________.. If you are in the current module, do not call this function unless you are loading it for the first time
Name | Type | Description |
---|---|---|
$language | ||
$module |
return_name(
$row, $first_column, $last_column
)
:
void
This function returns the name of the person.
It currently returns "first last". It should not put the space if either name is not available. It should not return errors if either name is not available. If no names are present, it will return "" Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$row | ||
$first_column | ||
$last_column |
return_session_value_or_default(
$varname, $default
)
:
void
If the session variable is defined and is not equal to "" then return it. Otherwise, return the default value.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$varname | ||
$default |
return_theme_language(
$language, $theme
)
:
void
This function retrieves a theme's language file and returns the array of strings included.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$language | ||
$theme |
safe_map(
$request_var, $focus, $always_copy
=
false
)
:
void
Copy the specified request variable to the member variable of the specified object.
Do no copy if the member variable is already set. Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$request_var | ||
$focus | ||
$always_copy |
safe_map_named(
$request_var, $focus, $member_var, $always_copy
)
:
void
Copy the specified request variable to the member variable of the specified object.
Do no copy if the member variable is already set. Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
Name | Type | Description |
---|---|---|
$request_var | ||
$focus | ||
$member_var | ||
$always_copy |
search_filter_rel_info(
$focus, $tar_rel_module, $relationship_name
)
:
void
Name | Type | Description |
---|---|---|
$focus | ||
$tar_rel_module | ||
$relationship_name |
set_register_value(
$category, $name, $value
)
:
void
Name | Type | Description |
---|---|---|
$category | ||
$name | ||
$value |
string_format(
\$format $format, \$args $args
)
:
\$result
This function will take a string that has tokens like {0}, {1} and will replace those tokens with the args provided
Name | Type | Description |
---|---|---|
$format | \$format | string to format |
$args | \$args | args to replace |
Type | Description |
---|---|
\$result | a formatted string |
sugarArrayMerge(
array $gimp, array $dom
)
:
array
like array_merge() but will handle array elements that are themselves arrays; PHP's version just overwrites the element with the new one.
Name | Type | Description |
---|---|---|
$gimp | array | gimp the array whose values will be overloaded |
$dom | array | dom the array whose values will pwn the gimp's |
Type | Description |
---|---|
array | beaten gimp |
sugar_config_union(
$default, $override
)
:
void
Name | Type | Description |
---|---|---|
$default | ||
$override |
sugar_die(
$error_message
)
:
void
Call this method instead of die().
Then we call the die method with the error message that is passed in.
Name | Type | Description |
---|---|---|
$error_message |
translate(
$string, $mod
=
'', $selectedValue
=
''
)
:
void
Name | Type | Description |
---|---|---|
$string | ||
$mod | ||
$selectedValue |
url2html(
$string
)
:
void
Adds the href HTML tags around any URL in the $string
Name | Type | Description |
---|---|---|
$string |