Buddies With Me (formerly Followers)

Started by dougiefresh, July 17, 2014, 04:17:53 PM

Previous topic - Next topic

dougiefresh

Link to Mod



BUDDIES WITH ME v2.2
By Dougiefresh - Link to Mod



Introduction
This mod adds a page to the Profile area under Buddies/Ignore List that lists everybody that lists you as a buddy.  Note that you cannot remove someone from their buddies list!

This mod also adds a resync function to the Admin area under Forum Maintenance, under Members, in the event the Buddies With Me table ever becomes unsynced.

Related Discussion
- Easiest way to display a list of everyone whos added me as a buddy on my profile

Potential Issue
After installation is successful, the script must call the resync function in order to build the table.  If this does not happen, then the proper results won't be seen.

Compatibility Notes
This mod was tested on SMF 2.0.9, but should work on SMF 2.1 Beta 1, as well as SMF 2.0 and up.  SMF 1.x is not and will not be supported.

Changelog
The changelog can be viewed at XPtsp.com.

License
Copyright (c) 2015 - 2018, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Hj Ahmad Rasyid Hj Ismail

Congratulations! I haven't try this mod. But I always like mods that improve buddy and social systems in SMF. Keep it up.

Bigguy

Nice addition/change to SMF. Good work. :)

DSystem

Very good.
Translation to Portuguese Brazil in annex.

Some ideas for this mod:

1-Show miniaturara of the avatars in the list.
2-Show in the statistics "Top 10 most followed"


dougiefresh

#4
Uploaded v1.0a - July 17th, 2014
o Added Portuguese Brazil to the language mix.  No functionality change.  Thanks, DSystem!!

EDIT: Corrected release date...

samborabora

Quote from: dougiefresh on July 17, 2014, 07:24:21 PM
Quote from: samborabora on July 17, 2014, 04:54:11 PM
I can't quite remember if it was a script from here or just the one in the default theme, I split it apart so I could define separate styles for the links, but it works the same, here's the add link:
<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_add'], ' ', $context['member']['name'], '</a>
@samborabora: It should work.  I installed it on my clean localhost  forum and it worked just fine, but I didn't make any other modifications.....  Attach your Profile.template.php, as well as the Profile-Modify.php from Sources here so I can look at it....  (I don't think it's related to my mod, but if it is, I'll update the mod to correct it!)

@Everybody: The mod has been approved.  Please discuss the mod in this topic.  Thanks.

I've attached those two, if it's not related to the mod, I apologize, but I'm curious why the first version worked and then the second gave the blank screen, either way, I really appreciate you taking a look for me!

dougiefresh

I don't have any problems installing the Followers mod with the two template files you provided.  Where is the problem, exactly?  I need the file that's causing the problem, as well as where the problem is (line numbers are helpful)

dougiefresh

#7
Uploaded v1.1 - July 20th, 2014
o Fixed major issues with resync function
o Fixed major issue with adding/removing buddies
o Fixed some minor install issues with the Portuguese Brazil language files.
o Made some necessary alterations to set my changes off from the core buddy system.

EDIT: Corrected release date...

samborabora

Quote from: dougiefresh on July 20, 2014, 12:35:12 PM
I don't have any problems installing the Followers mod with the two template files you provided.  Where is the problem, exactly?  I need the file that's causing the problem, as well as where the problem is (line numbers are helpful)

I'm not sure what line it is as it doesn't actually give me an error, it just displays a white screen if the followers mod is installed and I click on the profile page's "add buddy(in this case it's renamed to follower but it's still just add buddy)" link. If I uninstall Followers, it adds the buddy and returns to the profile page as it should. With version 1 of Followers, it didn't display a white screen, but the added buddies didn't reflect in the followers list. In this version it just shows a white screen if I click an add buddy link.

dougiefresh

Uploaded v1.2 - June 21th, 2014
o Placed the new functions for the Followers into their own seperate file to try to reduce memory requirements.


samborabora

Quote from: dougiefresh on July 22, 2014, 03:45:50 AM
Uploaded v1.2 - June 21th, 2014
o Placed the new functions for the Followers into their own seperate file to try to reduce memory requirements.



This version is perfect, no white screen, all buddy profile link adds are reflected in Followers list. Dougie, what code can I use to put on my profile views page that will take the entire list of Followers I have, and place them one after another with a comma to separate them?

dougiefresh

#11
Uploaded v1.3 - July 23th, 2014
o Included SSI function ssi_getFollowers to pull the list of followers

EDIT: Corrected release date...

Hj Ahmad Rasyid Hj Ismail

@dougiefresh, any sample for portal block?

dougiefresh

#13
Uploaded v1.4 - July 27th, 2014
o Modified SSI function ssi_getFollowers to echo out results if changed...
o Added example code for ssi_getFollowers function in ssi_examples.php...

@ahrasis and @samborabora: Simple sample code can be found in ssi_examples.php....

EDIT: Corrected release date...

Hj Ahmad Rasyid Hj Ismail

Thanks for the updates...

samborabora

Quote from: dougiefresh on July 27, 2014, 07:24:51 PM
Uploaded v1.4 - June 27th, 2014
o Modified SSI function ssi_getFollowers to echo out results if changed...
o Added example code for ssi_getFollowers function in ssi_examples.php...

@ahrasis and @samborabora: Simple sample code can be found in ssi_examples.php....

Thanks, I've tried using this in profile.modify.php:
// Gets the whole followers list.
function ssi_getFollowers($include_banned = false, $output_method = 'echo')
{
global $smcFunc, $user_info, $scripturl;

$request = $smcFunc['db_query']('', '
SELECT m.real_name, m.id_member
FROM {db_prefix}followers AS f
INNER JOIN {db_prefix}members AS m ON (f.id_member = m.id_member)
WHERE f.follows = {int:user_id}' . ($include_banned ? ' AND m.is_activated < 10' : '') . '
ORDER BY m.real_name',
array(
'user_id' => (int) $user_info['id'],
)
);
$followers = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$followers[$row['id_member']] = $row['real_name'];
$smcFunc['db_free_result']($request);

if ($output_method <> 'echo')
return $followers;

foreach ($followers as $id => $name)
$followers[$id] = '<a href="' . $scripturl . '/index.php?action=profile;u=' . $id . '">' . $name . '</a>';
echo implode(',', $followers);
}


But it returns no results. Any ideas?

dougiefresh

#16
First, you don't need to include my code in Profile-Modify.php.  You should be able to include SSI.php, then be able to call that function.
EDIT: Edited to strike out first thing....

Second, have you tried to resync your followers table lately?  It's possible that it isn't populated with information....

Third, have you tried the ssi_examples.php in your browser to see if the included Followers works?

Fourth, how are you calling the function?
EDIT: I mean, please give the statement that you are using to call the function.

Fifth, I just noticed one line of code is wrong.....
Code (Find) Select
WHERE f.follows = {int:user_id}' . ($include_banned ? ' AND m.is_activated < 10' : '') . '
Code (Replace) Select
WHERE f.follows = {int:user_id}' . (!$include_banned ? ' AND m.is_activated < 10' : '') . '
Don't think it would make a difference, but still, it's wrong....  Yes, this line is in the original v1.4 mod, too.....  :-\

Arantor

Fifth: including SSI.php inside SMF's actual runtime is guaranteed to be a world of pain.

dougiefresh

 :o Great, I love giving bad advice....  O:) Struck out first thing 2 posts ago...  ::)

Arantor

It's not something you'd normally know to avoid but it's really not recommended since SSI.php can end up trying to re-bootstrap SMF *inside* SMF.

Advertisement: