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

  • ActionMetaData
  • ActionText
  • Admin
  • AmorphousModel
  • ApiHook
  • APIModel
  • ChartSetting
  • ContactForm
  • ContactList
  • Credentials
  • Criteria
  • Dropdowns
  • Events
  • EventsData
  • Fields
  • FormLayout
  • Imports
  • InlineEmail
  • LeadRouting
  • Locations
  • LoginForm
  • Maps
  • Modules
  • Notes
  • Notification
  • PhoneNumber
  • Profile
  • Record
  • Relationships
  • Roles
  • RoleToPermission
  • RoleToUser
  • RoleToWorkflow
  • Rules
  • Session
  • SessionLog
  • Social
  • Tags
  • TempFile
  • Tips
  • Tours
  • TrackEmail
  • TriggerLog
  • URL
  • ViewLog
  • Widgets
  • X2List
  • X2ListCriterion
  • X2ListItem
  • X2Model
  • Overview
  • Package
  • Class
  • Tree

Class X2Model

General model class that uses dynamic fields

CComponent
Extended by CModel implements IteratorAggregate, ArrayAccess
Extended by CActiveRecord
Extended by X2ActiveRecord
Extended by X2Model

Direct known subclasses

Accounts, Actions, ProductFeature, Quote, Services, Templates, Topics, X2Leads, X2List, BugReports, Campaign, Contacts, Docs, Groups, Media, Opportunity, Product

Indirect known subclasses

ContactList
Abstract
Package: application\models
Located at x2engine/protected/models/X2Model.php
Methods summary
public
# __construct( string $scenario = 'insert', mixed $uid = null, mixed $dbPersistentGridSettings = false, mixed $disablePersistentGridSettings = false )

Initialize the model.

Initialize the model.

Calls X2Model::queryFields() before CActiveRecord::__constructo() is called, and populates the model with default values, if any.

Parameters

$scenario
string
$scenario scenario name. See CModel::scenario for more details about this parameter. Note: in order to setup initial model parameters use CActiveRecord::init() or CModel::afterConstruct(). Do NOT override the constructor unless it is absolutely necessary!
$uid
$dbPersistentGridSettings
$disablePersistentGridSettings

Overrides

CActiveRecord::__construct()
public static static
# model( string $className = 'CActiveRecord' )

Returns the static model of the specified AR class. The model returned is a static instance of the AR class. It is provided for invoking class-level methods (something similar to static class methods.)

Returns the static model of the specified AR class. The model returned is a static instance of the AR class. It is provided for invoking class-level methods (something similar to static class methods.)

EVERY derived AR class must override this method as follows,

public static function model($className=__CLASS__)
{
    return parent::model($className);
}

Parameters

$className
string
$className active record class name.

Returns

static
active record model instance.

Overrides

CActiveRecord::model()
public static
# model2( mixed $className = 'CActiveRecord' )

Like X2Model::model() except without the exception thrown in case of bad model name

Like X2Model::model() except without the exception thrown in case of bad model name

public
# runWithoutBehavior( string $behaviorName, function $fn )

Runs specified function without the specified behavior

Runs specified function without the specified behavior

Parameters

$behaviorName
string
$behaviorName
$fn
function
$fn
public static string
# getRecordName( string $type, boolean $plural = false )

Returns name of records associated with model type or $type if none could be found

Returns name of records associated with model type or $type if none could be found

Parameters

$type
string
$type class name of subclass of X2Model
$plural
boolean
$plural if true, the record name will be pluralized

Returns

string
public static
# getAllRecordNames( )
public static string
# getAssociationType( mixed $modelName )

Get association type corresponding to model

Get association type corresponding to model

Returns

string
public static string
# getModelName( mixed $typeOrModuleName, mixed $strict = false )

Gets name of model corresponding to module or association type

Gets name of model corresponding to module or association type

Returns

string
public static array
# getModelsFromNames( array $modelNames )

Parameters

$modelNames
array
$modelNames names of models

Returns

array
models with given names
public static array
# getTableNames( array $models )

Parameters

$models
array
$models models

Returns

array
names of tables associated with given models
public static array
# getModelNames( null|CDbCriteria $criteria = null )

Retrieves a list of model names.

Retrieves a list of model names.

Obtains model names as an associative array with model names as the keys and human-readable model names as their values. This is used in place of getDisplayedModelNamesList() (formerly Admin::getModelList) where specifying values for modelName, because the value of that should ALWAYS be the name of the actual class, and X2Model::getModelName() is guaranteed to return a class name (or false, if the class does not exist).

Parameters

$criteria
null|CDbCriteria
$criteria if not null, will be used to query modules table. Specifying a CDbCriteria will bypass caching.

Returns

array
module titles indexed by associated model class names
public static true
# isModuleModelName( string $modelName )

Tests whether or not model name is the name of a visible, editable module's primary model

