include/utils.php
Functions
StackTraceErrorHandler(
$errno, $errstr, $errfile, $errline, $errcontext
)
:
void
Name | Type | Description |
---|---|---|
$errno | ||
$errstr | ||
$errfile | ||
$errline | ||
$errcontext |
_mergeCustomAppListStrings(
\file $file, \app_list_strings $app_list_strings
)
:
array
The dropdown items in custom language files is $app_list_strings['$key']['$second_key'] = $value not $GLOBALS['app_list_strings']['$key'] = $value, so we have to delete the original ones in app_list_strings and relace it with the custom ones.
Name | Type | Description |
---|---|---|
$file | \file | string the language that you want include, |
$app_list_strings | \app_list_strings | array the golbal strings |
Type | Description |
---|---|
array |
_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 |
_ppf(
object $bean, $die
=
false
)
:
void
private helper function to quickly show the major, direct, field attributes of a given bean.
The ppf stands for Pre[formatted] Print Focus [object]
Name | Type | Description |
---|---|---|
$bean | object | bean The focus bean |
$die |
_ppl(
\$mixed $mixed, \$die $die
=
false, \$displayStackTrace $displayStackTrace
=
false, $loglevel
=
"fatal"
)
:
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, $textOnly
=
false
)
:
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 | ||
$textOnly |
_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 |
_pstack_trace(
$mixed
=
NULL
)
:
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 |
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): ______________________________________..
array_depth(
$array, $depth_count
=
-1, $depth_array
=
array()
)
:
void
Name | Type | Description |
---|---|---|
$array | ||
$depth_count | ||
$depth_array |
chartColors(
)
:
\sugarColors.xml
Chart dashlet helper functions that returns the correct XML color file for charts, dependent on the current theme.
Type | Description |
---|---|
\sugarColors.xml | to use |
chartStyle(
)
:
\chart.css
Chart dashlet helper function that returns the correct CSS file, dependent on the current theme.
Type | Description |
---|---|
\chart.css | file to use |
- Todo
- this won't work completely right until we impliment css compression and combination for now, we'll just include the last css file found.
check_iis_version(
$sys_iis_version
=
''
)
:
\1
Will check if a given IIS version string is supported (tested on this ver), unsupported (results unknown), or invalid (something will break on this ver).
Name | Type | Description |
---|---|---|
$sys_iis_version |
Type | Description |
---|---|
\1 | implies supported, 0 implies unsupported, -1 implies invalid |
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_sensitive_data(
array $defs, \SugarBean | array $data
)
:
mixed
Remove vars marked senstitive from array
Name | Type | Description |
---|---|---|
$defs | array | |
$data | \SugarBean | array |
Type | Description |
---|---|
mixed | $data without sensitive fields |
clean_string(
string $str, string $filter
=
"STANDARD", boolean $dieOnBadData
=
true
)
:
void
Designed to take a string passed in the URL as a parameter and clean all "bad" data from it
Name | Type | Description |
---|---|---|
$str | string | |
$filter | string | which corresponds to a regular expression to use; choices are: "STANDARD" ( default ) "STANDARDSPACE" "FILE" "NUMBER" "SQL_COLUMN_LIST" "PATH_NO_URL" "SAFED_GET" "UNIFIED_SEARCH" "AUTO_INCREMENT" "ALPHANUM" |
$dieOnBadData | boolean | true (default) if you want to die if bad data if found, false if not |
clean_superglobals(
$key, $filter
=
'STANDARD'
)
:
void
cleans the given key in superglobals $_GET, $_POST, $_REQUEST
Name | Type | Description |
---|---|---|
$key | ||
$filter |
clean_xss(
string $str, bool $cleanImg
=
true
)
:
array
Detects typical XSS attack patterns
Name | Type | Description |
---|---|---|
$str | string | str String to search for XSS attack vectors |
$cleanImg | bool | cleanImg Flag to allow tags to survive - only used by InboundEmail for inline images. |
Type | Description |
---|---|
array | Array of matches, empty on clean string |
- Deprecated
clearAllJsAndJsLangFilesWithoutOutput(
)
:
void
We need to clear all the js cache files, including the js language files in serval places in MB. So I extract them into a util function here.
- Depends
- on QuickRepairAndRebuild.php
- Relate
- bug 30642 ,23177
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 |
createGroupUser(
string $name
)
:
string
Creates a new Group User
Name | Type | Description |
---|---|---|
$name | string | Name of Group User |
Type | Description |
---|---|
string | GUID of new Group User |
create_export_query_relate_link_patch(
\$module: $module, \$searchFields: $searchFields, \$where: $where
)
:
\$ret_array['where']:\$ret_array['join']:
create_export_query is used for export and massupdate We haven't handle the these fields: $field['type'] == 'relate' && isset($field['link'] This function will correct the where clause and output necessary join condition for them
Name | Type | Description |
---|---|---|
$module | \$module: | the module name |
$searchFields | \$searchFields: | searchFields which is got after $searchForm->populateFromArray() |
$where | \$where: | where clauses |
Type | Description |
---|---|
\$ret_array['where']:\$ret_array['join']: | corrected where clauseextra join condition |
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): ______________________________________.. |
decodeJavascriptUTF8(
$str
)
:
void
Private helper function for decoding javascript UTF8 This function is only intended to be used for SugarCRM internal development.
Name | Type | Description |
---|---|---|
$str |
filterInboundEmailPopSelection(
array $protocol
)
:
void
Filter the protocol list for inbound email accounts.
Name | Type | Description |
---|---|---|
$protocol | array |
format_number_display(
\$num $num, \$system_id $system_id
)
:
\$result
Generate a string for displaying a unique identifier that is composed of a system_id and number. This is use to allow us to generate quote numbers using a DB auto-increment key from offline clients and still have the number be unique (since it is modified by the system_id.
Name | Type | Description |
---|---|---|
$num | \$num | of bean |
$system_id | \$system_id | from system |
Type | Description |
---|---|
\$result | a formatted string |
generateETagHeader(
string $etag
)
:
void
generateETagHeader
This function generates the necessary cache headers for using ETags with dynamic content. You simply have to generate the ETag, pass it in, and the function handles the rest.
Name | Type | Description |
---|---|---|
$etag | string | ETag to use for this content. |
generate_search_where(
$field_list
=
array(), $values
=
array(), $bean, $add_custom_fields
=
false, $module
=
''
)
:
void
Name | Type | Description |
---|---|---|
$field_list | ||
$values | ||
$bean | ||
$add_custom_fields | ||
$module |
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): ______________________________________..
getAbsolutePath(
string $path, $currentServer
=
false
)
:
string
Returns an absolute path from the given path, determining if it is relative or absolute
Name | Type | Description |
---|---|---|
$path | string | |
$currentServer |
Type | Description |
---|---|
string |
getDefaultXssTags(
)
:
array
returns a default array of XSS tags to clean
Type | Description |
---|---|
array |
getFTSBoostOptions(
string $optionName
)
:
array
Name | Type | Description |
---|---|---|
$optionName | string |
|
Type | Description |
---|---|
array | - the array to be used in option element |
getImagePath(
$image_name
)
:
void
Name | Type | Description |
---|---|---|
$image_name |
- Deprecated
- use SugarTheme::getImageURL()
getJSPath(
$relative_path, $additional_attrs
=
''
)
:
void
Name | Type | Description |
---|---|---|
$relative_path | ||
$additional_attrs |
getJavascriptSiteURL(
)
:
\$site_url
getJavascriptSiteURL This function returns a URL for the client javascript calls to access the site. It uses $_SERVER['HTTP_REFERER'] in the event that Proxy servers are used to access the site. Thus, the hostname in the URL returned may not always match that of $sugar_config['site_url']. Basically, the assumption is that however the user accessed the website is how they will continue to with subsequent javascript requests. If the variable $_SERVER['HTTP_REFERER'] is not found then we default to old algorithm.
Type | Description |
---|---|
\$site_url | The url used to refer to the website |
getMajorMinorVersion(
string $version
)
:
\version
Return the numeric portion of a version. For example if passed 5.5.0RC1 then return 5.5. If given 5.5.1RC1 then return 5.5.1
Name | Type | Description |
---|---|---|
$version | string |
Type | Description |
---|---|
\version |
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.
getReportNameTranslation(
string $reportName
)
:
string
getReportNameTranslation
Translates the report name if a translation exists, otherwise just returns the name
Name | Type | Description |
---|---|---|
$reportName | string |
Type | Description |
---|---|
string | translated report name |
getSWFPath(
$relative_path, $additional_params
=
''
)
:
void
Name | Type | Description |
---|---|---|
$relative_path | ||
$additional_params |
getStudioIcon(
string $iconFileName
=
'', $altFileName
=
'', string $width
=
'48', string $height
=
'48', string $align
=
'baseline', string $alt
=
''
)
:
string
Function to grab the correct icon image for Studio
Name | Type | Description |
---|---|---|
$iconFileName | string | Name of the icon file |
$altFileName | ||
$width | string | Width of image |
$height | string | Height of image |
$align | string | Alignment of image |
$alt | string | Alt tag of image |
Type | Description |
---|---|
string | $string <img> tag with corresponding image |
getTrackerSubstring(
string $name
)
:
string
getTrackerSubstring
Returns a [number]-char or less string for the Tracker to display in the header based on the tracker_max_display_length setting in config.php. If not set, or invalid length, then defaults to 15 for COM editions, 30 for others.
Name | Type | Description |
---|---|---|
$name | string | name field for a given Object |
Type | Description |
---|---|
string | [number]-char formatted string if length of string exceeds the max allowed |
getUrls(
$string
)
:
array
Extract urls from a piece of text
Name | Type | Description |
---|---|---|
$string |
Type | Description |
---|---|
array | of urls found in $string |
getUserArrayFromFullName(
\args $args, $hide_portal_users
=
false
)
:
array
uses a different query to return a list of users than get_user_array() Used from QuickSearch.php
Name | Type | Description |
---|---|---|
$args | \args | string where clause entry |
$hide_portal_users |
Type | Description |
---|---|
array | Array of Users' details that match passed criteria |
getVariableFromQueryString(
$variable, $string
)
:
void
This function will allow you to get a variable value from query string
Name | Type | Description |
---|---|---|
$variable | ||
$string |
getVersionStatus(
string $version
)
:
string
Given a version such as 5.5.0RC1 return RC. If we have a version such as: 5.5 then return GA
Name | Type | Description |
---|---|---|
$version | string |
Type | Description |
---|---|
string | RC, BETA, GA |
getVersionedPath(
$path, $additional_attrs
=
''
)
:
void
Name | Type | Description |
---|---|---|
$path | ||
$additional_attrs |
getVersionedScript(
$path, $additional_attrs
=
''
)
:
void
Name | Type | Description |
---|---|---|
$path | ||
$additional_attrs |
get_alt_hot_key(
)
:
String
Returns the shortcut keys to access the shortcut links. Shortcut keys vary depending on browser versions and operating systems.
Type | Description |
---|---|
String | value of the shortcut keys |
get_assigned_team_name(
$assigned_team_id
)
:
void
Name | Type | Description |
---|---|---|
$assigned_team_id |
get_assigned_user_name(
$assigned_user_id, $is_group
=
''
)
:
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_custom_file_if_exists(
\$file $file
)
:
\$file
get_custom_file_if_exists
This function handles the repetitive code we have where we first check if a file exists in the custom directory to determine whether we should load it, require it, include it, etc. This function returns the path of the custom file if it exists. It basically checks if custom/{$file} exists and returns this path if so; otherwise it return $file
Name | Type | Description |
---|---|---|
$file | \$file | String of filename to check |
Type | Description |
---|---|
\$file | String of filename including custom directory if found |
get_dashlets_dialog_icon(
string $module
=
'', string $width
=
'32', string $height
=
'32', string $align
=
'absmiddle', string $alt
=
''
)
:
string
Function to grab the correct icon image for Dashlets Dialog
Name | Type | Description |
---|---|---|
$module | string | Name of the module to fall back onto if file does not exist |
$width | string | Width of image |
$height | string | Height of image |
$align | string | Alignment of image |
$alt | string | Alt tag of image |
Type | Description |
---|---|
string | $string <img> tag with corresponding image |
get_help_url(
string $send_edition
=
'', string $send_version
=
'', string $send_lang
=
'', string $send_module
=
'', string $send_action
=
'', string $dev_status
=
'', string $send_key
=
'', string $send_anchor
=
''
)
:
string
get_help_url
This will return the URL used to redirect the user to the help documentation. It can be overriden completely by setting the custom_help_url or partially by setting the custom_help_base_url in config.php or config_override.php.
Name | Type | Description |
---|---|---|
$send_edition | string | |
$send_version | string | |
$send_lang | string | |
$send_module | string | |
$send_action | string | |
$dev_status | string | |
$send_key | string | |
$send_anchor | string |
Type | Description |
---|---|
string | the completed help URL |
get_image(
$image, $other_attributes, $width
=
"", $height
=
"", $ext
=
'.gif', $alt
=
""
)
:
void
Name | Type | Description |
---|---|---|
$image | ||
$other_attributes | ||
$width | ||
$height | ||
$ext | ||
$alt |
- Deprecated
- use SugarTheme::getImage()
get_label(
$label_tag, $temp_module_strings
)
:
void
Name | Type | Description |
---|---|---|
$label_tag | ||
$temp_module_strings |
get_language_header(
)
:
String
get_language_header
This is a utility function for 508 Compliance. It returns the lang=[Current Language] text string used inside the tag. If no current language is specified, it defaults to lang='en'.
Type | Description |
---|---|
String | The lang=[Current Language] markup to insert into the <html> tag |
get_notify_template_file(
$language
)
:
string
get_notify_template_file This function will return the location of the email notifications template to use
Name | Type | Description |
---|---|---|
$language |
Type | Description |
---|---|
string | relative file path to email notifications template file |
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, $massupdate
=
false
)
:
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 | ||
$massupdate |
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_team_name(
\unknown_type $team_id
)
:
void
Bug 13271 - Sometimes we just want to know the name of a team for display purposes when the team_id may not be one of the users assigned teams.
For example when they have an admin Role for a module we may need to display the teams for other users Unfortunately this means we can't just use the team_array value that may be stored in the register as unless we pass is_admin(), it won't contain all the necessary team names
Name | Type | Description |
---|---|---|
$team_id | \unknown_type |
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 |
- Deprecated
- use SugarThemeRegistry::get($theme)->name instead
get_themes(
)
:
void
Return an array of directory names.
Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights Reserved. Contributor(s): ______________________________________..
- Deprecated
- use SugarThemeRegistry::availableThemes() instead.
get_user_array(
bool $add_blank
=
true, string $status
=
"Active", string $user_id
=
'', bool $use_real_name
=
false, String $user_name_filter
=
'', string $portal_filter
=
' AND portal_only=0 ', bool $from_cache
=
true
)
:
array
get_user_array
This is a helper function to return an Array of users depending on the parameters passed into the function. This function uses the get_register_value function by default to use a caching layer where supported.
Name | Type | Description |
---|---|---|
$add_blank | bool | Boolean value to add a blank entry to the array results, true by default |
$status | string | String value indicating the status to filter users by, "Active" by default |
$user_id | string | String value to specify a particular user id value (searches the id column of users table), blank by default |
$use_real_name | bool | Boolean value indicating whether or not results should include the full name or just user_name, false by default |
$user_name_filter | String | String value indicating the user_name filter (searches the user_name column of users table) to optionally search with, blank by default |
$portal_filter | string | String query filter for portal users (defaults to searching non-portal users), change to blank if you wish to search for all users including portal users |
$from_cache | bool | Boolean value indicating whether or not to use the get_register_value function for caching, true by default |
Type | Description |
---|---|
array | Array of users matching the filter criteria that may be from cache (if similar search was previously run) |
get_user_name(
string $id
)
:
string
retrieves the user_name column value (login)
Name | Type | Description |
---|---|---|
$id | string | id GUID of user |
Type | Description |
---|---|
string |
get_valid_bean_name(
$module_name
)
:
void
In order to have one place to obtain the proper object name. aCase for example causes issues throughout the application.
Name | Type | Description |
---|---|---|
$module_name |
isTouchScreen(
)
:
void
Returns true if the application is being accessed on a touch screen interface ( like an iPad )
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 |
is_guid(
string $guid
)
:
bool
determines if a passed string matches the criteria for a Sugar GUID
Name | Type | Description |
---|---|---|
$guid | string |
Type | Description |
---|---|
bool | False on failure |
is_writable_windows(
string $file
)
:
bool
equivalent for windows filesystem for PHP's is_writable()
Name | Type | Description |
---|---|---|
$file | string | file Full path to the file/dir |
Type | Description |
---|---|
bool | true if writable |
loadBean(
string $module
)
:
object
Returns the bean object of the given module
Name | Type | Description |
---|---|---|
$module | string |
Type | Description |
---|---|
object |
- Deprecated
- use SugarModule::loadBean() instead
load_menu(
$path
)
:
void
Name | Type | Description |
---|---|---|
$path |
- Deprecated
- use SugarView::getMenu() instead
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 |
number_empty(
$value
)
:
boolean
Check to see if the number is empty or non-zero
Name | Type | Description |
---|---|---|
$value |
Type | Description |
---|---|
boolean |
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 |
rebuildConfigFile(
$sugar_config, $sugar_version
)
:
bool
This function will rebuild the config file
Name | Type | Description |
---|---|---|
$sugar_config | ||
$sugar_version |
Type | Description |
---|---|
bool | true if successful |
remove_logic_hook(
$module_name, $event, $action_array
)
:
void
Name | Type | Description |
---|---|---|
$module_name | ||
$event | ||
$action_array |
remove_xss(
string $str
)
:
string
Remove potential xss vectors from strings
Name | Type | Description |
---|---|---|
$str | string | str String to search for XSS attack vectors |
Type | Description |
---|---|
string |
- Deprecated
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(
string $language
)
:
array
This function retrieves an application language file and returns the array of strings included in the $app_list_strings var.
Name | Type | Description |
---|---|---|
$language | string | specific language to load |
Type | Description |
---|---|
array | lang strings |
return_application_language(
string $language
)
:
array
This function retrieves an application language file and returns the array of strings included.
Name | Type | Description |
---|---|---|
$language | string | specific language to load |
Type | Description |
---|---|
array | lang strings |
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(
string $language, string $module, bool $refresh
=
false
)
:
array
This function retrieves a module's language file and returns the array of strings included.
Name | Type | Description |
---|---|---|
$language | string | specific language to load |
$module | string | module name to load strings for |
$refresh | bool | optional, true if you want to rebuild the language strings |
Type | Description |
---|---|
array | lang strings |
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 |
sanitize(
\$input $input, int $quotes
=
ENT_QUOTES, string $charset
=
'UTF-8', bool $remove
=
false
)
:
string
Name | Type | Description |
---|---|---|
$input | \$input |
|
$quotes | int |
|
$charset | string |
|
$remove | bool |
|
Type | Description |
---|---|
string | - the sanitized string |
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 |
should_hide_iframes(
)
:
boolean
should_hide_iframes This is a helper method to determine whether or not to show iframes (My Sites) related information in the application.
Type | Description |
---|---|
boolean | flag indicating whether or not iframes module should be hidden |
sql_like_string(
string $str, string $like_char, $wildcard
=
'%', $appendWildcard
=
true
)
:
string
Return search like string This function takes a user input string and returns a string that contains wild card(s) that can be used in db query.
Name | Type | Description |
---|---|---|
$str | string | string to be searched |
$like_char | string | Database like character, usually '%' |
$wildcard | ||
$appendWildcard |
Type | Description |
---|---|
string | Returns a string to be searched in db query |
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 |
sugarArrayMergeRecursive(
array $gimp, array $dom
)
:
array
Similiar to sugarArrayMerge except arrays of N depth are merged.
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 |
sugarLangArrayMerge(
$gimp, $dom
)
:
array
Identical to sugarArrayMerge but with some speed improvements and used specifically to merge language files. Language file merges do not need to account for null values so we can get some performance increases by using this specialized function. Note this merge function does not properly handle null values.
Name | Type | Description |
---|---|---|
$gimp | ||
$dom |
Type | Description |
---|---|
array |
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 |
sugar_microtime(
)
:
string
Return string composed of seconds & microseconds of current time, without dots
Type | Description |
---|---|
string |
sugar_substr(
$string, $length, $charset
=
'UTF-8'
)
:
void
The function is used because currently we are not supporting mbstring.func_overload For some user using mssql without FreeTDS, they may store multibyte charaters in varchar using latin_general collation. It cannot store so many mutilbyte characters, so we need to use strlen.
The varchar in MySQL, Orcale, and nvarchar in FreeTDS, we can store $length mutilbyte charaters in it. we need mb_substr to keep more info.
Name | Type | Description |
---|---|---|
$string | ||
$length | ||
$charset |
- Returns
- the substred strings.
sugar_ucfirst(
$string, $charset
=
'UTF-8'
)
:
void
The function is used because on FastCGI enviroment, the ucfirst(Chinese Characters) will produce bad charcters.
This will work even without setting the mbstring.*encoding
Name | Type | Description |
---|---|---|
$string | ||
$charset |
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 |
utf8_recursive_encode(
\$data $data
)
:
\utf8
utf8_recursive_encode
This function walks through an Array and recursively calls utf8_encode on the values of each of the elements.
Name | Type | Description |
---|---|---|
$data | \$data | Array of data to encode |
Type | Description |
---|---|
\utf8 | encoded Array data |
verify_image_file(
string $path, bool $jpeg
=
false
)
:
void
Sanitize image file from hostile content
Name | Type | Description |
---|---|---|
$path | string | Image file |
$jpeg | bool | Accept only JPEGs? |
verify_uploaded_image(
string $path, bool $jpeg_only
=
false
)
:
void
Verify uploaded image Verifies that image has proper extension, MIME type and doesn't contain hostile content
Name | Type | Description |
---|---|---|
$path | string | Image path |
$jpeg_only | bool | Accept only JPEGs? |