コード例 #1
0
ファイル: OptionValue.php プロジェクト: konadave/civicrm-core
 /**
  * Check if there is a record with the same name in the db.
  *
  * @param string $mode
  * @param string $contactType
  *
  * @return bool
  *   true if object exists
  */
 public static function getFields($mode = '', $contactType = 'Individual')
 {
     $key = "{$mode} {$contactType}";
     if (empty(self::$_fields[$key]) || !self::$_fields[$key]) {
         self::$_fields[$key] = array();
         $option = CRM_Core_DAO_OptionValue::import();
         foreach (array_keys($option) as $id) {
             $optionName = $option[$id];
         }
         $nameTitle = array();
         if ($mode == 'contribute') {
             $nameTitle = array('payment_instrument' => array('name' => 'payment_instrument', 'title' => ts('Payment Method'), 'headerPattern' => '/^payment|(p(ayment\\s)?instrument)$/i'));
         } elseif ($mode == '') {
             //the fields email greeting and postal greeting are meant only for Individual and Household
             //the field addressee is meant for all contact types, CRM-4575
             if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                 $nameTitle = array('addressee' => array('name' => 'addressee', 'title' => ts('Addressee'), 'headerPattern' => '/^addressee$/i'));
                 $title = array('email_greeting' => array('name' => 'email_greeting', 'title' => ts('Email Greeting'), 'headerPattern' => '/^email_greeting$/i'), 'postal_greeting' => array('name' => 'postal_greeting', 'title' => ts('Postal Greeting'), 'headerPattern' => '/^postal_greeting$/i'));
                 $nameTitle = array_merge($nameTitle, $title);
             }
         }
         if (is_array($nameTitle)) {
             foreach ($nameTitle as $name => $attribs) {
                 self::$_fields[$key][$name] = $optionName;
                 list($tableName, $fieldName) = explode('.', $optionName['where']);
                 self::$_fields[$key][$name]['where'] = "{$name}.label";
                 foreach ($attribs as $k => $val) {
                     self::$_fields[$key][$name][$k] = $val;
                 }
             }
         }
     }
     return self::$_fields[$key];
 }
コード例 #2
0
ファイル: OptionValue.php プロジェクト: ksecor/civicrm
 /**
  * Check if there is a record with the same name in the db
  *
  * @param string $value     the value of the field we are checking
  * @param string $daoName   the dao object name
  * @param string $daoID     the id of the object being updated. u can change your name
  *                          as long as there is no conflict
  * @param string $fieldName the name of the field in the DAO
  *
  * @return boolean     true if object exists
  * @access public
  * @static
  */
 static function getFields($mode = '', $contactType = 'Individual')
 {
     $key = "{$mode} {$contactType}";
     if (empty(self::$_fields[$key]) || !self::$_fields[$key]) {
         self::$_fields[$key] = array();
         require_once "CRM/Core/DAO/OptionValue.php";
         $option = CRM_Core_DAO_OptionValue::import();
         foreach (array_keys($option) as $id) {
             $optionName = $option[$id];
         }
         $nameTitle = array();
         if ($mode == 'contribute') {
             $nameTitle = array('payment_instrument' => array('name' => 'payment_instrument', 'title' => 'Payment Instrument', 'headerPattern' => '/^payment|(p(ayment\\s)?instrument)$/i'));
         } else {
             if ($mode == '') {
                 //the fields email greeting and postal greeting are meant only for Individual and Household
                 //the field addressee is meant for all contact types, CRM-4575
                 if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                     $nameTitle = array('addressee' => array('name' => 'addressee', 'title' => 'Addressee', 'headerPattern' => '/^addressee$/i'));
                 }
                 if ($contactType == 'Individual' || $contactType == 'Household' || $contactType == 'All') {
                     $title = array('email_greeting' => array('name' => 'email_greeting', 'title' => 'Email Greeting', 'headerPattern' => '/^email_greeting$/i'), 'postal_greeting' => array('name' => 'postal_greeting', 'title' => 'Postal Greeting', 'headerPattern' => '/^postal_greeting$/i'));
                     $nameTitle = array_merge($nameTitle, $title);
                 }
                 if ($contactType == 'Individual' || $contactType == 'All') {
                     $title = array('gender' => array('name' => 'gender', 'title' => 'Gender', 'headerPattern' => '/^gender$/i'), 'individual_prefix' => array('name' => 'individual_prefix', 'title' => 'Individual Prefix', 'headerPattern' => '/^(prefix|title)/i'), 'individual_suffix' => array('name' => 'individual_suffix', 'title' => 'Individual Suffix', 'headerPattern' => '/^suffix$/i'));
                     $nameTitle = array_merge($nameTitle, $title);
                 }
             }
         }
         if (is_array($nameTitle)) {
             foreach ($nameTitle as $name => $attribs) {
                 self::$_fields[$key][$name] = $optionName;
                 list($tableName, $fieldName) = explode('.', $optionName['where']);
                 // not sure of this fix, so keeping it commented for now
                 // this is from CRM-1541
                 // self::$_fields[$mode][$name]['where'] = $name . '.' . $fieldName;
                 self::$_fields[$key][$name]['where'] = "{$name}.label";
                 foreach ($attribs as $k => $val) {
                     self::$_fields[$key][$name][$k] = $val;
                 }
             }
         }
     }
     return self::$_fields[$key];
 }