Tests whether or not model name is the name of a visible, editable module's primary model

Parameters

$modelName
string
$modelName

Returns

true
public static
# getModuleModelNames( )
public static
# getModules( )
public static
# getModuleModelsByName( )
public static array
# getAssociationTypeOptions( )

Returns the translated module titles indexed by association type

Returns the translated module titles indexed by association type

Returns

array
public
# getDisplayName( mixed $plural = true )
public static
# getModelTitle( mixed $modelClass, mixed $singular = false )

Returns the title of the model to display in the UI

Returns the title of the model to display in the UI

public static
# getTranslatedModelTitles( mixed $singular = false )
public static string
# getModuleName( string $modelName )

Returns module name for given model name, or $modelName if none could be found

Returns module name for given model name, or $modelName if none could be found

Parameters

$modelName
string
$modelName the name of a model

Returns

string
the name of the module associated with the model
public static string
# getModuleModelName( )

Returns model name of module associated with current controller Precondition: model is an instance of X2Model

Returns model name of module associated with current controller Precondition: model is an instance of X2Model

Returns

string
model name
public static object
# getModuleModel( )

Returns model of module associated with current controller Precondition: model is an instance of X2Model

Returns model of module associated with current controller Precondition: model is an instance of X2Model

Returns

object
model
public static
# updateTimerTotals( mixed $modelId, mixed $modelName = null )

Updates action timer sum fields in X2Model.

Updates action timer sum fields in X2Model.

public
# hide( )

Hides record from all but admin users who have "Show Hidden" turned on

Hides record from all but admin users who have "Show Hidden" turned on

public
# findByEmail( type $email )

Use all email addresses of the model for finding a record

Use all email addresses of the model for finding a record

Parameters

$email
type
$email
public type
# findByNameId( type $nameId )

Finds a model via a nameId reference

Finds a model via a nameId reference

Parameters

$nameId
type
$nameId

Returns

type
public static
# findByAttributes( array $attributes, mixed $condition = '', array $params = array() )

Finds a single active record that has the specified attribute values. See CActiveRecord::find() for detailed explanation about $condition and $params.

Finds a single active record that has the specified attribute values. See CActiveRecord::find() for detailed explanation about $condition and $params.

Parameters

$attributes
array
$attributes list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
$condition
mixed
$condition query condition or criteria.
$params
array
$params parameters to be bound to an SQL statement.

Returns

static
the record found. Null if none is found.

Overrides

CActiveRecord::findByAttributes()
public string
# getMyModelName( )

Magic getter for myModelName

Magic getter for myModelName

Returns

string
public
# resetFieldsPropertyCache( )
protected
# queryFields( )

Queries and caches Fields objects for the model.

Queries and caches Fields objects for the model.

This method obtains the fields defined for the model in x2_fields and makes them available for later usage to ensure that the query does not need to be performed again. The fields are stored as both static attributes of the model and and as Yii cache objects.

public array
# relations( )

This method should be overridden to declare related objects.

This method should be overridden to declare related objects.

There are four types of relations that may exist between two active record objects:
  • BELONGS_TO: e.g. a member belongs to a team;
  • HAS_ONE: e.g. a member has at most one profile;
  • HAS_MANY: e.g. a team has many members;
  • MANY_MANY: e.g. a member has many skills and a skill belongs to a member.

Besides the above relation types, a special relation called STAT is also supported that can be used to perform statistical query (or aggregational query). It retrieves the aggregational information about the related objects, such as the number of comments for each post, the average rating for each product, etc.

Each kind of related objects is defined in this method as an array with the following elements:

'varName'=>array('relationType', 'className', 'foreignKey', ...additional options)

where 'varName' refers to the name of the variable/property that the related object(s) can be accessed through; 'relationType' refers to the type of the relation, which can be one of the following four constants: self::BELONGS_TO, self::HAS_ONE, self::HAS_MANY and self::MANY_MANY; 'className' refers to the name of the active record class that the related object(s) is of; and 'foreignKey' states the foreign key that relates the two kinds of active record. Note, for composite foreign keys, they can be either listed together, separated by commas or specified as an array in format of array('key1','key2'). In case you need to specify custom PK->FK association you can define it as array('fk'=>'pk'). For composite keys it will be array('fk_c1'=>'pk_с1','fk_c2'=>'pk_c2'). For foreign keys used in MANY_MANY relation, the joining table must be declared as well (e.g. 'join_table(fk1, fk2)').

