diff --git a/fulcrm_campaign.admin.inc b/fulcrm_campaign.admin.inc index b8028c0..480c8ce 100644 --- a/fulcrm_campaign.admin.inc +++ b/fulcrm_campaign.admin.inc @@ -562,7 +562,7 @@ function _fulcrm_campaign_admin_campaign_sync_build( $fcid, $fetch = false, $err } } - $query = db_select( 'fulcrm_campaign' )->fields( 'fulcrm_campaign', array( 'fcid', 'name', 'subject') )->condition( 'fulcrm_campaign.fcid', $fcid ); + $query = db_select( 'fulcrm_campaign' )->fields( 'fulcrm_campaign', array( 'fcid', 'name', 'subject' ) )->condition( 'fulcrm_campaign.fcid', $fcid ); foreach ( $query->execute() as $row ) { $campaign[ 'name' ] = $row->name; $campaign[ 'subject' ] = $row->subject; @@ -593,19 +593,49 @@ function _fulcrm_campaign_admin_campaign_sync_build( $fcid, $fetch = false, $err ->orderBy( 'fulcrm_campaign_node.weight' ); foreach ( $query->execute() as $row ) { $node = node_load( $row->nid ); - $node_view = node_view( $node, 'full' ); - - $node_data = array( 'title' => $node->title, - //'date' => $node->date, - //'node_url' => $node->url, - //'submitted' => $submitted, - //'nid' => $node->nid, - //'type' => $node->type, - ( 'is_node_type_' . $node->type . '?' ) => true, - ); + if ( $node ) { + $uri = entity_uri( 'node', $node ); + $node_data = array( ( 'is_node_type_' . $node->type . '?' ) => TRUE, + 'node_url' => url( $uri[ 'path' ], $uri[ 'options' ] ), + 'node_url_absolute' => url( $uri[ 'path' ], array_merge( $uri[ 'options' ], array( 'absolute' => TRUE ) ) ), + 'date' => format_date( $node->created ), + 'name' => theme( 'username', array( 'account' => $node ) ), + ); + + foreach ( get_object_vars( $node ) as $k => $v ) { + switch ( $k ) { + case 'data': + $node_data[ 'data' ] = unserialize( $v ); + break; + default: + if ( strpos( $k, 'field_' ) === 0 ) { + $v = _fulcrm_campaign_admin_array_copy( $v ); + $v[ 'is_field?' ] = TRUE; + foreach ( $v as $lang => $langitems ) { + $user = $old_user; + for ( $i = 0; $i < count( $langitems ); $i++ ) { + $v[ $lang ][ $i ][ 'is_field_value?' ] = TRUE; + if ( array_key_exists( 'filemime', $langitems[ $i ] ) ) { + if ( strpos( $langitems[ $i ][ 'filemime' ], 'image/' ) === 0 ) { + $v[ 'is_image_field?' ] = TRUE; + $v[ $lang ][ $i ][ 'is_image?' ] = TRUE; + foreach ( image_styles() as $imagestyle => $styledata ) { + $v[ $lang ][ $i ][ 'image_style_' . $imagestyle . '_url' ] = image_style_url( $imagestyle, $v[ $lang ][ $i ][ 'uri' ] ); + $v[ $lang ][ $i ][ 'image_style_' . $imagestyle . '_url_absolute' ] = url( $v[ $lang ][ $i ][ 'image_style_' . $imagestyle . '_url' ], array( 'absolute' => TRUE ) ); + } + } + } + } + } + } + $node_data[ $k ] = $v; + break; + } + } - $fms_content[ 'node_' . $node->nid ] = $node_data; - $campaign[ $row->name ] = $row->value; + $fms_content[ 'node_' . $node->nid ] = $node_data; + $campaign[ $row->name ] = $row->value; + } } $campaign[ 'd' ][ 'fms_content' ] = $fms_content;