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 Credentials

Model implementing encrypted, generic credentials storage.

CComponent
Extended by CModel implements IteratorAggregate, ArrayAccess
Extended by CActiveRecord
Extended by Credentials
Package: application\models
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/models/Credentials.php
Methods summary
public
# afterDelete( )

This method is invoked after deleting a record. The default implementation raises the CActiveRecord::onAfterDelete() event. You may override this method to do postprocessing after the record is deleted. Make sure you call the parent implementation so that the event is raised properly.

This method is invoked after deleting a record. The default implementation raises the CActiveRecord::onAfterDelete() event. You may override this method to do postprocessing after the record is deleted. Make sure you call the parent implementation so that the event is raised properly.

Overrides

CActiveRecord::afterDelete()
public array
# attributeLabels( )

Returns the attribute labels. Attribute labels are mainly used in error messages of validation. By default an attribute label is generated using CModel::generateAttributeLabel(). This method allows you to explicitly specify attribute labels.

Returns the attribute labels. Attribute labels are mainly used in error messages of validation. By default an attribute label is generated using CModel::generateAttributeLabel(). This method allows you to explicitly specify attribute labels.

Note, in order to inherit labels defined in the parent class, a child class needs to merge the parent labels with child labels using functions like array_merge().

Returns

array
attribute labels (name=>label)

See

CModel::generateAttributeLabel()

Overrides

CModel::attributeLabels()
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. The return value should be an array of behavior configurations indexed by behavior names. Each behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName'=>array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Returns a list of behaviors that this model should behave as. The return value should be an array of behavior configurations indexed by behavior names. Each behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName'=>array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Note, the behavior classes must implement IBehavior or extend from CBehavior. Behaviors declared in this method will be attached to the model when it is instantiated.

For more details about behaviors, see CComponent.

Returns

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

Overrides

CModel::behaviors()
public
# afterSave( )

This method is invoked after saving a record successfully. The default implementation raises the CActiveRecord::onAfterSave() event. You may override this method to do postprocessing after record saving. Make sure you call the parent implementation so that the event is raised properly.

This method is invoked after saving a record successfully. The default implementation raises the CActiveRecord::onAfterSave() event. You may override this method to do postprocessing after record saving. Make sure you call the parent implementation so that the event is raised properly.

Overrides

CActiveRecord::afterSave()
public boolean
# beforeDelete( )

This method is invoked before deleting a record. The default implementation raises the CActiveRecord::onBeforeDelete() event. You may override this method to do any preparation work for record deletion. Make sure you call the parent implementation so that the event is raised properly.

This method is invoked before deleting a record. The default implementation raises the CActiveRecord::onBeforeDelete() event. You may override this method to do any preparation work for record deletion. Make sure you call the parent implementation so that the event is raised properly.

Returns

boolean
whether the record should be deleted. Defaults to true.

Overrides

CActiveRecord::beforeDelete()
public
# defaultHooks( type $userId, mixed $serviceType )

Actions to take during setting of a default, especially when the default is system-wide.

Actions to take during setting of a default, especially when the default is system-wide.

Parameters

$userId
type
$event
$serviceType
public
# findDefault( type $userId, type $serviceType )

Returns the model with default credentials for a given type.

Returns the model with default credentials for a given type.

Parameters

$userId
type
$userId The ID of the user whose credentials are being looked up
$serviceType
type
$type The type of service for which credentials are being looked up
public type
# getAuthModels( )

An array of credential storage model objects, for reference

An array of credential storage model objects, for reference

Returns

type
public type
# getAuthModelLabels( )

Getter for authModelLabels

Getter for authModelLabels

Returns

type
public type
# getDefaultCredentials( type $refresh = false )

Getter for defaultCredentials

Getter for defaultCredentials

Parameters

$refresh
type
$d

Returns

type
public
# getDefaultSubstitutes( )

Returns the value for defaultSubstitutes