Additional options may be specified as name-value pairs in the rest array elements:
  • 'select': string|array, a list of columns to be selected. Defaults to '*', meaning all columns. Column names should be disambiguated if they appear in an expression (e.g. COUNT(relationName.name) AS name_count).
  • 'condition': string, the WHERE clause. Defaults to empty. Note, column references need to be disambiguated with prefix 'relationName.' (e.g. relationName.age>20)
  • 'order': string, the ORDER BY clause. Defaults to empty. Note, column references need to be disambiguated with prefix 'relationName.' (e.g. relationName.age DESC)
  • 'with': string|array, a list of child related objects that should be loaded together with this object. Note, this is only honored by lazy loading, not eager loading.
  • 'joinType': type of join. Defaults to 'LEFT OUTER JOIN'.
  • 'alias': the alias for the table associated with this relationship. It defaults to null, meaning the table alias is the same as the relation name.
  • 'params': the parameters to be bound to the generated SQL statement. This should be given as an array of name-value pairs.
  • 'on': the ON clause. The condition specified here will be appended to the joining condition using the AND operator.
  • 'index': the name of the column whose values should be used as keys of the array that stores related objects. This option is only available to HAS_MANY and MANY_MANY relations.
  • 'scopes': scopes to apply. In case of a single scope can be used like 'scopes'=>'scopeName', in case of multiple scopes can be used like 'scopes'=>array('scopeName1','scopeName2'). This option has been available since version 1.1.9.
The following options are available for certain relations when lazy loading:
  • 'group': string, the GROUP BY clause. Defaults to empty. Note, column references need to be disambiguated with prefix 'relationName.' (e.g. relationName.age). This option only applies to HAS_MANY and MANY_MANY relations.
  • 'having': string, the HAVING clause. Defaults to empty. Note, column references need to be disambiguated with prefix 'relationName.' (e.g. relationName.age). This option only applies to HAS_MANY and MANY_MANY relations.
  • 'limit': limit of the rows to be selected. This option does not apply to BELONGS_TO relation.
  • 'offset': offset of the rows to be selected. This option does not apply to BELONGS_TO relation.
  • 'through': name of the model's relation that will be used as a bridge when getting related data. Can be set only for HAS_ONE and HAS_MANY. This option has been available since version 1.1.7.

Below is an example declaring related objects for 'Post' active record class:

return array(
    'author'=>array(self::BELONGS_TO, 'User', 'author_id'),
    'comments'=>array(self::HAS_MANY, 'Comment', 'post_id', 'with'=>'author', 'order'=>'create_time DESC'),
    'tags'=>array(self::MANY_MANY, 'Tag', 'post_tag(post_id, tag_id)', 'order'=>'name'),
);

Returns

array
list of related object declarations. Defaults to empty array.

Overrides

CActiveRecord::relations()
public array
# behaviors( )

Returns a list of behaviors that this model should behave as.

Returns a list of behaviors that this model should behave as.

Returns

array
the behavior configurations (behavior name=>behavior configuration)

Overrides

CModel::behaviors()
public
# afterFind( )

Saves attributes on initial model lookup

Saves attributes on initial model lookup

Overrides

CActiveRecord::afterFind()
public boolean
# beforeSave( )

Remembers if this was a new record before saving.

Remembers if this was a new record before saving.

Returns

boolean
whether the saving should be executed. Defaults to true.

Returns

the answer from CActiveRecord::beforeSave()

Overrides

CActiveRecord::beforeSave()
public
# onAfterCreate( mixed $event )
public
# afterCreate( )
public
# onAfterInsert( mixed $event )
public
# onAfterUpdate( mixed $event )
public
# afterUpdate( )
public
# afterDelete( )

Runs when a model is deleted. Clears any entries in x2_phone_numbers. Fires onAfterDelete event.

Runs when a model is deleted. Clears any entries in x2_phone_numbers. Fires onAfterDelete event.

Overrides

CActiveRecord::afterDelete()
public boolean
# save( boolean $runValidation = true, array $attributes = null )

Modified to enable/disable X2Flow record update trigger. This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Modified to enable/disable X2Flow record update trigger. This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Parameters

$runValidation
boolean
$runValidation whether to perform validation before saving the record. If the validation fails, the record will not be saved to database.
$attributes
array
$attributes list of attributes that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved.

Returns

boolean
whether the saving succeeds

Overrides

CActiveRecord::save()
public
# afterSave( )

Runs when a model is saved. Scans attributes for phone numbers and index them in x2_phone_numbers. Updates x2_relationships table based on link type fields. Fires onAfterSave event.

Runs when a model is saved. Scans attributes for phone numbers and index them in x2_phone_numbers. Updates x2_relationships table based on link type fields. Fires onAfterSave event.

Overrides

CActiveRecord::afterSave()
public array
# rules( )

Generates validation rules for custom fields

Generates validation rules for custom fields

Returns

array
validation rules for model attributes.

Overrides

X2ActiveRecord::rules()
public static
# modelRules( mixed & $fields, mixed $model )
public mixed
# getAttribute( string $name, boolean $renderFlag = false, boolean $makeLinks = false )

Returns the named attribute value. Recognizes linked attributes and looks them up with X2Model::getLinkedAttribute()

Returns the named attribute value. Recognizes linked attributes and looks them up with X2Model::getLinkedAttribute()

