As you know I have prepared an addon that turn offline member's avatar to gray. However, the addon is not fully hook because I cannot make the following hook to work.
The hook:
'integrate_prepare_display_context' => 'Bola_Main|SOURCEDIR/addons/BOLA.subs.php',
The main code (tested as correct):
// Add blur_avatars class to offline avatar in display page
addInlineJavascript('
$( "#info_'. $message['id_msg'] . '" ).parent().parent().parent().find(".avatar").addClass("blur_avatars");
', true);
The problematic, conditional, non-working code:
if (!empty($modSettings['bola_enable']) && !$message['member']['online']['is_online'])
if (!empty($modSettings['bola_enable']) && in_array($message['id_member'], !$user['is_online']))
Both of the above code are aimed to be conditions so that if the addon are enable and the said user are not online, the avatar will be blurred / grayed via blur_avatars css class. However, I cannot get either one to work which of course due to wrong coding.
In the manual modification, I change the default avatar injection to $poster_div to this:
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && $message['member']['online']['is_online'])
$poster_div .= '
<li class="listlevel1 poster_avatar">
<a class="linklevel1" href="' . $scripturl . '?action=profile;u=' . $message['member']['id'] . '">
' . $message['member']['avatar']['image'] . '
</a>
</li>';
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && !$message['member']['online']['is_online'])
$poster_div .= '
<li class="listlevel1 poster_avatar">
<a class="linklevel1 blur_avatars" href="' . $scripturl . '?action=profile;u=' . $message['member']['id'] . '">
' . $message['member']['avatar']['image'] . '
</a>
</li>';
Or is it wise to override avatar css img class if user is offline by using call_integration_hook('integrate_avatar', array(&$avatar, $profile)); in Load.php instead?
I was thinking if !$profile['is_online'] then $avatar['image'] should then be <img class="avatar avatarresize blur_avatars or something like that but not sure how yet.
Any suggestions to make this thing fully work using hook and without any direct file modification are highly appreciated.
Thank you.