Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AccountsGridViewProfileWidget
  • ActionMenu
  • ActionsGridViewProfileWidget
  • ActionsQuickCreateRelationshipBehavior
  • ActiveDateRangeInput
  • ApplicationConfigBehavior
  • Attachments
  • ChatBox
  • CommonControllerBehavior
  • ContactMapInlineTags
  • ContactsGridViewProfileWidget
  • CronForm
  • CSaveRelationsBehavior
  • DateRangeInputsWidget
  • DocsGridViewProfileWidget
  • DocViewer
  • DocViewerProfileWidget
  • EButtonColumnWithClearFilters
  • EmailDeliveryBehavior
  • EmailProgressControl
  • EncryptedFieldsBehavior
  • EventsChartProfileWidget
  • FileUploader
  • FontPickerInput
  • Formatter
  • FormView
  • GridViewWidget
  • History
  • IframeWidget
  • ImportExportBehavior
  • InlineActionForm
  • InlineEmailAction
  • InlineEmailForm
  • InlineEmailModelBehavior
  • InlineQuotes
  • JSONEmbeddedModelFieldsBehavior
  • JSONFieldsDefaultValuesBehavior
  • LeadRoutingBehavior
  • LeftWidget
  • LoginThemeHelper
  • LoginThemeHelperBase
  • MarketingGridViewProfileWidget
  • MediaBox
  • MessageBox
  • MobileFormatter
  • MobileFormLayoutRenderer
  • MobileLayoutRenderer
  • MobileLoginThemeHelper
  • MobileViewLayoutRenderer
  • ModelFileUploader
  • NewWebLeadsGridViewProfileWidget
  • NormalizedJSONFieldsBehavior
  • NoteBox
  • OnlineUsers
  • OpportunitiesGridViewProfileWidget
  • Panel
  • ProfileDashboardManager
  • ProfileGridViewWidget
  • ProfileLayoutEditor
  • ProfilesGridViewProfileWidget
  • Publisher
  • PublisherActionTab
  • PublisherCalendarEventTab
  • PublisherCallTab
  • PublisherCommentTab
  • PublisherEventTab
  • PublisherSmallCalendarEventTab
  • PublisherTab
  • PublisherTimeTab
  • QuickContact
  • QuickCreateRelationshipBehavior
  • QuotesGridViewProfileWidget
  • RecordAliasesWidget
  • RecordViewLayoutManager
  • RecordViewWidgetManager
  • RememberPagination
  • Reminders
  • ResponseBehavior
  • ResponsiveHtml
  • SearchIndexBehavior
  • ServicesGridViewProfileWidget
  • SmallCalendar
  • SmartActiveDataProvider
  • SmartDataProviderBehavior
  • SmartSort
  • SocialForm
  • SortableWidgetManager
  • SortableWidgets
  • TagBehavior
  • TagCloud
  • TemplatesGridViewProfileWidget
  • TimeZone
  • TopContacts
  • TopSites
  • TransformedFieldStorageBehavior
  • TranslationLogger
  • TwitterFeed
  • TwoColumnSortableWidgetManager
  • UpdaterBehavior
  • UpdatesForm
  • UserIdentity
  • UsersChartProfileWidget
  • WorkflowBehavior
  • X2ActiveGridView
  • X2ActiveGridViewForSortableWidgets
  • X2AssetManager
  • X2AuthManager
  • X2ChangeLogBehavior
  • X2ClientScript
  • X2Color
  • X2DateUtil
  • X2FixtureManager
  • X2FlowFormatter
  • X2GridView
  • X2GridViewBase
  • X2GridViewForSortableWidgets
  • X2GridViewSortableWidgetsBehavior
  • X2LeadsGridViewProfileWidget
  • X2LinkableBehavior
  • X2ListView
  • X2PillBox
  • X2ProgressBar
  • X2SmartSearchModelBehavior
  • X2TimestampBehavior
  • X2TranslationBehavior
  • X2UrlRule
  • X2WebModule
  • X2Widget
  • X2WidgetList
  • Overview
  • Package
  • Class
  • Tree

Class ImportExportBehavior

Behavior for dealing with data files directly on the server while avoiding directory traversal and publicly visible files.

CComponent
Extended by CBehavior implements IBehavior
Extended by ImportExportBehavior
Package: application\components
Author: Demitri Morgan <demitri@x2engine.com>
Author: Raymond Colebaugh <raymond@x2engine.com>
Located at x2engine/protected/components/ImportExportBehavior.php
Methods summary
public false
# sendFile( type $file, mixed $deleteAfterSend = false )

Sends the file to the web client upon request

Sends the file to the web client upon request

Parameters

$file
type
$file
$deleteAfterSend

Returns

false
if send file failed (if successful, script is terminated)
public type
# safePath( type $filename = 'data.csv' )

Returns a file path that is within the protected folder, to protect data

Returns a file path that is within the protected folder, to protect data

Parameters

$filename
type
$filename

Returns

type
public string
# getImportDelimeter( )