Returns the value for defaultSubstitutes

public
# getDefaultSubstitutesInv( )

Returns the value for defaultSubstitutesInv

Returns the value for defaultSubstitutesInv

public
# getDefaultUserAccount( mixed $userId = null, mixed $type = 'email' )

Gets the default service record ID for the user of a given type.

Gets the default service record ID for the user of a given type.

public
# getIsInUseBySystem( )

Getter for sysDefaultCredentials

Getter for sysDefaultCredentials

public
# getAuthModel( )
public type
# getPageTitle( )

Returns an appropriate title for create/update pages.

Returns an appropriate title for create/update pages.

Returns

type
public type
# getServiceLabel( )

Obtains the service type label (UI-friendly name for the category of credentials)

Obtains the service type label (UI-friendly name for the category of credentials)

Returns

type
public array
# getServiceLabels( )

Gets translated labels for each service type (serviceLabels)

Gets translated labels for each service type (serviceLabels)

Returns

array
public array
# getSubstituteLabels( )

Gets a UI-friendly list of substitute classes to names for the current embedded model (i.e. for a selector of services for which the current credentials should be used as default)

Gets a UI-friendly list of substitute classes to names for the current embedded model (i.e. for a selector of services for which the current credentials should be used as default)

Returns

array
public type
# getSysUseLabel( )

Returns a list of labels for designated systemwide-use types.

Returns a list of labels for designated systemwide-use types.

Returns

type
public static array
# getCredentialOptions( CModel $model, string $name, string $type = 'email', integer $uid = null, array $htmlOptions = array(), boolean $excludeLegacy = false, mixed $imapOnly = false )

Parameters

