You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
3.0 KiB
PHP
61 lines
3.0 KiB
PHP
<?php /* -*- php -*- */
|
|
|
|
function fulcrm_mailshot_menu() {
|
|
$items = array();
|
|
$items[ 'user/mailshots' ] = array( 'page callback' => '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',
|
|
),
|
|
);
|
|
}
|