Parameters

$name
string
$name the attribute name
$renderFlag
boolean
$renderFlag
$makeLinks
boolean
$makeLinks If the render flag is set, determines whether to render attributes as links

Returns

mixed
the attribute value. Null if the attribute is not set or does not exist.

See

CActiveRecord::hasAttribute()

Overrides

CActiveRecord::getAttribute()
public mixed
# getLinkedAttribute( string $linkField, string $attribute )

Looks up a linked attribute by loading the linked model and calling getAttribute() on it.

Looks up a linked attribute by loading the linked model and calling getAttribute() on it.

Parameters

$linkField
string
$linkField the attribute of $this linking to the external model
$attribute
string
$attribute the attribute of the external model

Returns

mixed
the attribute value. Null if the attribute is not set or does not exist.
public mixed
# renderLinkedAttribute( string $linkField, string $attribute )

Looks up a linked attribute by loading the linked model and calling renderAttribute() on it.

Looks up a linked attribute by loading the linked model and calling renderAttribute() on it.

Parameters

$linkField
string
$linkField the attribute of $this linking to the external model
$attribute
string
$attribute the attribute of the external model

Returns

mixed
the properly formatted attribute value. Null if the attribute is not set or does not exist.

See

X2Model::getLinkedAttribute()
public mixed
# getLinkedModel( string $linkField, boolean $lookup = true )

Looks up an external model referenced in a link field. Caches loaded models in X2Model::$_linkedModels

Looks up an external model referenced in a link field. Caches loaded models in X2Model::$_linkedModels

Parameters

$linkField
string
$linkField the attribute of $this linking to the external model
$lookup
boolean
$lookup Actually look up the model; otherwise (if false) use the name/ID to populate a dummy model that can be used for just generating a link.

Returns

mixed
the active record. Null if the attribute is not set or does not exist.
public static modelClass|string
# getLinkedModelMock( string $modelClass, string $name, integer $id, boolean $allowEmpty = false )

Creates a mock-up of a linked model with the minimum requirements for generating a link in a view of another model.

Creates a mock-up of a linked model with the minimum requirements for generating a link in a view of another model.

Parameters

$modelClass
string
$modelClass
$name
string
$name
$id
integer
$id
$allowEmpty
boolean
$allowEmpty Return the model even if $name/$id are empty.

Returns

modelClass|string
public static string
# getModelLink( integer $id, string $class, mixed $requireAbsoluteUrl = false )

Wrapper method for generating a link to the view for a model record.

Wrapper method for generating a link to the view for a model record.

Parameters

$id
integer
$id the route to this model's AutoComplete data source
$class
string
$class the model class
$requireAbsoluteUrl

Returns

string
a link to the model, or $id if the model is invalid
public array
# getStaticLinkedModels( )

Returns

array
static linked models indexed by link field name
public static type
# getModelLinkMock( type $modelClass, type $nameId, array $htmlOptions = array() )

Link generation shortcut.

Link generation shortcut.

Parameters

$modelClass
type
$modelClass
$nameId
type
$nameId
$htmlOptions
array
$htmlOptions options to be applied to the link element

Returns

type
public static array
# getModelTypes( boolean $assoc = false, mixed $filter = null )

Returns all possible models, either as a regular array or associative (key and value are the same)

Returns all possible models, either as a regular array or associative (key and value are the same)

Parameters

$assoc
boolean
$assoc
$filter

Returns

array
public static
# getModelTypesWhichSupportRelationships( mixed $assoc = false, mixed $refresh = false )
public static array
# getModelTypesWhichSupportWorkflow( boolean $assoc = false, mixed $associationTypes = false )

Like getModelTypes () except that only types of models which support workflow are returned

Like getModelTypes () except that only types of models which support workflow are returned

Parameters

$assoc
boolean
$assoc
$associationTypes

Returns

array
public type
# translatedAttributeLabel( type $label )

Returns a translated label using "module" defined in

Returns a translated label using "module" defined in

Parameters

$label
type
$label

Returns

type
public array
# getAttributeLabels( )

Returns custom attribute values defined in x2_fields

Returns custom attribute values defined in x2_fields

Returns

array
customized attribute labels (name=>label)

See

CModel::generateAttributeLabel()
public array
# attributeLabels( )

Returns custom attribute values defined in x2_fields

Returns custom attribute values defined in x2_fields

Returns

array
customized attribute labels (name=>label)

See

CModel::generateAttributeLabel()

Overrides

CModel::attributeLabels()
public string
# getAttributeLabel( string $attribute )

Returns the text label for the specified attribute. This method overrides the parent implementation by supporting returning the label defined in relational object. In particular, if the attribute name is in the form of "post.author.name", then this method will derive the label from the "author" relation's "name" attribute.

Returns the text label for the specified attribute. This method overrides the parent implementation by supporting returning the label defined in relational object. In particular, if the attribute name is in the form of "post.author.name", then this method will derive the label from the "author" relation's "name" attribute.

