diff --git a/fulcrm_mailshot.info b/fulcrm_mailshot.info new file mode 100644 index 0000000..cf0f68c --- /dev/null +++ b/fulcrm_mailshot.info @@ -0,0 +1,9 @@ +name = fulcrm mailshot +description = fulcrm mailshot +core = 7.x +package = fulcrm + +configure = admin/config/services/fulcrm/mailshot + +dependencies[] = fulcrm_apiv2 +dependencies[] = fulcrm_webhook diff --git a/fulcrm_mailshot.module b/fulcrm_mailshot.module new file mode 100644 index 0000000..fb2253d --- /dev/null +++ b/fulcrm_mailshot.module @@ -0,0 +1,56 @@ + 'fulcrm_mailshot_user_mailshots', + 'title' => 'Mailshot History', + 'description' => 'View all previous mailshots.', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + ); + $items[ 'user/mailshots/%' ] = array( 'page callback' => 'fulcrm_mailshot_user_mailshots', + 'page arguments' => array(2), + 'title' => 'Mailshot History', + 'description' => 'View all previous mailshots.', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + ); +} + +function fulcrm_mailshot_user_mailshots( $page = 1 ) { + global $user; + $person_id = NULL; + + $variables = array(); + $page_size = 10; + + if ( user_is_logged_in() ) { + $person_id = fulcrm_webhook_get_pk_for_entity_type( 'user', $user->uid, 'person' ); + } + + if ( $person_id ) { + $api2_data = fulcrm_apiv2_GET( 'mailshot/', + $query = array( 'person' => $person_id, + 'page_size' => $page_size, + 'page' => $page, + 'completed__isnull' => false, + 'expand' => implode( ',', array( 'campaign', + 'campaign.d', + ) ) ) ); + + if ( $api2_data[ 'success' ] ) { + $variables[ 'mailshots' ] = $api2_data[ 'data' ][ 'results' ]; + $variables[ 'mailshots_count' ] = $api2_data[ 'data' ][ 'count' ]; + $variables[ 'pages' ] = $variables[ 'mailshots_count' ] / $page_size; + $variables[ 'page' ] = $page; + } + } + + return theme( 'fulcrm_mailshot_user_mailshots', $variables ); +} + +function fulcrm_mailshot_theme( $existing, $type, $theme, $path ) { + return array( 'fulcrm_mailshot_user_mailshots' => array( 'variables' => array(), // data returned from fulcrm API + 'template' => 'fulcrm_mailshot_user_mailshots', + ), + ); +} diff --git a/fulcrm_mailshot_user_mailshots.tpl.php b/fulcrm_mailshot_user_mailshots.tpl.php new file mode 100644 index 0000000..27abe01 --- /dev/null +++ b/fulcrm_mailshot_user_mailshots.tpl.php @@ -0,0 +1,49 @@ +
+

Emails from Redeye

+ + +
+ +