$model
CModel
$model Model whose attribute is being used to specify a set of credentials
$name
string
$name Attribute storing the ID of the credentials record
$type
string
$type Keyword specifying the "service type" (i.e. "email" encompasess credentials with modelClass "EmailAccount" and "GMailAccount"
$uid
integer
$uid The user ID or system role ID for which the input is being generated
$htmlOptions
array
$htmlOptions HTML options to pass to CHtml::activeDropDownList()
$excludeLegacy
boolean
$getNameEmailsArr if true, returned array will include array indexed by credId which contains associated email and name
$imapOnly

Returns

array
containing values which can be used to instantiate an activeDropDownList. This inludes an array of credential names as well an array of the options' selected attributes.
public static string
# selectorField( CModel $model, string $name, string $type = 'email', integer $uid = null, array $htmlOptions = array(), array $excludeLegacy = false, array $imapOnly = false )

Generates a select input for a form that includes a list of credentials available for the current user.

Generates a select input for a form that includes a list of credentials available for the current user.

Parameters

$model
CModel
$model Model whose attribute is being used to specify a set of credentials
$name
string
$name Attribute storing the ID of the credentials record
$type
string
$type Keyword specifying the "service type" (i.e. "email" encompasess credentials with modelClass "EmailAccount" and "GMailAccount"
$uid
integer
$uid The user ID or system role ID for which the input is being generated
$htmlOptions
array
$htmlOptions HTML options to pass to CHtml::activeDropDownList()
$excludeLegacy
array
$excludeLegacy Exclude the sendmail legacy option
$imapOnly
array
$imapOnly Hide models which do not support IMAP

Returns

string
public array
# isDefaultOf( integer $uid )

Given a user id, returns an array of all service types for which the current record is default.

Given a user id, returns an array of all service types for which the current record is default.

Parameters

$uid
integer
$uid

Returns

array
public
# makeDefault( type $userId, type $serviceType, mixed $hooks = true )

Set the default account for a given user to use for a given service.

Set the default account for a given user to use for a given service.

Parameters

$userId
type
$userId ID of the user whose default is getting set. Null for generic/system account.
$serviceType
type
$serviceType Service type, i.e. 'email'
$hooks
public static static
# model( string $className = __CLASS__ )

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 array
# rules( )

Returns the validation rules for attributes.

Returns the validation rules for attributes.

This method should be overridden to declare validation rules. Each rule is an array with the following structure:

array('attribute list', 'validator name', 'on'=>'scenario name', ...validation parameters...)
where
  • attribute list: specifies the attributes (separated by commas) to be validated;
  • validator name: specifies the validator to be used. It can be the name of a model class method, the name of a built-in validator, or a validator class (or its path alias). A validation method must have the following signature:
    // $params refers to validation parameters given in the rule
    function validatorName($attribute,$params)
    
    A built-in validator refers to one of the validators declared in CValidator::builtInValidators. And a validator class is a class extending CValidator.
  • on: this specifies the scenarios when the validation rule should be performed. Separate different scenarios with commas. If this option is not set, the rule will be applied in any scenario that is not listed in "except". Please see scenario for more details about this option.
  • except: this specifies the scenarios when the validation rule should not be performed. Separate different scenarios with commas. Please see scenario for more details about this option.
  • additional parameters are used to initialize the corresponding validator properties. Please refer to individual validator class API for possible properties.

The following are some examples:

array(
    array('username', 'required'),
    array('username', 'length', 'min'=>3, 'max'=>12),
    array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'),
    array('password', 'authenticate', 'on'=>'login'),
);

Note, in order to inherit rules defined in the parent class, a child class needs to merge the parent rules with child rules using functions like array_merge().

Returns

array
validation rules to be applied when CModel::validate() is called.

See

scenario

Overrides

CModel::rules()
public string
# tableName( )

Returns the name of the associated database table. By default this method returns the class name as the table name. You may override this method if the table is not named after this convention.

Returns the name of the associated database table. By default this method returns the class name as the table name. You may override this method if the table is not named after this convention.

Returns

string
the table name

Overrides

CActiveRecord::tableName()
Methods inherited from CActiveRecord
__call(), __construct(), __get(), __isset(), __set(), __sleep(), __unset(), addRelatedRecord(), afterFind(), afterFindInternal(), applyScopes(), attributeNames(), beforeCount(), beforeFind(), beforeFindInternal(), beforeSave(), cache(), count(), countByAttributes(), countBySql(), defaultScope(), delete(), deleteAll(), deleteAllByAttributes(), deleteByPk(), equals(), exists(), find(), findAll(), findAllByAttributes(), findAllByPk(), findAllBySql(), findByAttributes(), findByPk(), findBySql(), getActiveFinder(), getActiveRelation(), getAttribute(), getAttributeLabel(), getAttributes(), getCommandBuilder(), getDbConnection(), getDbCriteria(), getIsNewRecord(), getMetaData(), getOldPrimaryKey(), getPrimaryKey(), getRelated(), getTableAlias(), getTableSchema(), hasAttribute(), hasRelated(), init(), insert(), instantiate(), offsetExists(), onAfterDelete(), onAfterFind(), onAfterSave(), onBeforeCount(), onBeforeDelete(), onBeforeFind(), onBeforeSave(), populateRecord(), populateRecords(), primaryKey(), query(), refresh(), refreshMetaData(), resetScope(), save(), saveAttributes(), saveCounters(), scopes(), setAttribute(), setDbCriteria(), setIsNewRecord(), setOldPrimaryKey(), setPrimaryKey(), setTableAlias(), 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 summary
integer LEGACY_ID -1
#

When selecting a Credentials record: this as an ID indicates to use the (legacy) system default method. This should only ever be used in scenarios where "email" is the generic type of service being configured.

When selecting a Credentials record: this as an ID indicates to use the (legacy) system default method. This should only ever be used in scenarios where "email" is the generic type of service being configured.

integer SYS_ID -1
#

When the userId of the record is set to this value, that denotes that it is available system-wide for generic tasks not tied to any one person.

When the userId of the record is set to this value, that denotes that it is available system-wide for generic tasks not tied to any one person.

Constants inherited from CActiveRecord
BELONGS_TO, HAS_MANY, HAS_ONE, MANY_MANY, STAT
Properties summary
public static array $sysUseAlias array( -1 => 'bulkEmail', -2 => 'serviceCaseEmail', -3 => 'systemResponseEmail', -4 => 'systemNotificationEmail' )
#

Effectively the inverse map of Credentials::$sysUseId; declared statically to avoid having to generate it.

Effectively the inverse map of Credentials::$sysUseId; declared statically to avoid having to generate it.

public static array $sysUseId array( 'bulkEmail' => -1, 'serviceCaseEmail' => -2, 'systemResponseEmail' => -3, 'systemNotificationEmail' => -4 )
#

When selecting a user to set as the owner: values of this array as the userId field in the x2_credentials_default record indicate that it is it's owned by no one but can be used by anyone, and that it's the default for a particular usage that is generic (i.e. not tied to any one user), i.e. bulk email (which might typically use a non-personal address).

When selecting a user to set as the owner: values of this array as the userId field in the x2_credentials_default record indicate that it is it's owned by no one but can be used by anyone, and that it's the default for a particular usage that is generic (i.e. not tied to any one user), i.e. bulk email (which might typically use a non-personal address).

Different values of userId derived from this array hence distinguish different types of usage for system-wide credentials.

public static type $sysUseTypes array( -1 => 'email', -2 => 'email', -3 => 'email', -4 => 'email' )
#

For each system use type, define (as a comma-delineated list) the service type for that system use type.

For each system use type, define (as a comma-delineated list) the service type for that system use type.

protected array $validModels array( 'EmailAccount', 'GMailAccount', 'MandrillAccount', 'MailjetAccount', 'MailgunAccount', 'OutlookEmailAccount', 'SendgridAccount', 'SESAccount', 'YahooEmailAccount', 'TwitterApp', 'GoogleProject', )
#

Model classes to include/list as valid for storing auth data

Model classes to include/list as valid for storing auth data

protected static array $imapModels array( 'EmailAccount', 'GMailAccount', 'OutlookEmailAccount', 'YahooEmailAccount', )
#

Model classes which support the IMAP protocol

Model classes which support the IMAP protocol

Properties inherited from CActiveRecord
$db
Magic properties summary
public array $authModelLabels
#

(read-only) labels for embedded models; classes to display labels.

(read-only) labels for embedded models; classes to display labels.

public array $defaultCredentials
#

(read-only) all credential default records indexed by user ID and service type

(read-only) all credential default records indexed by user ID and service type

public array $defaultSubstitutes
#

(read-only) a map of service types to valid embedded classes for storing data for that service. For example, the Google account model can be used for sending email just as well as the generic email account model, so it would need to be included among a list of credentials to use as the default email account.

(read-only) a map of service types to valid embedded classes for storing data for that service. For example, the Google account model can be used for sending email just as well as the generic email account model, so it would need to be included among a list of credentials to use as the default email account.

public array $defaultSubstitutesInv
#

(read-only) Like defaultSubstitutes but "inverted"; displays, for a given model class, the list of service types for which it can act as a stand-in.

(read-only) Like defaultSubstitutes but "inverted"; displays, for a given model class, the list of service types for which it can act as a stand-in.

public boolean $isInUseBySystem
#

(read-only) indicates whether the attribute is being used for some system-wide/generic task.

(read-only) indicates whether the attribute is being used for some system-wide/generic task.

public array $serviceLabels
#

(read-only) An array of UI-friendly names for service keyworkds, i.e. "Email Account" for "email".

(read-only) An array of UI-friendly names for service keyworkds, i.e. "Email Account" for "email".

public array $sysUseLabels
#

(read-only) An array of labels for system-wide uses of system-owned credentials.

(read-only) An array of labels for system-wide uses of system-owned credentials.

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