Skip to content

Commit

Permalink
CRM: Fix PHP error (and logic) on dashboard Recent Activity avatar (#…
Browse files Browse the repository at this point in the history
…40280)

* Fix recent activity avatar on dash

* Fix escaped output

* Add changelog

* Simplify
  • Loading branch information
tbradsha authored Nov 20, 2024
1 parent 6edf453 commit c465b13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
16 changes: 13 additions & 3 deletions projects/plugins/crm/admin/dashboard/main.page.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@ function jpcrm_render_dashboard_page() {
$last_x_ago = '';
foreach ( $latest_logs as $log ) {

$em = zeroBS_customerEmail( $log['owner'] );
$avatar = zeroBSCRM_getGravatarURLfromEmail( $em, 28 );
$log_avatar = '';
$log_wp_user = get_userdata( $log['owner'] );
// If the WP user still exists, grab their email and generate a gravatar URL.
if ( $log_wp_user ) {
$log_avatar = zeroBSCRM_getGravatarURLfromEmail( $log_wp_user->user_email, 28 );
}
$unixts = gmdate( 'U', strtotime( $log['created'] ) );
$diff = human_time_diff( $unixts, current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested

Expand Down Expand Up @@ -289,7 +293,13 @@ function jpcrm_render_dashboard_page() {
}
?>
<div class="feed-item">
<img class="ui avatar img img-rounded" alt="<?php esc_attr_e( 'Contact Image', 'zero-bs-crm' ); ?>" src="<?php echo esc_url( $avatar ); ?>"/>
<?php
if ( $log_wp_user ) {
?>
<img class="ui avatar img img-rounded" alt="<?php esc_attr_e( 'Contact Image', 'zero-bs-crm' ); ?>" src="<?php echo esc_url( $log_avatar ); ?>"/>
<?php
}
?>
<div>
<?php echo esc_html( $logmetatype ); ?>
<div><?php echo wp_kses( $logmetashot, array( 'i' => array( 'class' => true ) ) ); ?></div>
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/crm/changelog/fix-crm-php_error_on_dash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Dashboard: Show correct avatar for recent activity.
12 changes: 6 additions & 6 deletions projects/plugins/crm/includes/ZeroBSCRM.GeneralFuncs.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,27 +670,27 @@ function jpcrm_inject_contacts( $contacts, $args ) {
$injected_contacts = array(
array(
'id' => 0,
'name' => '<i class="fa fa-diamond green"></i>',
'name' => 'Project Oz 🌈',
),
array(
'id' => -1,
'name' => 'Wizard of Oz',
'name' => 'Dorothy 👠',
),
array(
'id' => -2,
'name' => 'Dorothy',
'name' => 'Toto the Dog 🐶',
),
array(
'id' => -3,
'name' => 'Toto the Dog',
'name' => 'Scarecrow 🧑‍🌾',
),
array(
'id' => -4,
'name' => 'Scarecrow',
'name' => 'Tin Man 🤖',
),
array(
'id' => -5,
'name' => 'Tin Man',
'name' => 'Cowardly Lion 🦁',
),
);
}
Expand Down

0 comments on commit c465b13

Please sign in to comment.