Skip to content
Snippets Groups Projects
Contact.php 51.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • totten's avatar
    totten committed
    <?php
    
    totten's avatar
    totten committed
    /**
     * @package CRM
    
     * @copyright CiviCRM LLC https://civicrm.org/licensing
    
    totten's avatar
    totten committed
     *
     * Generated from xml/schema/CRM/Contact/Contact.xml
     * DO NOT EDIT.  Generated by CRM_Core_CodeGen
    
     * (GenCodeChecksum:e34bde9c7a6fcbfdc33cd9cbc305f1fb)
    
    totten's avatar
    totten committed
     */
    
    eileen's avatar
    eileen committed
    /**
    
     * Database access object for the Contact entity.
    
    eileen's avatar
    eileen committed
     */
    
    totten's avatar
    totten committed
    class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
    
    colemanw's avatar
    colemanw committed
      const EXT = 'civicrm';
      const TABLE_ADDED = '1.1';
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * Static instance to hold the table name.
    
    totten's avatar
    totten committed
       *
       * @var string
       */
    
      public static $_tableName = 'civicrm_contact';
    
      /**
       * Icon associated with this entity.
       *
       * @var string
       */
      public static $_icon = 'fa-address-book-o';
    
    
      /**
       * Field to show when displaying a record.
       *
       * @var string
       */
      public static $_labelField = 'display_name';
    
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * Should CiviCRM log any modifications to this table in the civicrm_log table.
    
    totten's avatar
    totten committed
       *
    
    totten's avatar
    totten committed
       */
    
      public static $_log = TRUE;
    
      /**
       * Paths for accessing this entity in the UI.
       *
       * @var string[]
       */
      protected static $_paths = [
    
        'add' => 'civicrm/contact/add?reset=1&ct=[contact_type]',
    
        'view' => 'civicrm/contact/view?reset=1&cid=[id]',
    
        'update' => 'civicrm/contact/add?reset=1&action=update&cid=[id]',
    
        'delete' => 'civicrm/contact/view/delete?reset=1&delete=1&cid=[id]',
      ];
    
    
    totten's avatar
    totten committed
      /**
       * Unique Contact ID
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $id;
    
    totten's avatar
    totten committed
      /**
       * Type of Contact.
       *
       * @var string
       */
      public $contact_type;
    
    totten's avatar
    totten committed
      /**
       * May be used to over-ride contact view and edit templates.
       *
       * @var string
       */
      public $contact_sub_type;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $do_not_email;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $do_not_phone;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $do_not_mail;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $do_not_sms;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $do_not_trade;
    
    totten's avatar
    totten committed
      /**
       * Has the contact opted out from receiving all bulk email from the organization or site domain?
       *
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $is_opt_out;
    
    totten's avatar
    totten committed
      /**
       * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
       *
       * @var string
       */
      public $legal_identifier;
    
    totten's avatar
    totten committed
      /**
       * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
       *
       * @var string
       */
      public $external_identifier;
    
    totten's avatar
    totten committed
      /**
       * Name used for sorting different contact types
       *
       * @var string
       */
      public $sort_name;
    
    totten's avatar
    totten committed
      /**
       * Formatted name representing preferred format for display/print/other output.
       *
       * @var string
       */
      public $display_name;
    
    totten's avatar
    totten committed
      /**
       * Nickname.
       *
       * @var string
       */
      public $nick_name;
    
    totten's avatar
    totten committed
      /**
       * Legal Name.
       *
       * @var string
       */
      public $legal_name;
    
    totten's avatar
    totten committed
      /**
       * optional URL for preferred image (photo, logo, etc.) to display for this contact.
       *
       * @var text
       */
      public $image_URL;
    
    totten's avatar
    totten committed
      /**
       * What is the preferred mode of communication.
       *
       * @var string
       */
      public $preferred_communication_method;
    
    totten's avatar
    totten committed
      /**
       * Which language is preferred for communication. FK to languages in civicrm_option_value.
       *
       * @var string
       */
      public $preferred_language;
    
    totten's avatar
    totten committed
      /**
       * What is the preferred mode of sending an email.
       *
       * @var string
       */
      public $preferred_mail_format;
    
    totten's avatar
    totten committed
      /**
       * Key for validating requests related to this contact.
       *
       * @var string
       */
      public $hash;
    
    totten's avatar
    totten committed
      /**
       * API Key for validating requests related to this contact.
       *
       * @var string
       */
      public $api_key;
    
    totten's avatar
    totten committed
      /**
       * where contact come from, e.g. import, donate module insert...
       *
       * @var string
       */
      public $source;
    
    totten's avatar
    totten committed
      /**
       * First Name.
       *
       * @var string
       */
      public $first_name;
    
    totten's avatar
    totten committed
      /**
       * Middle Name.
       *
       * @var string
       */
      public $middle_name;
    
    totten's avatar
    totten committed
      /**
       * Last Name.
       *
       * @var string
       */
      public $last_name;
    
    totten's avatar
    totten committed
      /**
       * Prefix or Title for name (Ms, Mr...). FK to prefix ID
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $prefix_id;
    
    totten's avatar
    totten committed
      /**
       * Suffix for name (Jr, Sr...). FK to suffix ID
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $suffix_id;
    
    totten's avatar
    totten committed
      /**
       * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
       *
       * @var string
       */
      public $formal_title;
    
    totten's avatar
    totten committed
      /**
       * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $communication_style_id;
    
    totten's avatar
    totten committed
      /**
       * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $email_greeting_id;
    
    totten's avatar
    totten committed
      /**
       * Custom Email Greeting.
       *
       * @var string
       */
      public $email_greeting_custom;
    
    totten's avatar
    totten committed
      /**
       * Cache Email Greeting.
       *
       * @var string
       */
      public $email_greeting_display;
    
    totten's avatar
    totten committed
      /**
       * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $postal_greeting_id;
    
    totten's avatar
    totten committed
      /**
       * Custom Postal greeting.
       *
       * @var string
       */
      public $postal_greeting_custom;
    
    totten's avatar
    totten committed
      /**
       * Cache Postal greeting.
       *
       * @var string
       */
      public $postal_greeting_display;
    
    totten's avatar
    totten committed
      /**
       * FK to civicrm_option_value.id, that has to be valid registered Addressee.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $addressee_id;
    
    totten's avatar
    totten committed
      /**
       * Custom Addressee.
       *
       * @var string
       */
      public $addressee_custom;
    
    totten's avatar
    totten committed
      /**
       * Cache Addressee.
       *
       * @var string
       */
      public $addressee_display;
    
    totten's avatar
    totten committed
      /**
       * Job Title
       *
       * @var string
       */
      public $job_title;
    
    totten's avatar
    totten committed
      /**
       * FK to gender ID
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $gender_id;
    
    totten's avatar
    totten committed
      /**
       * Date of birth
       *
       * @var date
       */
      public $birth_date;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $is_deceased;
    
    totten's avatar
    totten committed
      /**
       * Date of deceased
       *
       * @var date
       */
      public $deceased_date;
    
    totten's avatar
    totten committed
      /**
       * Household Name.
       *
       * @var string
       */
      public $household_name;
    
    totten's avatar
    totten committed
      /**
       * Optional FK to Primary Contact for this household.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $primary_contact_id;
    
    totten's avatar
    totten committed
      /**
       * Organization Name.
       *
       * @var string
       */
      public $organization_name;
    
    totten's avatar
    totten committed
      /**
       * Standard Industry Classification Code.
       *
       * @var string
       */
      public $sic_code;
    
    totten's avatar
    totten committed
      /**
       * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
       *
       * @var string
       */
      public $user_unique_id;
    
    totten's avatar
    totten committed
      /**
       * OPTIONAL FK to civicrm_contact record.
       *
    
    eileen's avatar
    eileen committed
       * @var int
    
    totten's avatar
    totten committed
       */
      public $employer_id;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * @var bool
    
    totten's avatar
    totten committed
       */
      public $is_deleted;
    
    totten's avatar
    totten committed
      /**
       * When was the contact was created.
       *
       * @var timestamp
       */
      public $created_date;
    
    totten's avatar
    totten committed
      /**
       * When was the contact (or closely related entity) was created or modified or deleted.
       *
       * @var timestamp
       */
      public $modified_date;
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * Class constructor.
    
    totten's avatar
    totten committed
       */
    
      public function __construct() {
    
    totten's avatar
    totten committed
        $this->__table = 'civicrm_contact';
        parent::__construct();
      }
    
      /**
       * Returns localized title of this entity.
    
       *
       * @param bool $plural
       *   Whether to return the plural version of the title.
    
      public static function getEntityTitle($plural = FALSE) {
        return $plural ? ts('Contacts') : ts('Contact');
    
    totten's avatar
    totten committed
      /**
    
    eileen's avatar
    eileen committed
       * Returns foreign keys and entity references.
    
    totten's avatar
    totten committed
       *
       * @return array
       *   [CRM_Core_Reference_Interface]
       */
    
      public static function getReferenceColumns() {
    
        if (!isset(Civi::$statics[__CLASS__]['links'])) {
    
          Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
    
          Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
          Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'employer_id', 'civicrm_contact', 'id');
    
          CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
    
    totten's avatar
    totten committed
        }
    
        return Civi::$statics[__CLASS__]['links'];
    
    totten's avatar
    totten committed
      }
    
    totten's avatar
    totten committed
      /**
       * Returns all the column names of this table
       *
       * @return array
       */
    
      public static function &fields() {
    
        if (!isset(Civi::$statics[__CLASS__]['fields'])) {
    
          Civi::$statics[__CLASS__]['fields'] = [
            'id' => [
    
    totten's avatar
    totten committed
              'name' => 'id',
              'type' => CRM_Utils_Type::T_INT,
    
              'title' => ts('Contact ID'),
    
              'description' => ts('Unique Contact ID'),
    
              'required' => TRUE,
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.id',
              'headerPattern' => '/internal|contact?|id$/i',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
              'name' => 'contact_type',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Contact Type'),
    
              'description' => ts('Type of Contact.'),
    
    totten's avatar
    totten committed
              'maxlength' => 64,
              'size' => CRM_Utils_Type::BIG,
              'where' => 'civicrm_contact.contact_type',
    
              'export' => TRUE,
    
              'contactType' => NULL,
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'table' => 'civicrm_contact_type',
                'keyColumn' => 'name',
                'labelColumn' => 'label',
                'condition' => 'parent_id IS NULL',
    
    eileen's avatar
    eileen committed
              ],
    
    totten's avatar
    totten committed
              'name' => 'contact_sub_type',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Contact Subtype'),
    
              'description' => ts('May be used to over-ride contact view and edit templates.'),
    
    totten's avatar
    totten committed
              'maxlength' => 255,
              'size' => CRM_Utils_Type::HUGE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.contact_sub_type',
              'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
              'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'table' => 'civicrm_contact_type',
                'keyColumn' => 'name',
                'labelColumn' => 'label',
                'condition' => 'parent_id IS NOT NULL',
    
    eileen's avatar
    eileen committed
              ],
    
    totten's avatar
    totten committed
              'name' => 'do_not_email',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('Do Not Email'),
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.do_not_email',
              'headerPattern' => '/d(o )?(not )?(email)/i',
              'dataPattern' => '/^\d{1,}$/',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'do_not_phone',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('Do Not Phone'),
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.do_not_phone',
              'headerPattern' => '/d(o )?(not )?(call|phone)/i',
              'dataPattern' => '/^\d{1,}$/',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'do_not_mail',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('Do Not Mail'),
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.do_not_mail',
              'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
              'dataPattern' => '/^\d{1,}$/',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'do_not_sms',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('Do Not Sms'),
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.do_not_sms',
              'headerPattern' => '/d(o )?(not )?(sms)/i',
              'dataPattern' => '/^\d{1,}$/',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'do_not_trade',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('Do Not Trade'),
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.do_not_trade',
              'headerPattern' => '/d(o )?(not )?(trade)/i',
              'dataPattern' => '/^\d{1,}$/',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'is_opt_out',
              'type' => CRM_Utils_Type::T_BOOLEAN,
    
              'title' => ts('No Bulk Emails (User Opt Out)'),
    
              'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
    
              'required' => TRUE,
              'import' => TRUE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.is_opt_out',
    
              'default' => '0',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'CheckBox',
    
    totten's avatar
    totten committed
              'name' => 'legal_identifier',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Legal Identifier'),
    
    Seamus Lee's avatar
    Seamus Lee committed
              'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
    
    totten's avatar
    totten committed
              'maxlength' => 32,
              'size' => CRM_Utils_Type::MEDIUM,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.legal_identifier',
              'headerPattern' => '/legal\s?id/i',
              'dataPattern' => '/\w+?\d{5,}/',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
            ],
            'external_identifier' => [
    
    totten's avatar
    totten committed
              'name' => 'external_identifier',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('External Identifier'),
    
              'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
    
    totten's avatar
    totten committed
              'maxlength' => 64,
              'size' => 8,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.external_identifier',
              'headerPattern' => '/external\s?id/i',
              'dataPattern' => '/^\d{11,}$/',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'sort_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Sort Name'),
    
              'description' => ts('Name used for sorting different contact types'),
    
    totten's avatar
    totten committed
              'maxlength' => 128,
              'size' => 30,
              'where' => 'civicrm_contact.sort_name',
    
              'export' => TRUE,
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'display_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Display Name'),
    
              'description' => ts('Formatted name representing preferred format for display/print/other output.'),
    
    totten's avatar
    totten committed
              'maxlength' => 128,
              'size' => 30,
              'where' => 'civicrm_contact.display_name',
    
              'export' => TRUE,
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'nick_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Nickname'),
    
              'description' => ts('Nickname.'),
    
    totten's avatar
    totten committed
              'maxlength' => 128,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.nick_name',
              'headerPattern' => '/n(ick\s)name|nick$/i',
              'dataPattern' => '/^\w+$/',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'legal_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Legal Name'),
    
              'description' => ts('Legal Name.'),
    
    totten's avatar
    totten committed
              'maxlength' => 128,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.legal_name',
              'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
    
              'contactType' => 'Organization',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'image_URL',
              'type' => CRM_Utils_Type::T_TEXT,
    
              'title' => ts('Image Url'),
    
              'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.image_URL',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'File',
    
            ],
            'preferred_communication_method' => [
    
    totten's avatar
    totten committed
              'name' => 'preferred_communication_method',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Preferred Communication Method'),
    
              'description' => ts('What is the preferred mode of communication.'),
    
    totten's avatar
    totten committed
              'maxlength' => 255,
              'size' => CRM_Utils_Type::HUGE,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.preferred_communication_method',
              'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
              'dataPattern' => '/^\w+$/',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
              'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'optionGroupName' => 'preferred_communication_method',
                'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
    
    eileen's avatar
    eileen committed
              ],
    
    totten's avatar
    totten committed
              'name' => 'preferred_language',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Preferred Language'),
    
              'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
    
    totten's avatar
    totten committed
              'maxlength' => 5,
              'size' => CRM_Utils_Type::SIX,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.preferred_language',
              'headerPattern' => '/^lang/i',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'optionGroupName' => 'languages',
                'keyColumn' => 'name',
                'optionEditPath' => 'civicrm/admin/options/languages',
    
    eileen's avatar
    eileen committed
              ],
    
            ],
            'preferred_mail_format' => [
    
    totten's avatar
    totten committed
              'name' => 'preferred_mail_format',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Preferred Mail Format'),
    
              'description' => ts('What is the preferred mode of sending an email.'),
    
    totten's avatar
    totten committed
              'maxlength' => 8,
              'size' => CRM_Utils_Type::EIGHT,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.preferred_mail_format',
              'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
    
    totten's avatar
    totten committed
              'default' => 'Both',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'callback' => 'CRM_Core_SelectValues::pmf',
    
    eileen's avatar
    eileen committed
              ],
    
    totten's avatar
    totten committed
              'name' => 'hash',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Contact Hash'),
    
              'description' => ts('Key for validating requests related to this contact.'),
    
    totten's avatar
    totten committed
              'maxlength' => 32,
              'size' => CRM_Utils_Type::MEDIUM,
              'where' => 'civicrm_contact.hash',
    
              'export' => TRUE,
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
              'name' => 'api_key',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Api Key'),
    
              'description' => ts('API Key for validating requests related to this contact.'),
    
    totten's avatar
    totten committed
              'maxlength' => 32,
              'size' => CRM_Utils_Type::MEDIUM,
    
              'where' => 'civicrm_contact.api_key',
    
              'permission' => [
                [
                  'administer CiviCRM',
                  'edit api keys',
                ],
              ],
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
              'name' => 'source',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Contact Source'),
    
              'description' => ts('where contact come from, e.g. import, donate module insert...'),
    
    totten's avatar
    totten committed
              'maxlength' => 255,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.source',
              'headerPattern' => '/(C(ontact\s)?Source)$/i',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'first_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('First Name'),
    
              'description' => ts('First Name.'),
    
    totten's avatar
    totten committed
              'maxlength' => 64,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.first_name',
              'headerPattern' => '/^first|(f(irst\s)?name)$/i',
              'dataPattern' => '/^\w+$/',
    
              'contactType' => 'Individual',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'middle_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Middle Name'),
    
              'description' => ts('Middle Name.'),
    
    totten's avatar
    totten committed
              'maxlength' => 64,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.middle_name',
              'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
              'dataPattern' => '/^\w+$/',
    
              'contactType' => 'Individual',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'last_name',
              'type' => CRM_Utils_Type::T_STRING,
    
              'title' => ts('Last Name'),
    
              'description' => ts('Last Name.'),
    
    totten's avatar
    totten committed
              'maxlength' => 64,
              'size' => 30,
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.last_name',
              'headerPattern' => '/^last|(l(ast\s)?name)$/i',
              'dataPattern' => '/^\w+(\s\w+)?+$/',
    
              'contactType' => 'Individual',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Text',
    
    totten's avatar
    totten committed
              'name' => 'prefix_id',
              'type' => CRM_Utils_Type::T_INT,
    
              'title' => ts('Individual Prefix'),
    
              'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.prefix_id',
              'headerPattern' => '/^(prefix|title)/i',
              'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
    
              'contactType' => 'Individual',
    
    eileen's avatar
    eileen committed
              'table_name' => 'civicrm_contact',
              'entity' => 'Contact',
              'bao' => 'CRM_Contact_BAO_Contact',
    
              'localizable' => 0,
    
    totten's avatar
    totten committed
                'type' => 'Select',
    
    totten's avatar
    totten committed
                'optionGroupName' => 'individual_prefix',
                'optionEditPath' => 'civicrm/admin/options/individual_prefix',
    
    eileen's avatar
    eileen committed
              ],
    
    totten's avatar
    totten committed
              'name' => 'suffix_id',
              'type' => CRM_Utils_Type::T_INT,
    
              'title' => ts('Individual Suffix'),
    
              'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
    
    totten's avatar
    totten committed
              'where' => 'civicrm_contact.suffix_id',
              'headerPattern' => '/^suffix$/i',
              'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
    
              'contactType' => 'Individual',