コード例 #1
0
ファイル: utils.php プロジェクト: sugan2111/Drupal_code
/**
 * Build fields array.
 *
 * This is the array of fields as it relates to the given DAO
 * returns unique fields as keys by default but if set but can return by DB fields
 *
 * @param CRM_Core_DAO $bao
 *
 * @return array
 */
function _civicrm_api3_get_unique_name_array(&$bao)
{
    $fields = $bao->fields();
    foreach ($fields as $field => $values) {
        $uniqueFields[$field] = CRM_Utils_Array::value('name', $values, $field);
    }
    return $uniqueFields;
}
コード例 #2
0
ファイル: Import.php プロジェクト: kidaa30/yes
 /**
  * @param CRM_Core_DAO $dao
  * @param $xml
  * @param bool $save
  * @param null $keyName
  *
  * @return bool
  */
 public function copyData(&$dao, &$xml, $save = FALSE, $keyName = NULL)
 {
     if ($keyName) {
         if (isset($xml->{$keyName})) {
             $dao->{$keyName} = (string) $xml->{$keyName};
             if ($dao->find(TRUE)) {
                 CRM_Core_Session::setStatus(ts("Found %1, %2, %3", array(1 => $keyName, 2 => $dao->{$keyName}, 3 => $dao->__table)), '', 'info');
                 return FALSE;
             }
         }
     }
     $fields =& $dao->fields();
     foreach ($fields as $name => $dontCare) {
         if (isset($xml->{$name})) {
             $value = (string) $xml->{$name};
             $value = str_replace(CRM_Utils_Migrate_Export::XML_VALUE_SEPARATOR, CRM_Core_DAO::VALUE_SEPARATOR, $value);
             $dao->{$name} = $value;
         }
     }
     if ($save) {
         $dao->save();
     }
     return TRUE;
 }
コード例 #3
0
ファイル: Export.php プロジェクト: rameshrr99/civicrm-core
 /**
  * @param string $objectName
  *   Business-entity/xml-tag name.
  * @param CRM_Core_DAO $object
  * @param $mappedFields
  *
  * @return array
  */
 public function exportDAO($objectName, $object, $mappedFields)
 {
     $dbFields =& $object->fields();
     // Filter the list of keys and values so that we only export interesting stuff
     $keyValues = array();
     foreach ($dbFields as $name => $dontCare) {
         // ignore all ids
         if ($name == 'id' || substr($name, -3, 3) == '_id') {
             continue;
         }
         if (isset($object->{$name}) && $object->{$name} !== NULL) {
             // hack for extends_entity_column_value
             if ($name == 'extends_entity_column_value') {
                 if (in_array($object->extends, array('Event', 'Activity', 'Relationship', 'Individual', 'Organization', 'Household', 'Case'))) {
                     if ($object->extends == 'Event') {
                         $key = 'event_type';
                     } elseif ($object->extends == 'Activity') {
                         $key = 'activity_type';
                     } elseif ($object->extends == 'Relationship') {
                         $key = 'relationship_type';
                     } elseif ($object->extends == 'Case') {
                         $key = 'case_type';
                     }
                     $types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($object->{$name}, 1, -1));
                     $values = array();
                     if (in_array($object->extends, array('Individual', 'Organization', 'Household'))) {
                         $key = 'contact_type';
                         $values = $types;
                     } else {
                         foreach ($types as $type) {
                             if (in_array($key, array('activity_type', 'event_type', 'case_type'))) {
                                 $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $key, 'id', 'name');
                                 $ovParams = array('option_group_id' => $ogID, 'value' => $type);
                                 CRM_Core_BAO_OptionValue::retrieve($ovParams, $oValue);
                                 $values[] = $oValue['name'];
                             } else {
                                 $relTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_RelationshipType', $type, 'name_a_b', 'id');
                                 $values[] = $relTypeName;
                             }
                         }
                     }
                     $keyValues['extends_entity_column_value_option_group'] = $key;
                     $value = implode(',', $values);
                     $object->extends_entity_column_value = $value;
                 } else {
                     echo "This extension: {$object->extends} is not yet handled";
                     exit;
                 }
             }
             $value = $object->{$name};
             if ($name == 'field_name') {
                 // hack for profile field_name
                 if (substr($value, 0, 7) == 'custom_') {
                     $cfID = substr($value, 7);
                     list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($cfID);
                     $value = "custom.{$tableName}.{$columnName}";
                 }
             }
             $keyValues[$name] = $value;
         }
     }
     $keyValues += $this->computeMappedFields($mappedFields, $object);
     return $keyValues;
 }