Class X2Model
General model class that uses dynamic fields
- CComponent
- CModel implements IteratorAggregate, ArrayAccess
- CActiveRecord
- X2ActiveRecord
- X2Model
Direct known subclasses
Accounts, Actions, ProductFeature, Quote, Services, Templates, Topics, X2Leads, X2List, BugReports, Campaign, Contacts, Docs, Groups, Media, Opportunity, ProductIndirect known subclasses
ContactList
public
|
#
__construct( string $scenario = 'insert', mixed $uid = null, mixed $dbPersistentGridSettings = false, mixed $disablePersistentGridSettings = false )
Initialize the model. |
public static
static
|
|
public static
|
#
model2( mixed $className = 'CActiveRecord' )
Like |
public
|
#
runWithoutBehavior( string $behaviorName, function $fn )
Runs specified function without the specified behavior |
public static
string
|
#
getRecordName( string $type, boolean $plural = false )
Returns name of records associated with model type or $type if none could be found |
public static
|
|
public static
string
|
|
public static
string
|
#
getModelName( mixed $typeOrModuleName, mixed $strict = false )
Gets name of model corresponding to module or association type |
public static
array
|
|
public static
array
|
|
public static
array
|
|
public static
true
|
#
isModuleModelName( string $modelName )
Tests whether or not model name is the name of a visible, editable module's primary model |
public static
|
|
public static
|
|
public static
|
|
public static
array
|
|
public
|
|
public static
|
#
getModelTitle( mixed $modelClass, mixed $singular = false )
Returns the title of the model to display in the UI |
public static
|
|
public static
string
|
#
getModuleName( string $modelName )
Returns module name for given model name, or $modelName if none could be found |
public static
string
|
#
getModuleModelName( )
Returns model name of module associated with current controller Precondition: model is an instance of X2Model |
public static
object
|
#
getModuleModel( )
Returns model of module associated with current controller Precondition: model is an instance of X2Model |
public static
|
#
updateTimerTotals( mixed $modelId, mixed $modelName = null )
Updates action timer sum fields in X2Model. |
public
|
|
public
|
|
public
type
|
|
public
static
|
#
findByAttributes( array $attributes, mixed $condition = '', array $params = array() )
Finds a single active record that has the specified attribute values. See
|
public
string
|
|
public
|
|
protected
|
|
public
array
|
|
public
array
|
|
public
|
|
public
boolean
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
afterDelete( )
Runs when a model is deleted. Clears any entries in x2_phone_numbers. Fires onAfterDelete event. |
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/ |
public
|
|
public
array
|
|
public static
|
|
public
mixed
|
#
getAttribute( string $name, boolean $renderFlag = false, boolean $makeLinks = false )
Returns the named attribute value. Recognizes linked attributes and looks
them up with |
public
mixed
|
#
getLinkedAttribute( string $linkField, string $attribute )
Looks up a linked attribute by loading the linked model and calling getAttribute() on it. |
public
mixed
|
#
renderLinkedAttribute( string $linkField, string $attribute )
Looks up a linked attribute by loading the linked model and calling renderAttribute() on it. |
public
mixed
|
#
getLinkedModel( string $linkField, boolean $lookup = true )
Looks up an external model referenced in a link field. Caches loaded models in X2Model::$_linkedModels |
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. |
public static
string
|
#
getModelLink( integer $id, string $class, mixed $requireAbsoluteUrl = false )
Wrapper method for generating a link to the view for a model record. |
public
array
|
|
public static
type
|
#
getModelLinkMock( type $modelClass, type $nameId, array $htmlOptions = array() )
Link generation shortcut. |
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) |
public static
|
|
public static
array
|
#
getModelTypesWhichSupportWorkflow( boolean $assoc = false, mixed $associationTypes = false )
Like getModelTypes () except that only types of models which support workflow are returned |
public
type
|
|
public
array
|
|
public
array
|
|
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. |
public
|
|
public
|
#
getReadableAttributeNames( )
Returns all attributes of the current model that the user has permission to view. |
public
|
|
public
array
|
#
getVisibleAttributes( )
Filters attributes to those for which the current user has view permission |
public
array
|
#
getFields( boolean $assoc = false, null|function $filterFn = null, integer $requiredPermission =
|
public static
array
|
|
public
array
|
#
getFieldsForDropdown( boolean $includeFieldsOfLinkedRecords = false, boolean $condList = true, function|null $filterFn = null, string $separator = '.' )
|
public
null|
|
|
public
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 |
public static
|
#
getPhoneNumber( string $field, string $class, integer $id, boolean $encode = false, boolean $makeLink = false, string $default = null )
|
public static
|
|
public static
|
|
public
string
|
#
renderInput( string $fieldName, array $htmlOptions = array() )
Renders an attribute of the model based on its field type |
public
|
|
public
|
#
setX2Fields( array & $data, boolean $filter = false, boolean $bypassPermissions = false )
Sets attributes using X2Fields |
public
CActiveDataProvider
|
#
searchBase( CDbCriteria $criteria, integer $pageSize = null, mixed $showHidden = false )
Base search function, includes Retrieves a list of models based on the
current |
public
|
|
public
array
|
|
protected
|
|
public
|
|
protected
|
|
public
|
|
protected
|
|
public static
CActiveRecord
|
#
getAssociationModel( String $type, Integer $id )
Returns a model of the appropriate type with a particular record loaded. |
public
type
|
#
findByPkInArray( array $params )
Picks the primary key attribute out of an associative aray and finds the record |
public
|
|
public static
|
#
massUpdateNameId( string $modelName, mixed $ids = array() )
Populates the nameId field in multiple records (or all) with one query. |
public
|
|
public
boolean
|
|
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. |
public static
type
|
#
getAssignmentOptions( type $anyone = true, type $showGroups = true, type $showSeparator = true )
Returns assignment selection options |
public
mixed
|
#
getEditableFieldNames( boolean $suppressAttributeLabels = true )
Returns an array of field names that the user has permission to edit |
public
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. |
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). |
public static
mixed
|
#
getModelOfTypeWithId( boolean $type, mixed $id, mixed $isAssocType = false )
Retrieves model of a specified type with a specified id |
public static
|
|
public static
|
#
renderModelAutocomplete( string $modelClass, boolean $ajax = false, mixed $htmlOptions = array(), mixed $value = null )
|
public
|
|
public
CActiveRecord[]
|
#
findAll( mixed $condition = '', array $params = array()/* x2modstart */, boolean $getCommand = false/* x2modend */ )
Finds all active records satisfying the specified condition. See |
public
|
|
protected
mixed
|
|
public
|
getAllErrorMessages(),
getBehaviorRules(),
getFormatter(),
getInputRenderer(),
getName(),
renderAttribute(),
setFormatter(),
setInputRenderer()
|
__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()
|
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()
|
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
BELONGS_TO,
HAS_MANY,
HAS_ONE,
MANY_MANY,
STAT
|
public
boolean
|
$supportsFieldLevelPermissions | true |
|
public
true
|
$supportsWorkflow | true |
#
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 |
public
boolean
|
$dbPersistentGridSettings | false |
#
If true, grid views displaying models of this type will have their filter
and |
public
boolean
|
$disablePersistentGridSettings | false |
#
$disablePersistentGridSettings If true, grid settings will not be saved to
or |
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. |
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. |
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 |
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 |
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 |
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) |
protected static
type
|
$_nameIdRefs |
|
#
Stores possible references to models via lookup fields. The structure of this array is: |
protected static
mixed
|
$_linkedModels |
|
|
protected
mixed
|
$_runAfterCreate |
|
|
protected
string
|
$fieldFormatterClass | 'FieldFormatter' |
$fieldInputRendererClass
|
$db
|
public
array
|
$fieldPermissions |
#
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. |
public
array
|
$relatedX2Models |
#
(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. |
public
boolean
|
$isExemptFromFieldLevelPermissions |
#
True if the user is admin or has no roles (in which case field-level permissions do not apply) |
$attributes,
$commandBuilder,
$dbConnection,
$dbCriteria,
$isNewRecord,
$metaData,
$oldPrimaryKey,
$primaryKey,
$tableAlias,
$tableSchema
|
$errors,
$iterator,
$safeAttributeNames,
$scenario,
$validatorList,
$validators
|