data/SugarBean.php
\SugarBean
SugarBean is the base class for all business objects in Sugar. It implements the primary functionality needed for manipulating business objects: create, retrieve, update, delete. It allows for searching and retrieving list of records.
It allows for retrieving related objects (e.g. contacts related to a specific account).
In the current implementation, there can only be one bean per folder. Naming convention has the bean name be the same as the module and folder name. All bean names should be singular (e.g. Contact). The primary table name for a bean should be plural (e.g. contacts).
- Children
- \KBDocumentKBTag
- \UserPreference
- \Product
- \KBDocumentViewsRating
- \KBDocument
- \Shipper
- \KBContent
- \WorkFlowAlert
- \ProductCategory
- \Role
- \Call
- \ProductBundleNote
- \WorkFlowTriggerShell
- \Expression
- \SavedReport
- \ImportMap
- \UsersLastImport
- \ProjectTask
- \Document
- \KBTag
- \UserSignature
- \FieldsMetaData
- \TrackerSession
- \TrackerPerf
- \Tracker
- \TrackerQuery
- \Manufacturer
- \TeamSetModule
- \Team
- \TeamMembership
- \TeamSet
- \Scheduler
- \Opportunity
- \Contract
- \EmailText
- \ACLAction
- \Audit
- \Release
- \ACLRole
- \WorkFlowActionShell
- \Meeting
- \Project
- \ProjectResource
- \Version
- \SavedSearch
- \Note
- \Campaign
- \ProductBundle
- \OAuthToken
- \CustomQuery
- \WorkFlowAlertShell
- \ForecastSchedule
- \ContractType
- \Currency
- \ProductTemplate
- \TaxRate
- \Quota
- \ForecastOpportunities
- \ForecastDirectReports
- \Worksheet
- \Forecast
- \TimePeriod
- \EmailMan
- \WorkFlowAction
- \DocumentRevision
- \Task
- \ReportMaker
- \EmailMarketing
- \ContactOpportunityRelationship
- \ContactQuoteRelationship
- \Quote
- \ProductType
- \DataSet_Attribute
- \DataSet
- \DataSet_Layout
- \SessionManager
- \System
- \Administration
- \UpgradeHistory
- \vCal
- \TeamNotice
- \Bug
- \Relationship
- \Holiday
- \WorkFlowSchedule
- \WorkFlow
- \KBDocumentRevision
- \ProspectList
- \EmailTemplate
- \CampaignLog
- \CampaignTracker
- \InboundEmail
- \MergeRecord
- \Basic
- \SugarEmailAddress
- \Controller
- Api
Properties
BOOL
$deleted= '0'
true if this bean has been deleted, false otherwise.
0
Details- Type
- BOOL
BOOL
$disable_row_level_security= 'false'
Pro Only -- When all data of a specifiy module is publically available, row level security can be turned off. This should only be used for modules that do not need row level security.
-- default falsefalse
Details- Type
- BOOL
BOOL
$disable_vardefs= 'false'
Disble vardefs. This should be set to true only for beans that do not have varders. Tracker is an example
-- default falsefalse
Details- Type
- BOOL
BOOL
$duplicates_found= 'false'
When running a query on related items using the method: retrieve_by_string_fields this value will be set to true if more than one item matches the search criteria.
false
Details- Type
- BOOL
$importable= 'false'
Set to true in the child beans if the module supports importing
false
Details- Type
- n/a
$in_import= 'false'
Set to true in <modules>/Import/views/view.step4.php if a module is being imported
false
Details- Type
- n/a
$in_workflow= 'false'
Set to true if the bean is being dealt with in a workflow
false
Details- Type
- n/a
$is_updated_dependent_fields= 'false'
set to true if dependent fields updated
false
Details- Type
- n/a
$listview_inner_join= 'array()'
Used to pass inner join string to ListView Data.
array()
Details- Type
- n/a
array
$loaded_relationships= 'array()'
A way to keep track of the loaded relationships so when we clone the object we can unset them.
array()
Details- Type
- array
String
$module_dir= ''''
The name of the module folder for this type of bean.
''
Details- Type
- String
String
$new_assigned_user_name= ''
holds the full name of the user that an item is assigned to. Only used if notifications are turned on and going to be sent out.
- Type
- String
BOOL
$new_with_id= 'false'
When createing a bean, you can specify a value in the id column as long as that value is unique. During save, if the system finds an id, it assumes it is an update. Setting new_with_id to true will make sure the system performs an insert instead of an update.
-- default falsefalse
Details- Type
- BOOL
String
$object_name= ''''
This is the singular name of the bean. (i.e. Contact).
''
Details- Type
- String
BOOL
$process_save_dates= 'true'
Whether to process date/time fields for storage in the database in GMT
true
Details- Type
- BOOL
Array
$processed_dates_times= 'array()'
An array of booleans. This array is cleared out when data is loaded.
of booleansAs date/times are converted, a "1" is placed under the key, the field is converted.
array()
Details- Type
- Array
BOOL
$save_from_post= 'true'
This signals to the bean that it is being saved in a mass mode.
Examples of this kind of save are import and mass update. We turn off notificaitons of this is the case to make things more efficient.
true
Details- Type
- BOOL
\unknown_type
$set_created_by= 'true'
This allows for seed data to be created without using the current uesr to set the id.
This should be replaced by altering the current user before the call to save.
true
Details- Type
- \unknown_type
$special_notification= 'false'
Set to true in the child beans if the module use the special notification template
false
Details- Type
- n/a
String
$table_name= ''''
The database table where records of this Bean are stored.
''
Details- Type
- String
$tracker_visibility= 'true'
By default it will be true but if any module is to be kept non visible to tracker, then its value needs to be overriden in that particular module to false.
true
Details- Type
- n/a
$ungreedy_count= 'false'
Set this to true if you query contains a sub-select and bean is converting both select statements into count queries.
false
Details- Type
- n/a
BOOL
$update_date_entered= 'false'
Setting this to true allows for updates to overwrite the date_entered
false
Details- Type
- BOOL
BOOL
$update_date_modified= 'true'
Should the date modified column of the bean be updated during save? This is used for admin level functionality that should not be updating the date modified. This is only used by sync to allow for updates to be replicated in a way that will not cause them to be replicated back.
true
Details- Type
- BOOL
BOOL
$update_modified_by= 'true'
Should the modified by column of the bean be updated during save? This is used for admin level functionality that should not be updating the modified by column. This is only used by sync to allow for updates to be replicated in a way that will not cause them to be replicated back.
true
Details- Type
- BOOL
Methods
ACLAccess(
\$view $view, \$is_owner $is_owner
=
'not_set'
)
:
void
Check whether the user has access to a particular view for the current bean/module
Name | Type | Description |
---|---|---|
$view | \$view | string required, the view to determine access for i.e. DetailView, ListView... |
$is_owner | \$is_owner | bool optional, this is part of the ACL check if the current user is an owner they will receive different access |
SugarBean(
)
:
void
Constructor for the bean, it performs following tasks:
- Initalized a database connections
- Load the vardefs for the module implemeting the class. cache the entries if needed
- Setup row-level security preference All implementing classes must call this constructor using the parent::SugarBean() class.
__clone(
)
:
void
Handle the following when a SugarBean object is cloned
Currently all this does it unset any relationships that were created prior to cloning the object
- Api
_checkOptimisticLocking(
$action, $isUpdate
)
:
void
Moved from save() method, functionality is the same, but this is intended to handle Optimistic locking functionality.
Name | Type | Description |
---|---|---|
$action | ||
$isUpdate |
_get_num_rows_in_query(
string $query, boolean $is_count_query
=
false
)
:
int
Returns the number of rows that the given SQL query should produce
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | string | valid select query |
$is_count_query | boolean | Optional, Default false, set to true if passed query is a count query. |
Type | Description |
---|---|
int | count of rows found |
_loadCachedArray(
\$module_dir $module_dir, \$module $module, \$key $key
)
:
void
This function is designed to cache references to field arrays that were previously stored in the bean files and have since been moved to separate files. Was previously in include/CacheHandler.php
Name | Type | Description |
---|---|---|
$module_dir | \$module_dir | string the module directory |
$module | \$module | string the name of the module |
$key | \$key | string the type of field array we are referencing, i.e. list_fields, column_fields, required_fields |
- Deprecated
_sendNotifications(
$check_notify
)
:
void
Send assignment notifications and invites for meetings and calls
Name | Type | Description |
---|---|---|
$check_notify |
add_address_streets(
string $street_field
)
:
void
Combined the contents of street field 2 thru 4 into the main field
Name | Type | Description |
---|---|---|
$street_field | string |
add_list_count_joins(
string $query, string $where
)
:
void
Add any required joins to the list count query. The joins are required if there is a field in the $where clause that needs to be joined.
Name | Type | Description |
---|---|---|
$query | string | |
$where | string | Internal Function, do Not override. |
add_team_security_where_clause(
$query, $table_alias
=
'', $join_type
=
'INNER', $force_admin
=
false, $join_teams
=
false
)
:
void
Add a join to the query to enforce the data returned will only be for teams to which this user has membership
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | ||
$table_alias | ||
$join_type | ||
$force_admin | ||
$join_teams |
afterImportSave(
)
:
void
Called during the import process after a bean save, to handle any needed post-save logic when importing a record
beforeImportSave(
)
:
void
Called during the import process before a bean save, to handle any needed pre-save logic when importing a record
build_generic_where_clause(
$value
)
:
void
Override this function to build a where clause based on the search criteria set into bean .
Name | Type | Description |
---|---|---|
$value |
- Abstract
build_related_in(
string $query
)
:
void
Constructs an comma separated list of ids from passed query results.
Name | Type | Description |
---|---|---|
$query | string | @query query to be executed. |
build_related_list(
string $query, object $template, int $row_offset
=
0, int $limit
=
-1
)
:
array
This function is used to execute the query and create an array template objects from the resulting ids from the query.
It is currently used for building sub-panel arrays.
Name | Type | Description |
---|---|---|
$query | string |
|
$template | object |
|
$row_offset | int | Optional, default 0 |
$limit | int | Optional, default -1 |
Type | Description |
---|---|
array |
build_related_list2(
string $query, object $template, array $field_list
)
:
array
Optionally copies values from fetched row into the bean.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | string |
|
$template | object |
|
$field_list | array | List of fields. |
Type | Description |
---|---|
array |
build_related_list_where(
string $query, object $template, $where
=
'', $in
=
'', $order_by, $limit
=
'', $row_offset
=
0
)
:
void
This function is used to execute the query and create an array template objects from the resulting ids from the query.
It is currently used for building sub-panel arrays. It supports an additional where clause that is executed as a filter on the results
Name | Type | Description |
---|---|---|
$query | string |
|
$template | object |
|
$where | ||
$in | ||
$order_by | ||
$limit | ||
$row_offset |
build_sub_queries_for_union(
$subpanel_list, $subpanel_def, $parentbean, $order_by
)
:
void
Name | Type | Description |
---|---|---|
$subpanel_list | ||
$subpanel_def | ||
$parentbean | ||
$order_by |
call_custom_logic(
$event, $arguments
=
null
)
:
void
Trigger custom logic for this module that is defined for the provided hook The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
That file should define the $hook_version that should be used. It should also define the $hook_array. The $hook_array will be a two dimensional array the first dimension is the name of the event, the second dimension is the information needed to fire the hook. Each entry in the top level array should be defined on a single line to make it easier to automatically replace this file. There should be no contents of this file that are not replacable.
$hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1'); This sample line creates a before_save hook. The hooks are procesed in the order in which they are added to the array. The second dimension is an array of: processing index (for sorting before exporting the array) A logic type hook label/type php file to include php class the method is in php method to call
The method signature for version 1 hooks is: function NAME(&$bean, $event, $arguments) $bean - $this bean passed in by reference. $event - The string for the current event (i.e. before_save) $arguments - An array of arguments that are specific to the event.
Name | Type | Description |
---|---|---|
$event | ||
$arguments |
call_relationship_handler(
$target_base
=
"module_dir", $return_handler
=
false
)
:
void
Name | Type | Description |
---|---|---|
$target_base | ||
$return_handler |
call_vardef_handler(
$meta_array_type
=
null
)
:
void
Name | Type | Description |
---|---|---|
$meta_array_type |
check_date_relationships_load(
)
:
\this
This function retrieves a record of the appropriate type from the DB.
It fills in all of the fields from the DB into the object it was called on.
Type | Description |
---|---|
\this | - The object that it was called apon or null if exactly 1 record was not found. |
convertField(
$fieldvalue, $fieldDef
)
:
string
Converts the field value based on the provided fieldDef
Name | Type | Description |
---|---|---|
$fieldvalue | ||
$fieldDef |
Type | Description |
---|---|
string |
convertRow(
array $row
)
:
array
Convert row data from DB format to internal format Mostly useful for dates/times
Name | Type | Description |
---|---|---|
$row | array |
Type | Description |
---|---|
array | $row |
createRelationshipMeta(
string $key, object $db, string $tablename, array $dictionary, string $module_dir, boolean $iscustom
=
false
)
:
void
Populates the relationship meta for a module.
It is called during setup/install. It is used statically to create relationship meta data for many-to-many tables.
Name | Type | Description |
---|---|---|
$key | string | name of the object. |
$db | object | database handle. |
$tablename | string | table, meta data is being populated for. |
$dictionary | array | dictionary vardef dictionary for the object. * |
$module_dir | string | module_dir name of subdirectory where module is installed. |
$iscustom | boolean | Optional,set to true if module is installed in a custom directory. Default value is false. |
- Static
- Internal function, do not override.
create_audit_table(
)
:
void
If auditing is enabled, create the audit table.
Function is used by the install scripts and a repair utility in the admin panel.
Internal function, do not override.
create_export_query(
string $order_by, string $where
)
:
string
Returns the query used for the export functionality for a module. Override this method if you wish to have a custom query to pull this data together instead
Name | Type | Description |
---|---|---|
$order_by | string | |
$where | string |
Type | Description |
---|---|
string | SQL query |
create_index(
$query
)
:
void
This is a helper function that is used to quickly created indexes when creating tables.
Name | Type | Description |
---|---|---|
$query |
create_list_count_query(
string $query
)
:
string
Changes the select expression of the given query to be 'count(*)' so you can get the number of items the query will return. This is used to populate the upper limit on ListViews.
Name | Type | Description |
---|---|---|
$query | string | Select query string |
Type | Description |
---|---|
string | count query Internal function, do not override. |
create_new_list_query(
string $order_by, string $where, array $filter
=
array(), array $params
=
array(), int $show_deleted
=
0, string $join_type
=
'', boolean $return_array
=
false, object $parentbean
=
null, boolean $singleSelect
=
false, $ifListForExport
=
false
)
:
String
Return the list query used by the list views and export button. Next generation of create_new_list_query function.
Override this function to return a custom query.
Name | Type | Description |
---|---|---|
$order_by | string | custom order by clause |
$where | string | custom where clause |
$filter | array | Optioanal |
$params | array | Optional * |
$show_deleted | int | Optional, default 0, show deleted records is set to 1. |
$join_type | string | |
$return_array | boolean | Optional, default false, response as array |
$parentbean | object | creating a subquery for this bean. |
$singleSelect | boolean | Optional, default false. |
$ifListForExport |
Type | Description |
---|---|
String | select query string, optionally an array value will be returned if $return_array= true. |
create_notification_email(
string $notify_user
)
:
void
This function handles create the email notifications email.
Name | Type | Description |
---|---|---|
$notify_user | string | the user to send the notification email to |
create_qualified_order_by(
string $order_by, string $qualify
)
:
\prefixed
Ensure that fields within order by clauses are properly qualified with their tablename. This qualification is a requirement for sql server support.
Name | Type | Description |
---|---|---|
$order_by | string | original order by from the query |
$qualify | string | prefix for columns in the order by list. |
Type | Description |
---|---|
\prefixed | Internal function do not override. |
create_relationship_meta(
$key, $db, $log, $tablename, $dictionary, $module_dir
)
:
void
This method has been deprecated.
Name | Type | Description |
---|---|---|
$key | ||
$db | ||
$log | ||
$tablename | ||
$dictionary | ||
$module_dir |
- Deprecated
- 4.5.1 - Nov 14, 2006
- See
- \createRelationshipMeta()
- Static
create_tables(
)
:
void
Creates tables for the module implementing the class.
If you override this function make sure that your code can handles table creation.
decrypt_after_retrieve(
STRING $value
)
:
string
Decode and decrypt a base 64 encoded string with field type 'encrypt' in this bean using Blowfish.
Name | Type | Description |
---|---|---|
$value | STRING | value - an encrypted and base 64 encoded string. |
Type | Description |
---|---|
string |
delete_linked(
string $id
)
:
void
Iterates through all the relationships and deletes all records for reach relationship.
Name | Type | Description |
---|---|---|
$id | string | Primary key value of the parent reocrd |
drop_tables(
)
:
void
Delete the primary table for the module implementing the class.
If custom fields were added to this table/module, the custom table will be removed too, along with the cache entries that define the custom fields.
encrpyt_before_save(
STRING $value
)
:
string
Encrpyt and base64 encode an 'encrypt' field type in the bean using Blowfish. The default system key is stored in cache/Blowfish/{keytype}
Name | Type | Description |
---|---|---|
$value | STRING | value -plain text value of the bean field. |
Type | Description |
---|---|
string |
fill_in_additional_detail_fields(
)
:
void
This is designed to be overridden and add specific fields to each record.
This allows the generic query to fill in the major fields, and then targeted queries to get related fields and add them to the record. The contact's account for instance. This method is only used for populating extra fields in the detail form
fill_in_additional_list_fields(
)
:
void
This is designed to be overridden and add specific fields to each record.
This allows the generic query to fill in the major fields, and then targeted queries to get related fields and add them to the record. The contact's account for instance. This method is only used for populating extra fields in lists.
fill_in_additional_parent_fields(
)
:
void
This is desgined to be overridden or called from extending bean. This method will fill in any parent_name fields.
fill_in_link_field(
$linkFieldName, $def
)
:
void
Name | Type | Description |
---|---|---|
$linkFieldName | ||
$def |
fixUpFormatting(
)
:
void
Function corrects any bad formatting done by 3rd party/custom code
This function will be removed in a future release, it is only here to assist upgrading existing code that expects formatted data in the bean
format_all_fields(
)
:
void
This functions adds formatting to all number fields before presenting them to user interface.
Internal function, do not override.
fromArray(
Array $arr
)
:
void
Converts an array into an acl mapping name value pairs into files
Name | Type | Description |
---|---|---|
$arr | Array |
getACLCategory(
)
:
string
Returns the ACL category for this module; defaults to the SugarBean::$acl_category if defined otherwise it is SugarBean::$module_dir
Type | Description |
---|---|
string |
getAuditEnabledFieldDefinitions(
)
:
\an
Returns a list of fields with their definitions that have the audited property set to true.
Before calling this function, check whether audit has been enabled for the table/module or not. You would set the audit flag in the implemting module's vardef file.
Type | Description |
---|---|
\an | array of |
- See
- \is_AuditEnabled
getFieldDefinition(
string $name
)
:
Array
Returns field definition for the requested field name.
The definitions were loaded in the constructor.
Name | Type | Description |
---|---|---|
$name | string | field name, |
Type | Description |
---|---|
Array | Field properties or boolean false if the field doesn't exist Internal function, do not override. |
getFieldDefinitions(
)
:
Array
Returns field definitions for the implementing module.
The definitions were loaded in the constructor.
Type | Description |
---|---|
Array | Field definitions. Internal function, do not override. |
getFieldValue(
string $name
)
:
\varies
Returns the value for the requested field.
When a row of data is fetched using the bean, all fields are created as variables in the context of the bean and then fetched values are set in these variables.
Name | Type | Description |
---|---|---|
$name | string | field name, |
Type | Description |
---|---|
\varies | Field value. Internal function, do not override. |
getIndices(
)
:
Array
Returns index definitions for the implementing module.
The definitions were loaded in the constructor.
Type | Description |
---|---|
Array | Index definitions. Internal function, do not override. |
getObjectName(
)
:
\nothing
Returns the object name. If object_name is not set, table_name is returned.
All implementing classes must set a value for the object_name variable.
Type | Description |
---|---|
\nothing |
getOwnerField(
$returnFieldName
=
false
)
:
STRING
Get owner field
Name | Type | Description |
---|---|---|
$returnFieldName |
Type | Description |
---|---|
STRING |
getOwnerWhere(
\GUID $user_id
)
:
STRING
Gets there where statement for checking if a user is an owner
Name | Type | Description |
---|---|---|
$user_id | \GUID |
Type | Description |
---|---|
STRING |
getPrimaryFieldDefinition(
)
:
Array
Returnss definition for the id field name.
The definitions were loaded in the constructor.
Type | Description |
---|---|
Array | Field properties. Internal function, do not override. |
getRelatedFields(
$module, $id, $fields, $return_array
=
false
)
:
void
Name | Type | Description |
---|---|---|
$module | ||
$id | ||
$fields | ||
$return_array |
getTableName(
)
:
String
Returns the implementing class' table name.
All implementing classes set a value for the table_name variable. This value is returned as the table name. If not set, table name is extracted from the implementing module's vardef.
Type | Description |
---|---|
String | Table name. Internal function, do not override. |
get_audit_table_name(
)
:
String
Returns the name of the audit table.
Audit table's name is based on implementing class' table name.
Type | Description |
---|---|
String | Audit table name. Internal function, do not override. |
get_custom_table_name(
)
:
String
Returns the name of the custom table.
Custom table's name is based on implementing class' table name.
Type | Description |
---|---|
String | Custom table name. Internal function, do not override. |
get_full_list(
string $order_by
=
"", string $where
=
"", $check_dates
=
false, int $show_deleted
=
0
)
:
void
Returns a full (ie non-paged) list of the current object type.
Name | Type | Description |
---|---|---|
$order_by | string | the order by SQL parameter. defaults to "" |
$where | string | where clause. defaults to "" |
$check_dates | ||
$show_deleted | int | show deleted records. defaults to 0 |
get_import_required_fields(
)
:
array
Returns an array of fields that are required for import
Type | Description |
---|---|
array |
get_importable_fields(
)
:
array
Returns an array of fields that are able to be Imported into i.e. 'importable' not set to 'false'
Type | Description |
---|---|
array | List of fields. Internal function, do not override. |
get_linked_beans(
string $field_name, $bean_name, array $sort_array
=
array(), int $begin_index
=
0, int $end_index
=
-1, int $deleted
=
0, $optional_where
=
""
)
:
void
Returns an array of beans of related data.
For instance, if an account is related to 10 contacts , this function will return an array of contacts beans (10) with each bean representing a contact record. Method will load the relationship if not done so already.
Name | Type | Description |
---|---|---|
$field_name | string | relationship to be loaded. |
$bean_name | ||
$sort_array | array | optional, unused |
$begin_index | int | Optional, default 0, unused. |
$end_index | int | Optional, default -1 |
$deleted | int | Optional, Default 0, 0 adds deleted=0 filter, 1 adds deleted=1 filter. |
$optional_where |
get_linked_fields(
)
:
array
Returns an array of fields that are of type link.
Type | Description |
---|---|
array | List of fields. Internal function, do not override. |
get_list_view_data(
)
:
void
Override this function to set values in the array used to render list view data.
get_related_fields(
)
:
array
Returns an array of fields that are of type relate.
Type | Description |
---|---|
array | List of fields. Internal function, do not override. |
get_related_list(
object $child_seed, string $related_field_name, string $order_by
=
"", string $where
=
"", $row_offset
=
0, $limit
=
-1, $max
=
-1, $show_deleted
=
0
)
:
array
Fetches data from all related tables.
Name | Type | Description |
---|---|---|
$child_seed | object | |
$related_field_name | string | relation to fetch data for |
$order_by | string | Optional, default empty |
$where | string | Optional, additional where clause |
$row_offset | ||
$limit | ||
$max | ||
$show_deleted |
Type | Description |
---|---|
array | Fetched data. Internal function, do not override. |
get_summary_text(
)
:
string
Returns the summary text that should show up in the recent history list for this object.
Type | Description |
---|---|
string |
get_union_related_list(
\SugarBean $parentbean, string $order_by
=
"", string $sort_order
=
'', string $where
=
"", $row_offset
=
0, $limit
=
-1, $max
=
-1, $show_deleted
=
0, $subpanel_def
)
:
void
Constructs a query to fetch data for supanels and list views
It constructs union queries for activities subpanel.
Name | Type | Description |
---|---|---|
$parentbean | \SugarBean | constructing queries for link attributes in this bean |
$order_by | string | Optional, order by clause |
$sort_order | string | Optional, sort order |
$where | string | Optional, additional where clause Internal Function, do not overide. |
$row_offset | ||
$limit | ||
$max | ||
$show_deleted | ||
$subpanel_def |
get_where(
array $fields_array, boolean $deleted
=
true
)
:
string
Construct where clause from a list of name-value pairs.
Name | Type | Description |
---|---|---|
$fields_array | array | Name/value pairs for column checks |
$deleted | boolean | Optional, default true, if set to false deleted filter will not be added. |
Type | Description |
---|---|
string | The WHERE clause |
handle_preset_relationships(
string | boolean $new_rel_id, string $new_rel_link, array $exclude
=
array()
)
:
string | boolean
Handle the preset fields listed in the fixed relationship_fields array hardcoded into the OOB beans
TODO: remove this mechanism and replace with mechanism exclusively based on the vardefs
Name | Type | Description |
---|---|---|
$new_rel_id | string | boolean | String of the ID to add |
$new_rel_link | string | Relationship Name |
$exclude | array | any relationship's to exclude |
Type | Description |
---|---|
string | boolean | Return the new_rel_id if it was not used. False if it was used. |
- Api
- See
- \save_relationship_changes
handle_remaining_relate_fields(
array $exclude
=
array()
)
:
array
Next, we'll attempt to update all of the remaining relate fields in the vardefs that have 'save' set in their field_def Only the 'save' fields should be saved as some vardef entries today are not for display only purposes and break the application if saved If the vardef has entries for field of type relate, where a->id_name = and field of type link then we receive a value for b from the MVC in the _REQUEST, and it should be set in the bean as $this->$b
Name | Type | Description |
---|---|---|
$exclude | array | any relationship's to exclude |
Type | Description |
---|---|
array | the list of relationships that were added or removed successfully or if they were a failure |
- Api
- See
- \save_relationship_changes
handle_request_relate(
string | boolean $new_rel_id, string $new_rel_link
)
:
boolean
Finally, we update a field listed in the _REQUEST['%/relate_id']/_REQUEST['relate_to'] mechanism (if it has not already been updated)
Name | Type | Description |
---|---|---|
$new_rel_id | string | boolean | |
$new_rel_link | string |
Type | Description |
---|---|
boolean |
- Api
- See
- \save_relationship_changes
has_been_modified_since(
\date $date, string $modified_user_id
)
:
void
Performs a check if the record has been modified since the specified date
Name | Type | Description |
---|---|---|
$date | \date | Datetime for verification |
$modified_user_id | string | User modified by |
has_calc_field_with_link(
string $linkName
=
""
)
:
bool
Tests if the current module has a calculated field with a link.
if a link name is specified, it will return true when a field uses that specific link Otherwise it will test for all link fields.
Name | Type | Description |
---|---|---|
$linkName | string |
Type | Description |
---|---|
bool |
isOwner(
\GUID $user_id
)
:
boolean
Returns true of false if the user_id passed is the owner
Name | Type | Description |
---|---|---|
$user_id | \GUID |
Type | Description |
---|---|
boolean |
is_AuditEnabled(
)
:
boolean
Return true if auditing is enabled for this object You would set the audit flag in the implemting module's vardef file.
Type | Description |
---|---|
boolean | Internal function, do not override. |
list_view_parse_additional_sections(
$list_form
)
:
void
Let implementing classes to fill in row specific columns of a list view form
Name | Type | Description |
---|---|---|
$list_form |
listviewACLHelper(
)
:
ARRAY
Used in order to manage ListView links and if they should links or not based on the ACL permissions of the user
Type | Description |
---|---|
ARRAY | of STRINGS |
loadFromRow(
array $arr
)
:
\nothing
Loads a row of data into instance of a bean. The data is passed as an array to this function
Name | Type | Description |
---|---|---|
$arr | array | row of data fetched from the database. |
Type | Description |
---|---|
\nothing | Internal function do not override. |
load_relationship(
string $rel_name
)
:
\nothing.
Loads the request relationship. This method should be called before performing any operations on the related data.
This method searches the vardef array for the requested attribute's definition. If the attribute is of the type link then it creates a similary named variable and loads the relationship definition.
Name | Type | Description |
---|---|---|
$rel_name | string | relationship/attribute name. |
Type | Description |
---|---|
\nothing. |
load_relationships(
)
:
\Nothing
Loads all attributes of type link.
DO NOT CALL THIS FUNCTION IF YOU CAN AVOID IT. Please use load_relationship directly instead.
Method searches the implmenting module's vardef file for attributes of type link, and for each attribute create a similary named variable and load the relationship definition.
Type | Description |
---|---|
\Nothing | Internal function, do not override. |
mark_deleted(
$id
)
:
void
This function should be overridden in each module. It marks an item as deleted.
If it is not overridden, then marking this type of item is not allowed
Name | Type | Description |
---|---|---|
$id |
mark_relationships_deleted(
int $id
)
:
void
This function deletes relationships to this object. It should be overridden to handle the relationships of the specific object.
This function is called when the item itself is being deleted.
Name | Type | Description |
---|---|---|
$id | int | id of the relationship to delete |
mark_undeleted(
$id
)
:
void
Restores data deleted by call to mark_deleted() function.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$id |
parseDateDefault(
string $value, bool $time
=
false
)
:
string
Create date string from default value like '+1 month'
Name | Type | Description |
---|---|---|
$value | string | |
$time | bool | Should be expect time set too? |
Type | Description |
---|---|
string |
parse_additional_headers(
$list_form, $xTemplateSection
)
:
void
Name | Type | Description |
---|---|---|
$list_form | ||
$xTemplateSection |
populateRelatedBean(
\SugarBean $newbean
)
:
void
Called from ImportFieldSanitize::relate(), when creating a new bean in a related module. Will copies fields over from the current bean into the related. Designed to be overriden in child classes.
Name | Type | Description |
---|---|---|
$newbean | \SugarBean | newly created related bean |
preprocess_fields_on_save(
)
:
void
This function processes the fields before save.
Interal function, do not override.
process_detail_query(
string $query, int $row_offset, int $limit
=
-1, int $max_per_page
=
-1, string $where
=
'', int $offset
=
0
)
:
array
Applies pagination window to select queries used by detail view, executes the query and returns fetched data.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | string | query to be processed. |
$row_offset | int | |
$limit | int | optional, default -1 |
$max_per_page | int | Optional, default -1 |
$where | string | Custom where clause. |
$offset | int | Optional, default 0 |
Type | Description |
---|---|
array | Fetched data. |
process_full_list_query(
string $query, boolean $check_date
=
false
)
:
array
Processes fetched list view data
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | string | query to be processed. |
$check_date | boolean | Optional, default false. if set to true date time values are processed. |
Type | Description |
---|---|
array | Fetched data. |
process_list_query(
string $query, int $row_offset, int $limit
=
-1, int $max_per_page
=
-1, string $where
=
''
)
:
array
Processes the list query and return fetched row.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$query | string | select query to be processed. |
$row_offset | int | starting position |
$limit | int | Optioanl, default -1 |
$max_per_page | int | Optional, default -1 |
$where | string | Optional, additional filter criteria. |
Type | Description |
---|---|
array | Fetched data |
process_order_by(
string $order_by, \SugarBean $submodule
=
null
)
:
string
Prefixes column names with this bean's table name.
Name | Type | Description |
---|---|---|
$order_by | string | Order by clause to be processed |
$submodule | \SugarBean | name of the module this order by clause is for |
Type | Description |
---|---|
string | Processed order by clause Internal function, do not override. |
process_special_fields(
)
:
void
This method is called during an import before inserting a bean Define an associative array called $special_fields the keys are user defined, and don't directly map to the bean's fields the value is the method name within that bean that will do extra processing for that field. example: 'full_name'=>'get_names_from_full_name'
process_union_list_query(
object $parent_bean, string $query, int $row_offset, int $limit
=
-1, int $max_per_page
=
-1, string $where
=
'', array $subpanel_def, string $query_row_count
=
'', $secondary_queries
=
array()
)
:
array
Applies pagination window to union queries used by list view and subpanels, executes the query and returns fetched data.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$parent_bean | object | |
$query | string | query to be processed. |
$row_offset | int | |
$limit | int | optional, default -1 |
$max_per_page | int | Optional, default -1 |
$where | string | Custom where clause. |
$subpanel_def | array | definition of sub-panel to be processed |
$query_row_count | string | |
$secondary_queries |
Type | Description |
---|---|
array | Fetched data. |
process_workflow_alerts(
)
:
void
Any alerts that have been placed into the session, be sure to process them.
This function was created as a result of bug 7908
removeRelationshipMeta(
string $key, string $db, string $tablename, string $dictionary, string $module_dir
)
:
\Nothing
Removes relationship metadata cache.
Every module that has relationships defined with other modules, has this meta data cached. The cache is stores in 2 locations: relationships table and file system. This method clears the cache from both locations.
Name | Type | Description |
---|---|---|
$key | string | module whose meta cache is to be cleared. |
$db | string | database handle. |
$tablename | string | table name |
$dictionary | string | vardef for the module |
$module_dir | string | name of subdirectory where module is installed. |
Type | Description |
---|---|
\Nothing |
- Static
- Internal function, do not override.
remove_relationship_meta(
$key, $db, $log, $tablename, $dictionary, $module_dir
)
:
void
This method has been deprecated.
Name | Type | Description |
---|---|---|
$key | ||
$db | ||
$log | ||
$tablename | ||
$dictionary | ||
$module_dir |
- Deprecated
- 4.5.1 - Nov 14, 2006
- See
- \removeRelationshipMeta()
- Static
retrieve(
string $id
=
-1, boolean $encode
=
true, boolean $deleted
=
true
)
:
void
Function fetches a single row of data given the primary key value.
The fetched data is then set into the bean. The function also processes the fetched data by formattig date/time and numeric values.
Name | Type | Description |
---|---|---|
$id | string | Optional, default -1, is set to -1 id value from the bean is used, else, passed value is used |
$encode | boolean | Optional, default true, encodes the values fetched from the database. |
$deleted | boolean | Optional, default true, if set to false deleted filter will not be added. Internal function, do not override. |
retrieve_by_string_fields(
array $fields_array, boolean $encode
=
true, boolean $deleted
=
true
)
:
object
Constructs a select query and fetch 1 row using this query, and then process the row
Internal function, do not override.
Name | Type | Description |
---|---|---|
$fields_array | array | @fields_array array of name value pairs used to construct query. |
$encode | boolean | Optional, default true, encode fetched data. |
$deleted | boolean | Optional, default true, if set to false deleted filter will not be added. |
Type | Description |
---|---|
object | Instance of this bean with fetched data. |
retrieve_parent_fields(
array $type_info
)
:
void
Returns parent record data for objects that store relationship information
Name | Type | Description |
---|---|---|
$type_info | array | Interal function, do not override. |
retrieve_relationships(
$table, $values, $select_id
)
:
void
Name | Type | Description |
---|---|---|
$table | ||
$values | ||
$select_id |
save(
boolean $check_notify
=
FALSE
)
:
void
Implements a generic insert and update logic for any SugarBean This method only works for subclasses that implement the same variable names.
This method uses the presence of an id field that is not null to signify and update. The id field should not be set otherwise.
Name | Type | Description |
---|---|---|
$check_notify | boolean | Optional, default false, if set to true assignee of the record is notified via email. |
- Todo
- Add support for field type validation and encoding of parameters.
save_relationship_changes(
boolean $is_update, array $exclude
=
array()
)
:
void
This function is a good location to save changes that have been made to a relationship.
This should be overridden in subclasses that have something to save.
Name | Type | Description |
---|---|---|
$is_update | boolean | true if this save is an update. |
$exclude | array | a way to exclude relationships |
send_assignment_notifications(
string $notify_user, string $admin
)
:
void
Handles sending out email notifications when items are first assigned to users
Name | Type | Description |
---|---|---|
$notify_user | string | user to notify |
$admin | string | the admin user that sends out the notification |
set_relationship(
$table, $relate_values, $check_duplicates
=
true, $do_update
=
false, $data_values
=
null
)
:
void
Name | Type | Description |
---|---|---|
$table | ||
$relate_values | ||
$check_duplicates | ||
$do_update | ||
$data_values |
set_relationship_info(
array $exclude
=
array()
)
:
array
Look in the bean for the new relationship_id and relationship_name if $this->not_use_rel_in_req is set to true, otherwise check the $_REQUEST param for a relate_id and relate_to field. Once we have that make sure that it's not excluded from the passed in array of relationships to exclude
Name | Type | Description |
---|---|---|
$exclude | array | any relationship's to exclude |
Type | Description |
---|---|
array | The relationship_id and relationship_name in an array |
setupCustomFields(
string $module_name, boolean $clean_load
=
true
)
:
void
Loads the definition of custom fields defined for the module.
Local file system cache is created as needed.
Name | Type | Description |
---|---|---|
$module_name | string | setting up custom fields for this module. |
$clean_load | boolean | Optional, default true, rebuilds the cache if set to true. |
toArray(
$dbOnly
=
false, $stringOnly
=
false, $upperKeys
=
false
)
:
array
returns this bean as an array
Name | Type | Description |
---|---|---|
$dbOnly | ||
$stringOnly | ||
$upperKeys |
Type | Description |
---|---|
array | of fields with id, name, access and category |
track_view(
string $user_id, string $current_module, string $current_view
=
''
)
:
void
Tracks the viewing of a detail record.
This leverages get_summary_text() which is object specific.
Internal function, do not override.
Name | Type | Description |
---|---|---|
$user_id | string |
|
$current_module | string |
|
$current_view | string |
|
unPopulateDefaultValues(
)
:
void
Basically undoes the effects of SugarBean::populateDefaultValues(); this method is best called right after object initialization.
unformat_all_fields(
)
:
void
Removes formatting from values posted from the user interface.
It only unformats numbers. Function relies on user/system prefernce for format strings.
Internal Function, do not override.
updateDependentFieldForListView(
$listview_def_main
=
''
)
:
void
Name | Type | Description |
---|---|---|
$listview_def_main |