Skip to main content
Topic: BOLA: Blur OffLine Avatar (Read 1600 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

BOLA: Blur OffLine Avatar

BOLA: Blur OffLine Avatar

- For version 1.0x and 1.1x.
- Fully Hook.

1. Please do your own backup though every installation is backed up automatically.
2. This addon will allow you to blur offline avatar i.e. in mobile view below 50em.
3. If you enable this addon in the settings page, the offline avatar's color will be changed to gray.
4. Option for blurring the avatar to all view instead just in small/mobile view is also available.
5. For security, only logged-in user(s) is allowed to view offline user by default.
6. Upon successful installation, you will be brought to addon settings page where you can enable it.


Thank you for using/testing it.


Yours friendly,
Abu Fahim Ismail.

BSD License. Feel free to modify accordingly but keep author's link if it is in there somewhere. ;)

 

#Change Logs

@Version 1.0.6
- Restore sources as addons main folder.
- Option to show blurred avatar to all view and not only in small/mobile view.
- By default, it shows only to logged-in user(s), so guest won't know any offline user(s).
Spoiler (click to show/hide)

Re: BOLA - Blur OffLine Avatar

Reply #1
First suggestion about hooks, avoid to "pollute" the addons directory with the files, keep everything into a subdirectory, something like:
Code: [Select]
sources/
  |-- addons/
        |-- BOLA/
             |-- BOLA.subs.php
Yes, I know it's boring, but the addons directory has a particular meaning in 1.1[1] and if we start keeping it tidy, the transition will be smooth. ;)
It's not I want to force you not to throw files in the addons directory, but I just want to let everybody know about this (that may have slipped through because the directory is not something I have explained in details. O:-))

Second: BOLA_Main is added to integrate_prepare_display_context, this means the same javascript code will be added and run several times during the page rendering. (struk, because even though it's true, it has a reason to be there.)

Third part a:
Code: [Select]
in_array($message['id_member'], $user_info['buddies'])
do you want to blur members not online or the buddies? ;)
Third part b:
Code: [Select]
$( ".avatar" ).addClass("blur_avatars");
means "pick any element of class "avatar" in the page and add the class "blur_avatars".
I feel what you wanted to do was: "pick any element of class "avatar" of members currently not online and add the class "blur_avatars". In your code the "members currently not online" is missing, because jQuery doesn't work on the last added element, but on *any* element in the page up to the point it is inserted.
Do that via javascript is a bit... messy, because there is no id wrapping all the elements of the message that is unique for that message, so the only thing you can do is pick the id of the "post_anchor", find it's parent and then find the "avatar" element, something like this:
Code: [Select]
$( "#msg' . $output['id'] . '" ).parent().find(".avatar" ).addClass("blur_avatars");
I'm not sure it will work, give it a try. ;)
Using a certain naming pattern and some classes ad methods, it is possible to reduce the installation procedure to just the unzip and the "activation" goes into the "core features" page.
That's a kind of advanced-non-yet-documented use of the directory, but the idea is that at some point in the future it could become the standard method of installation. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: BOLA - Blur OffLine Avatar

Reply #2
That was the wrong package actually. Below is what I intended to do i.e. add blur_avatars class only to those who are not online.

Code: [Select]
global $modSettings, $message;

if (!empty($modSettings['bola_enable']) && !$message['member']['online']['is_online']) {
// Add blur_avatars class to offline avatar in display page
addInlineJavascript('
$(' . $message['member']['id'] . '".linklevel1 .avatar").addClass("blur_avatars");
', true);
}

I was trying to convert it from this code:

Code: [Select]
	// Show avatars, images, etc.?
if (empty($options['hide_poster_area']) && !$ignoring)
{
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>';

I guess it is missing a proper id or something.

Re: BOLA - Blur OffLine Avatar

Reply #3
This actually looks to be a really nice approach to show that someone is offline :D I might test it when I get the time.

Re: BOLA - Blur OffLine Avatar

Reply #4
I will revert it back to manual modification since I cant get the hook working correctly.

Re: BOLA - Blur OffLine Avatar

Reply #5
 :(  Thanks for the effort!  :)

Re: BOLA - Blur OffLine Avatar

Reply #6
Fixed the installation file to include original manual modification since I still cannot find the correct way to make it work simply using hook(s). The new one is attached in first post replacing the old one.

I will explore other possibility to make this addon works without any file modification.

First suggestion about hooks, avoid to "pollute" the addons directory with the files, keep everything into a subdirectory, something like:
Code: [Select]
sources/
  |-- addons/
        |-- BOLA/
             |-- BOLA.subs.php
Yes, I know it's boring, but the addons directory has a particular meaning in 1.1[1] and if we start keeping it tidy, the transition will be smooth. ;)
It's not I want to force you not to throw files in the addons directory, but I just want to let everybody know about this (that may have slipped through because the directory is not something I have explained in details. O:-))

I haven't done this in the new package but will do this in the future.
Using a certain naming pattern and some classes ad methods, it is possible to reduce the installation procedure to just the unzip and the "activation" goes into the "core features" page.
That's a kind of advanced-non-yet-documented use of the directory, but the idea is that at some point in the future it could become the standard method of installation. ;)

Re: BOLA - Blur OffLine Avatar

Reply #7
By the way, @emanuele should the footnote in a quote be inside a quote, instead of being inside of the main post / message?

Re: BOLA - Blur OffLine Avatar

Reply #8
There are several topics about it, feel free to weight in.
 emanuele would avoid hijacking the topic with an OT discussion. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: BOLA - Blur OffLine Avatar

Reply #9
There are several topics about it, feel free to weight in.
 emanuele would avoid hijacking the topic with an OT discussion. ;)

Ok. Noted that.

I would also like to note that, thanks to @emanuele we have successsfully make this addon fully hook i.e. with no file modification. The new one will added to the OT.

#Change Logs

@Version 1.0.3
- Restructuring the whole addon's directory and location.

@Version 1.0.2
- Fully hook version. Thank you for great support from @emanuele.

@Version 1.0.1
- Reverting back to partly manual modification.

@Version 1.0.0
- Initial release.

Re: [ADDON] BOLA - Blur OffLine Avatar

Reply #10
#Change Logs

@Version 1.0.4
- Cleaning up some code.

Re: BOLA: Blur OffLine Avatar

Reply #11
#Change Logs

@Version 1.0.5
- Make it work with 1.1 Beta 3.

 

Re: BOLA: Blur OffLine Avatar

Reply #12
#Change Logs

@Version 1.0.6
- Restore sources as addons main folder.
- Option to show blurred avatar to all view and not only in small/mobile view.
- By default, it shows only to logged-in user(s), so guest won't know any offline user(s).