Parameters

$attribute
string
$attribute the attribute name

Returns

string
the attribute label

Since

1.1.4

See

CModel::generateAttributeLabel()

Overrides

CActiveRecord::getAttributeLabel()
public
# getOldAttributes( )
public
# getReadableAttributeNames( )

Returns all attributes of the current model that the user has permission to view.

Returns all attributes of the current model that the user has permission to view.

public
# getEditableAttributeNames( )
public array
# getVisibleAttributes( )

Filters attributes to those for which the current user has view permission

Filters attributes to those for which the current user has view permission

Returns

array
attribute values indexed by name
public array
# getFields( boolean $assoc = false, null|function $filterFn = null, integer $requiredPermission = Fields::NO_PERMISSION )

Parameters

$assoc
boolean
$assoc If true, fields in returned array will be indexed by field name
$filterFn
null|function
$filterFn
$requiredPermission
integer
$requiredPermission Used to filter fields by field-level permissions

Returns

array
public static array
# getFieldComparisonOptions( )

Returns

array
all standard comparison operators
public array
# getFieldsForDropdown( boolean $includeFieldsOfLinkedRecords = false, boolean $condList = true, function|null $filterFn = null, string $separator = '.' )

Parameters

$includeFieldsOfLinkedRecords
boolean
$includeFieldsOfLinkedRecords if true, add field options for related models
$condList
boolean
$condList
$filterFn
function|null
$filterFn if set, will be used to filter results
$separator
string
$separator used to separate parent attribute from field name

Returns

array
public null|Fields
# getField( mixed $fieldName )

Returns

null|Fields
Fields instance if found, null otherwise
public boolean
# getIsExemptFromFieldLevelPermissions( )

Whether to skip applying field level permissions

Whether to skip applying field level permissions

Returns false if the user has any roles and isn't administrator; returns true (meaning, no arbitrary restrictions on field access/editability)

Returns

boolean
public boolean
# insert( array $attributes = null )

Inserts a row into the table based on this active record attributes. If the table's primary key is auto-incremental and is null before insertion, it will be populated with the actual value after insertion. Note, validation is not performed in this method. You may call CModel::validate() to perform the validation. After the record is inserted to DB successfully, its isNewRecord property will be set false, and its scenario property will be set to be 'update'.

Inserts a row into the table based on this active record attributes. If the table's primary key is auto-incremental and is null before insertion, it will be populated with the actual value after insertion. Note, validation is not performed in this method. You may call CModel::validate() to perform the validation. After the record is inserted to DB successfully, its isNewRecord property will be set false, and its scenario property will be set to be 'update'.

Parameters

$attributes
array
$attributes list of attributes that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved.

Returns

boolean
whether the attributes are valid and the record is inserted successfully.

Throws

CDbException
if the record is not new

Overrides

CActiveRecord::insert()
public static
# getPhoneNumber( string $field, string $class, integer $id, boolean $encode = false, boolean $makeLink = false, string $default = null )

Parameters

$field
string
$field the name of the field
$class
string
$class the name of the class with which the field is associated
$id
integer
$id
$encode
boolean
$encode Whether to html encode the number
$makeLink
boolean
$makeLink Whether return a phone link
$default
string
$default What to use in case phone number lookup failed; circumvents the need to re-query the model if used.
public static
# renderModelInput( CModel $model, mixed $field, mixed $htmlOptions = array() )
public static
# renderMergeInput( mixed $modelType, mixed $idArray, mixed $field )
public string
# renderInput( string $fieldName, array $htmlOptions = array() )

Renders an attribute of the model based on its field type

Renders an attribute of the model based on its field type

Parameters

$fieldName
string
$fieldName the name of the attribute to be rendered
$htmlOptions
array
$htmlOptions htmlOptions to be used on the input

Returns

string
the HTML or text for the formatted attribute
public
# renderErroneousField( )

Renders an error when a field cannot be found

Renders an error when a field cannot be found

public
# setX2Fields( array & $data, boolean $filter = false, boolean $bypassPermissions = false )

Sets attributes using X2Fields

Sets attributes using X2Fields

Parameters

$data
array
&$data array of attributes to be set (eg. $_POST['Contacts'])
$filter
boolean
$filter encode all HTML special characters in input
$bypassPermissions
boolean
$bypassPermissions (optional)
public CActiveDataProvider
# searchBase( CDbCriteria $criteria, integer $pageSize = null, mixed $showHidden = false )

Base search function, includes Retrieves a list of models based on the current
search/filter conditions.

Base search function, includes Retrieves a list of models based on the current search/filter conditions.

Parameters

$criteria
CDbCriteria
$criteria the attribute name
$pageSize
integer
$pageSize If set, will override property of profile model
$showHidden

Returns

