diff -Naur mailchimp.old/mailchimp_nodeprofile.info mailchimp/mailchimp_nodeprofile.info --- mailchimp.old/mailchimp_nodeprofile.info 1969-12-31 19:00:00.000000000 -0500 +++ mailchimp/mailchimp_nodeprofile.info 2009-03-26 17:25:22.574786148 -0400 @@ -0,0 +1,6 @@ +; $Id: +name = Mailchimp Node Profile +description = Allows the Mailchimp module to take advantage of Node Profile fields. +dependencies = mailchimp nodeprofile content +package = MailChimp + diff -Naur mailchimp.old/mailchimp_nodeprofile.module mailchimp/mailchimp_nodeprofile.module --- mailchimp.old/mailchimp_nodeprofile.module 1969-12-31 19:00:00.000000000 -0500 +++ mailchimp/mailchimp_nodeprofile.module 2009-03-26 17:25:09.611128855 -0400 @@ -0,0 +1,73 @@ +type == nodeprofile_get_types()) ) { + if( ($q = _mailchimp_get_api_object()) && ($account = user_load(array('uid' => $node->uid))) ) { + foreach ( (array)$q->lists() as $key => $list ) { + if ( _mailchimp_is_subscribed( $list['id'], $account->mail, $q ) ) { + $merge_vars = _mailchimp_load_user_list_mergevars( $account->uid, $list['id'], $q->listMergeVars($list['id']) ); + _mailchimp_update_user( $list, $account->mail, $merge_vars, $q ); + } + } + } + } + break; + } +} + + + +/** + * Implementation of hook_mailchimp_merge_keys + */ +function mailchimp_nodeprofile_mailchimp_merge_keys() { + $out = array( 0 => '' ); + if ( function_exists( 'nodeprofile_get_types' ) ) { + foreach(nodeprofile_get_types() as $type){ + foreach(content_fields(NULL, $type->type) as $field_name => $field_values){ + if ($field_values['type_name'] == $type->type){ + $name = node_get_types('name', $type->type); + $out[$type->type .'_'. $field_name] = $name .': '. $field_values['widget']['label']; + } + } + } + } + return $out; +} + + +/** + * Implementation of hook_mailchimp_merge_values + */ +function mailchimp_nodeprofile_mailchimp_merge_values( $user ) { + $out = array(); + $out = (array)$user; + $out = array_merge( $out, _mailchimp_nodeprofile_get_fields( $user ) ); + return $out; +} + +/** + * Get Node Profile fields for the given user + */ +function _mailchimp_nodeprofile_get_fields( $user ) { + $out = array(); + if ( function_exists( 'nodeprofile_get_types' ) ) { + foreach(nodeprofile_get_types() as $type){ + $profile = node_load(array('uid' => $user->uid, 'type' => $type->type), NULL, true); + $profile = node_build_content($profile, false, true); + foreach(content_fields(NULL, $type->type) as $field_name => $field_values){ + if ($field_values['type_name'] == $type){ + $out[$type->type .'_'. $field_name] = $profile->$$field_name[0]['view']; + } + } + } + } + return $out; +}