'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'), ); return $items; } 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, 'archived__isnull' => true, 'campaign__archived__isnull' => true, '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', ), ); } function fulcrm_mailshot_create_mailshot( $person, $recipient, $campaign_id, $d, $is_system = false, $content_object = null, $to_header = null ) { if ( is_null( $to_header ) ) $to_header = $recipient; $data = array( 'person' => $person, 'recipient' => $recipient, 'campaign' => '/api/v2/campaign/' . $campaign_id . '/', 'to_header' => $to_header, 'is_system' => ( $is_system ? true : false ), 'd' => $d, ); if ( !is_null( $content_object ) ) $data[ 'content_object' ] = $content_object; $api_data = fulcrm_apiv2_POST( 'mailshot/', $data = $data, $query = array( 'expand' => 'd' ), ); if ( $api_data[ 'success' ] ) return $api_data[ 'headers' ][ 'Location' ]; } function fulcrm_mailshot_send_mailshot( $mailshot ) { $api_data = fulcrm_apiv2_POST( $mailshot . 'send/', $data = array() ); return $api_data[ 'success' ]; }