CActiveDataProvider
the data provider that can return the models based on the search/filter conditions.
public
# getSort( )
public array
# unshiftOperator( mixed $string )

Unshifts valid operators of the front of the string.

Unshifts valid operators of the front of the string.

Returns

array
(<operator>, <remaining string>)
protected
# compareAttribute( mixed & $criteria, mixed $field )

Helper method for compareAttributes

Helper method for compareAttributes

public
# compareAttributes( mixed & $criteria )
protected
# compareBoolean( mixed $data )
public
# compareAssignment( mixed $data )
protected
# compareDropdown( mixed $ddId, mixed $value )
public static CActiveRecord
# getAssociationModel( String $type, Integer $id )

Returns a model of the appropriate type with a particular record loaded.

Returns a model of the appropriate type with a particular record loaded.

Parameters

$type
String
$type The type of the model to load
$id
Integer
$id The id of the record to load

Returns

CActiveRecord
A database record with the requested type and id
public type
# findByPkInArray( array $params )

Picks the primary key attribute out of an associative aray and finds the record

Picks the primary key attribute out of an associative aray and finds the record

Parameters

$params
array
$params

Returns

type
public
# updateNameId( boolean $save = false )

Sets the nameId field appropriately.

Sets the nameId field appropriately.

The model must be inserted already, so that its primary key can be used.

Parameters

$save
boolean
$save If true, update the model when done.
public static
# massUpdateNameId( string $modelName, mixed $ids = array() )

Populates the nameId field in multiple records (or all) with one query.

Populates the nameId field in multiple records (or all) with one query.

Note, if the method Fields::nameId() is ever dramatically changed, this method too will need to be changed accordingly. The unit test, {X2ModelTest::testMassUpdateNameId()}, is designed to fail when this happens in order to draw attention to it.

Parameters

$modelName
string
$modelName
$ids
mixed
$ids
public
# updateNameIdRefs( )

Updates references to this model record in other tables.

Updates references to this model record in other tables.

This is a temporary solution to be used until a future version, wherein all tables have been migrated to InnoDB and foreign key constraints can be used to maintain referential integrity. However, this function should still be kept in place for handling the special case of deletion, which cannot be adequately handled by foreign key constraints.

It may be a while before we can safely migrate everything to InnoDB, because one or more of our big-ticket customers have FULLTEXT indexes on their contacts table to make searching faster, and FULLTEXT indexes are not supported in InnoDB.

public boolean
# attributeChanged( mixed $attr )

Returns

boolean
true if attribute changed after being saved, false otherwise
public static
# getDefaultAssignment( )

Helper method for renderModelInput () and setX2Fields () used to retrieve the application default for the assignment field. This gets superceded by user define default values.

Helper method for renderModelInput () and setX2Fields () used to retrieve the application default for the assignment field. This gets superceded by user define default values.

public static type
# getAssignmentOptions( type $anyone = true, type $showGroups = true, type $showSeparator = true )

Returns assignment selection options

Returns assignment selection options

Parameters

$anyone
type
$anyone
$showGroups
type
$showGroups
$showSeparator
type
$showSeparator

Returns

type
public mixed
# getEditableFieldNames( boolean $suppressAttributeLabels = true )

Returns an array of field names that the user has permission to edit

Returns an array of field names that the user has permission to edit

Parameters

$suppressAttributeLabels
boolean
if false, get attribute labels as well as field names

Returns

mixed
if $suppressAttributeLabels is true, an array of field names is returned, otherwise an associative array is returned (fieldName => attributeLabel)
public type
# getFieldPermissions( )

Getter for fieldPermissions

Getter for fieldPermissions

Returns

type
public static json
# getDefaultFormLayout( string $modelName )

Build a json-encoded form layout for models whose Forms are not editable or for custom modules that do not yet have a user-created form.

Build a json-encoded form layout for models whose Forms are not editable or for custom modules that do not yet have a user-created form.

Parameters

$modelName
string
$modelname The model for which to build a default layout.

Returns

json
The default layout for the selected model.
public static
# checkThrowAttrError( array|string $attribute )

Should be used before inserting user-generated input into SQL string in cases where parameter binding cannot be used (e.g. for SQL object names).

Should be used before inserting user-generated input into SQL string in cases where parameter binding cannot be used (e.g. for SQL object names).

Parameters

$attribute
array|string
$attribute Name of attribute(s)

Throws

CException
If attribute does not exist
public static mixed
# getModelOfTypeWithId( boolean $type, mixed $id, mixed $isAssocType = false )

Retrieves model of a specified type with a specified id

Retrieves model of a specified type with a specified id

Parameters

$type
boolean
$isAssocType If true, $type will be treated as an association type. Otherwise, $type will be treated as a model class name.
$id
$isAssocType

Returns

mixed
object or null
public static
# getModelOfTypeWithName( mixed $type, mixed $name )
public static
# renderModelAutocomplete( string $modelClass, boolean $ajax = false, mixed $htmlOptions = array(), mixed $value = null )