Retrieve the current CSV delimeter for import/export

Retrieve the current CSV delimeter for import/export

Returns

string
Import CSV delimeter
public string
# getImportEnclosure( )

Retrieve the current CSV enclosure for import/export

Retrieve the current CSV enclosure for import/export

Returns

string
Import CSV enclosure
protected array
# importTags( string $modelName, string $tagsField )

Create tag records for each of the specified tags

Create tag records for each of the specified tags

Parameters

$modelName
string
$modelName The model class being imported
$tagsField
string
$tagsField Comma separated list of tags to generate

Returns

array
of Tag attributes
protected array
# availableImportMaps( string $model = null )

List available import maps from a directory, optionally of type $model

List available import maps from a directory, optionally of type $model

Parameters

$model
string
$model Name of the model to load import maps

Returns

array
Available import maps, with the filenames as keys, and import mapping names (product/version) as values
protected array
# loadImportMap( string $filename )

Load an import map from the map directory

Load an import map from the map directory

Parameters

$filename
string
$filename of the import map

Returns

array
Import map
protected
# verifyImportMap( string $model, array $keys, array $attributes, boolean $createFields = false )

Parse the given keys and attributes to ensure required fields are mapped and new fields are to be created. The verified map will be stored in the 'importMap' key for the $_SESSION super global.

Parse the given keys and attributes to ensure required fields are mapped and new fields are to be created. The verified map will be stored in the 'importMap' key for the $_SESSION super global.

Parameters

$model
string
$model name of the model
$keys
array
$keys
$attributes
array
$attributes
$createFields
boolean
$createFields whether or not to create new fields
protected
# normalizeImportMap( array $map, array $fields )

Insert placeholders for unmapped fields to ensure the import map contains all possible fields

Insert placeholders for unmapped fields to ensure the import map contains all possible fields

Parameters

$map
array
$map Import map
$fields
array
$fields Metadata fields from CSV

Returns

array Normalized import map
protected
# calculateCsvLength( mixed $csvfile )

Calculates the number of lines in a CSV file for import Warning: This must load and traverse the length of the file

Calculates the number of lines in a CSV file for import Warning: This must load and traverse the length of the file

protected
# fixCsvLineEndings( string $csvFile )

Remove any lone \r characters

Remove any lone \r characters

Parameters

$csvFile
string
$csvfile Path to CSV file
protected array
# initializeModelImporter( resource $fp )

Read metadata from the CSV and initialize session variables

Read metadata from the CSV and initialize session variables

Parameters

$fp
resource
$fp File pointer to CSV

Returns

array
CSV Metadata and X2Attributes
protected
# createImportMap( array $attributes, array $meta )

The goal of this function is to attempt to map meta into a series of Contact attributes, which it will do via string comparison on the Contact attribute names, the Contact attribute labels and a pattern match.

The goal of this function is to attempt to map meta into a series of Contact attributes, which it will do via string comparison on the Contact attribute names, the Contact attribute labels and a pattern match.

Parameters

$attributes
array
$attributes Contact model's attributes
$meta
array
$meta Provided metadata in the CSV
protected
# setCurrentActionText( mixed $attributes = null )

Append an empty placeholder for action texts, or set the attribute of the last action text in the container if attributes are specified

Append an empty placeholder for action texts, or set the attribute of the last action text in the container if attributes are specified

protected
# importRecordAttribute( string $modelName, X2Model $model, string $fieldName, string $importAttribute )

The import assumes we have human readable data in the CSV and will thus need to convert. This method converts link, date, and dateTime fields to the appropriate machine friendly data.

The import assumes we have human readable data in the CSV and will thus need to convert. This method converts link, date, and dateTime fields to the appropriate machine friendly data.

Parameters

$modelName
string
$modelName The model class being imported
$model
X2Model
$model The currently importing model record
$fieldName
string
$fieldName Field to set
$importAttribute
string
$importAttribute Value to set field

Returns

X2Model $model
protected
# importRecordLinkAttribute( string $modelName, X2Model $model, Fields $fieldRecord, string $importAttribute )

Handle setting link type fields and create linked records if specified

Handle setting link type fields and create linked records if specified

Parameters

$modelName
string
$modelName The model class being imported
$model
X2Model
$model The currently importing model record
$fieldRecord
Fields
$fieldRecord Field to set
$importAttribute
string
$importAttribute Value to set field

Returns

X2Model $model
protected static
# fixupImportedContactName( mixed $model )

Helper method to help out the user in the special case where a Contact's full name is set, but first and last name aren't, or vice versa.

Helper method to help out the user in the special case where a Contact's full name is set, but first and last name aren't, or vice versa.

Parameters

$model
mixed
$model

Returns

X2Model $model
protected
# fixupImportedAttributes( string $modelName, X2Model $model )

This method is used after importing a records attributes to perform extra tasks, such as assigning lead routing, setting visibility, and reconstructing Action associations.

This method is used after importing a records attributes to perform extra tasks, such as assigning lead routing, setting visibility, and reconstructing Action associations.

