initial import

master
Marek Isalski 7 years ago
parent 59a13b6e4e
commit b5773ac00b

@ -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

@ -0,0 +1,56 @@
<? /* -*- php -*- */
function fulcrm_mailshot_menu() {
$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'),
);
}
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',
),
);
}

@ -0,0 +1,49 @@
<div class="redeye-member-mailshots">
<h2>Emails from Redeye</h2>
<ul class="list-unstyled">
<?php foreach ( $mailshots as $mailshot ): ?>
<?php if ( $mailshot['completed'] ): ?>
<li><h3><q><?php print check_plain( $mailshot['campaign']['subject'] ); ?></q> <small><?php
$tz = new DateTimeZone('UTC');
$completed = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$mailshot['completed'],$timezone=$tz);
if ( $completed )
print format_date( $completed->getTimestamp(), 'custom', '\s\e\n\t \o\n j/M/Y \a\t ga' );
?></small></h3>
<blockquote>
<?php print text_summary( $mailshot['campaign']['d']['body'], 'full_html' ); ?>
<?php foreach ( $mailshot['_view_urls']['text/html'] as $k => $v ): ?>
<p><a href="<?php print check_plain($v); ?>" target="_blank">read more&hellip;</a></p>
<?php endforeach; ?>
</blockquote>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<nav aria-label="Page navigation">
<ul class="pagination">
<?php if ($page>1): ?>
<li>
<a href="/user/mailshots/<?php print $page-1;?>" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<?php else: ?>
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
<?php endif; ?>
<?php for ( $i = 1; $i <= $pages; $i++ ): ?>
<li<?php if ($i==$page):?> class="active"<?php endif; ?>><a href="/user/mailshots/<?php print $i; ?>"><?php print $i; ?></a></li>
<?php endfor; ?>
<?php if ($page+1<$pages): ?>
<li>
<a href="/user/mailshots/<?php print $page+1; ?>" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
<?php else: ?>
<li class="disabled"><a href="#" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
<?php endif; ?>
</ul>
</nav>
Loading…
Cancel
Save