Parameters

$modelClass
string
$modelClass the model class for which the autocomplete should be rendered
$ajax
boolean
$ajax if true, registered scripts are processed with ajaxRender
$htmlOptions
$value
public
# getInsertableAttributeTokens( )
public CActiveRecord[]
# findAll( mixed $condition = '', array $params = array()/* x2modstart */, boolean $getCommand = false/* x2modend */ )

Finds all active records satisfying the specified condition. See CActiveRecord::find() for detailed explanation about $condition and $params.

Finds all active records satisfying the specified condition. See CActiveRecord::find() for detailed explanation about $condition and $params.

Parameters

$condition
mixed
$condition query condition or criteria.
$params
array
$params parameters to be bound to an SQL statement.
$getCommand
boolean
$getCommand If true, command is returned instead of populating records

Returns

CActiveRecord[]
list of active records satisfying the specified condition. An empty array is returned if none is found. This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Overrides

CActiveRecord::findAll()
public
# duplicateFields( )
protected mixed
# query( CDbCriteria $criteria, boolean $all = false/* x2modstart */, boolean $getCommand = false/* x2modend */ )

Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.

Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.

Parameters

$criteria
CDbCriteria
$criteria the query criteria
$all
boolean
$all whether to return all data
$getCommand
boolean
$getCommand If true, command is returned instead of populating records

Returns

mixed
the AR objects populated with the query result

Since

1.1.7 This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Overrides

CActiveRecord::query()
public
# getSummaryFields( )
Methods inherited from X2ActiveRecord
getAllErrorMessages(), getBehaviorRules(), getFormatter(), getInputRenderer(), getName(), renderAttribute(), setFormatter(), setInputRenderer()
Methods inherited from CActiveRecord
__call(), __get(), __isset(), __set(), __sleep(), __unset(), addRelatedRecord(), afterFindInternal(), applyScopes(), attributeNames(), beforeCount(), beforeDelete(), beforeFind(), beforeFindInternal(), cache(), count(), countByAttributes(), countBySql(), defaultScope(), delete(), deleteAll(), deleteAllByAttributes(), deleteByPk(), equals(), exists(), find(), findAllByAttributes(), findAllByPk(), findAllBySql(), findByPk(), findBySql(), getActiveFinder(), getActiveRelation(), getAttributes(), getCommandBuilder(), getDbConnection(), getDbCriteria(), getIsNewRecord(), getMetaData(), getOldPrimaryKey(), getPrimaryKey(), getRelated(), getTableAlias(), getTableSchema(), hasAttribute(), hasRelated(), init(), instantiate(), offsetExists(), onAfterDelete(), onAfterFind(), onAfterSave(), onBeforeCount(), onBeforeDelete(), onBeforeFind(), onBeforeSave(), populateRecord(), populateRecords(), primaryKey(), refresh(), refreshMetaData(), resetScope(), saveAttributes(), saveCounters(), scopes(), setAttribute(), setDbCriteria(), setIsNewRecord(), setOldPrimaryKey(), setPrimaryKey(), setTableAlias(), tableName(), together(), update(), updateAll(), updateByPk(), updateCounters(), with()
Methods inherited from CModel
addError(), addErrors(), afterConstruct(), afterValidate(), beforeValidate(), clearErrors(), createValidators(), generateAttributeLabel(), getError(), getErrors(), getIterator(), getSafeAttributeNames(), getScenario(), getValidatorList(), getValidators(), hasErrors(), isAttributeRequired(), isAttributeSafe(), offsetGet(), offsetSet(), offsetUnset(), onAfterConstruct(), onAfterValidate(), onBeforeValidate(), onUnsafeAttribute(), setAttributes(), setScenario(), unsetAttributes(), validate()
Methods inherited from CComponent
asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants inherited from CActiveRecord
BELONGS_TO, HAS_MANY, HAS_ONE, MANY_MANY, STAT
Properties summary
public boolean $supportsFieldLevelPermissions true
#
public true $supportsWorkflow true
#

if this model can have workflows associated with it, false otherwise

if this model can have workflows associated with it, false otherwise

public (optional) $uid null
#

string Used in the search scenario to uniquely identify this model. Allows
filters to be saved separately for each grid view.

string Used in the search scenario to uniquely identify this model. Allows filters to be saved separately for each grid view.

public boolean $dbPersistentGridSettings false
#

If true, grid views displaying models of this type will have their filter and
sort settings saved in the database instead of in the session

If true, grid views displaying models of this type will have their filter and sort settings saved in the database instead of in the session

public boolean $disablePersistentGridSettings false
#

$disablePersistentGridSettings If true, grid settings will not be saved to or
retrieved from the session/db

$disablePersistentGridSettings If true, grid settings will not be saved to or retrieved from the session/db

public string $subScenario ''
#