Parameters

$modelName
string
$modelName Name of the model being imported
$model
X2Model
$model Current model to import

Returns

X2Model $model
protected
# saveImportedModel( X2Model $model, array $modelName, mixed $importedIds )

Remove a record with the same ID, save the model attributes in the container, and increment the count of imported records

Remove a record with the same ID, save the model attributes in the container, and increment the count of imported records

Parameters

$model
X2Model
$model
$modelName
array
$importedIds Array of ids from imported models
$importedIds
protected integer
# insertMultipleRecords( string $modelType, array $models )

Execute a multiple insert command

Execute a multiple insert command

Parameters

$modelType
string
$modelType Child of X2Model
$models
array
$models Array of model attributes to create

Returns

integer
Last inserted id
protected array
# prepareImportSampleRecords( mixed $meta, mixed $fp )

This grabs 5 sample records from the CSV to get an example of what the data looks like.

This grabs 5 sample records from the CSV to get an example of what the data looks like.

Returns

array
Sample records
protected
# reconstructImportedActionAssoc( Actions $model )

Handle reconstructing and validating Action associations

Handle reconstructing and validating Action associations

Parameters

$model
Actions
$model Action to reconstruct association

Returns

Actions $model
protected
# finishImportBatch( string $modelName, boolean $mappedId, boolean $finished = false )

Finalize this batch of records by performing a mass insert, handling accounting, updating nameIds, and rendering the JSON response

Finalize this batch of records by performing a mass insert, handling accounting, updating nameIds, and rendering the JSON response

Parameters

$modelName
string
$modelName Name of the model class being imported
$mappedId
boolean
$mappedId Whether the primary model's ID has been mapped: this alters the result of lastInsertId
$finished
boolean
$finished Whether this batch has reached the end of the CSV
protected
# massUpdateImportedNameIds( array $importedIds, string $type )

Populate the nameId field since auto-populating fields is disabled and it is far more efficient to do it in a single query

Populate the nameId field since auto-populating fields is disabled and it is far more efficient to do it in a single query

Parameters

$importedIds
array
$importedIds List of record ids
$type
string
$type Model name
protected
# triggerImportedRecords( array $importedIds, string $type )

Trigger the X2Workflow RecordCreateTrigger on the imported models

Trigger the X2Workflow RecordCreateTrigger on the imported models

Parameters

$importedIds
array
$importedIds List of record ids
$type
string
$type Model name
protected
# handleImportAccounting( array $models, string $modelName, array $lastInsertedIds, boolean $mappedId = false )

Create additional records related to the import, including the requested Tags, comment Actions, Import records, Events, and Relationships

Create additional records related to the import, including the requested Tags, comment Actions, Import records, Events, and Relationships

Parameters

$models
array
$models Array of arrays of model attributes
$modelName
string
$modelName Name of the model being imported
$lastInsertedIds
array
$lastInsertedIds The last MySQL IDs that were created, indexed by model type
$mappedId
boolean
$mappedId Whether ID was mapped: this affects lastInsertId's behavior
protected
# fixupLinkFields( integer $modelName, string $type, string $primaryIdRange )

Process the link-type fields to set nameId

Process the link-type fields to set nameId

Parameters

$modelName
integer
$count The number of primary models being imported
$type
string
$modelName The primary model being imported
$primaryIdRange
string
$type The model of the linked record
protected
# establishImportRelationships( integer $firstNewId, boolean $mappedId = false )

Create relationships records for the linked models

Create relationships records for the linked models

Parameters

$firstNewId
integer
$firstNewId The first inserted id
$mappedId
boolean
$mappedId Whether or not ID was a mapped field
protected
# markFailedRecord( string $modelName, X2Model $model, array $csvLine, array $metaData )

Save the failed record into a CSV with validation errors

Save the failed record into a CSV with validation errors

Parameters

$modelName
string
$modelName
$model
X2Model
$model
$csvLine
array
$csvLine
$metaData
array
$metadata
protected
# loadUploadedImportMap( )

Save and attempt to load the uploaded import mapping

Save and attempt to load the uploaded import mapping

protected array
# readExportFormatOptions( array $params )

Retrieve all associated export format options from the request parameters

Retrieve all associated export format options from the request parameters

Parameters

$params
array
$params Request parameters, e.g., $_GET

Returns

array
of format options, indexed by form element ID
protected string
# adjustExportPath( string $path, array $params, string $filetype = 'csv' )

Modifies the export path to ensure a consistent file extensions

Modifies the export path to ensure a consistent file extensions

Parameters

$path
string
$path Path to export file
$params
array
$params Export format parameters
$filetype
string
$filetype Expected file extension

Returns

string
$path Modified export path
public
# prepareExportDeliverable( mixed $src, mixed $params )
Methods inherited from CBehavior
attach(), detach(), events(), getEnabled(), getOwner(), setEnabled()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Magic properties inherited from CBehavior
$enabled, $owner
X2CRM Documentation API documentation generated by ApiGen 2.8.0