Temporary hack to allow importer to skip certain validation rules. This is used in place of scenario because the scenario property isn't used correctly in many places throughout the codebase. Scenario is meant to be used to filter validation rules (http://www.yiiframework.com/doc/api/1.1/CModel#scenario-detail), and not otherwise. So, for now, changing the scenario can mean introducing unintended side-effects not related to validation. Eventually, all non-validation uses of scenario should be refactored.

Temporary hack to allow importer to skip certain validation rules. This is used in place of scenario because the scenario property isn't used correctly in many places throughout the codebase. Scenario is meant to be used to filter validation rules (http://www.yiiframework.com/doc/api/1.1/CModel#scenario-detail), and not otherwise. So, for now, changing the scenario can mean introducing unintended side-effects not related to validation. Eventually, all non-validation uses of scenario should be refactored.

protected array $_oldAttributes array()
#
public static type $autoPopulateFields true
#

A flag for disabling the automatic setting of fields in events like find, update, validate (etc) to reduce overhead during queries.

A flag for disabling the automatic setting of fields in events like find, update, validate (etc) to reduce overhead during queries.

public static array $associationModels array( 'bugreports' => 'BugReports', 'media' => 'Media', 'actions' => 'Actions', 'calendar' => 'X2Calendar', 'contacts' => 'Contacts', 'accounts' => 'Accounts', 'product' => 'Product', 'products' => 'Product', 'Campaign' => 'Campaign', 'x2Leads' => 'X2Leads', 'marketing' => 'Campaign', 'quote' => 'Quote', 'quotes' => 'Quote', 'opportunities' => 'Opportunity', 'social' => 'Social', 'services' => 'Services', 'users' => 'User', '' => '' )
#

List of mapping between module names/associationType values and model class names

List of mapping between module names/associationType values and model class names

public static array $modelNameToModuleName array( 'Accounts' => 'Accounts', 'Actions' => 'Actions', 'BugReports' => 'BugReports', 'Campaign' => 'Marketing', 'Contacts' => 'Contacts', 'X2List' => 'Contacts', 'Groups' => 'Groups', 'Product' => 'Products', 'Media' => 'Media', 'Opportunity' => 'Opportunities', 'Quote' => 'Quotes', 'Services' => 'Services', 'User' => 'Users', 'WebForm' => 'Marketing', 'Workflow' => 'Workflow', 'X2Calendar' => 'Calendar', 'X2Leads' => 'X2Leads', )
#

1-1 mapping between model names and the names of the modules they belong to

1-1 mapping between model names and the names of the modules they belong to

public static array $translatedModelTitles array()
#
protected static array $_editableFieldNames array()
#
protected static type $_fields
#

Stores one copy of fields for all instances of this model

Stores one copy of fields for all instances of this model

protected static type $_fieldPermissions array()
#

Stores, for the current user, the permissions of the fields (1 for read, 2 for read/write, 0 for no access)

Stores, for the current user, the permissions of the fields (1 for read, 2 for read/write, 0 for no access)

protected static type $_nameIdRefs
#

Stores possible references to models via lookup fields. The structure of this array is:

Stores possible references to models via lookup fields. The structure of this array is:

1st level (array): [model class key] => [array value]

2nd level (array): [table name key] => [array value]

So for each model name, there is an array of corresponding tables (and for each table, a list of columns) that need to be updated if the nameId attribute changes.

protected static mixed $_linkedModels
#
protected mixed $_runAfterCreate
#
protected string $fieldFormatterClass 'FieldFormatter'
#
Properties inherited from X2ActiveRecord
$fieldInputRendererClass
Properties inherited from CActiveRecord
$db
Magic properties summary
public array $fieldPermissions
#

Associative array of field names to permissions: 0 for no access, 1 for read access, and 2 for read/write

Associative array of field names to permissions: 0 for no access, 1 for read access, and 2 for read/write

public string $myModelName
#

(read-only) Model name of the instance.

(read-only) Model name of the instance.

public array $relatedX2Models
#

(read-only) Models associated via the associations table

(read-only) Models associated via the associations table

public array $readableAttributeNames
#

(read-only) Names of attributes that can be accessed, per the field-level security settings, by the current user.

(read-only) Names of attributes that can be accessed, per the field-level security settings, by the current user.

public boolean $isExemptFromFieldLevelPermissions
#

True if the user is admin or has no roles (in which case field-level permissions do not apply)

True if the user is admin or has no roles (in which case field-level permissions do not apply)

Magic properties inherited from CActiveRecord
$attributes, $commandBuilder, $dbConnection, $dbCriteria, $isNewRecord, $metaData, $oldPrimaryKey, $primaryKey, $tableAlias, $tableSchema
Magic properties inherited from CModel
$errors, $iterator, $safeAttributeNames, $scenario, $validatorList, $validators
X2CRM Documentation API documentation generated by ApiGen 2.8.0