Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: dougiefresh on July 17, 2014, 04:17:53 PM

Title: Buddies With Me (formerly Followers)
Post by: dougiefresh on July 17, 2014, 04:17:53 PM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=3894)



BUDDIES WITH ME v2.2
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) - Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3894)



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 (http://www.simplemachines.org/community/index.php?topic=524878.0)

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 (http://www.xptsp.com/board/free-modifications/buddies-with-me/).

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.
Title: Re: Followers List
Post by: Hj Ahmad Rasyid Hj Ismail on July 17, 2014, 04:42:15 PM
Congratulations! I haven't try this mod. But I always like mods that improve buddy and social systems in SMF. Keep it up.
Title: Re: Followers List
Post by: Bigguy on July 17, 2014, 08:42:01 PM
Nice addition/change to SMF. Good work. :)
Title: Re: Followers List
Post by: DSystem on July 17, 2014, 11:29:58 PM
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"

Title: Re: Followers List
Post by: dougiefresh on July 18, 2014, 04:20:25 AM
Uploaded v1.0a - July 17th, 2014
o Added Portuguese Brazil to the language mix.  No functionality change.  Thanks, DSystem (http://www.simplemachines.org/community/index.php?action=profile;u=341618)!!

EDIT: Corrected release date...
Title: Re: Followers List
Post by: samborabora on July 18, 2014, 05:07:46 AM
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 (http://www.simplemachines.org/community/index.php?topic=525303.0).  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!
Title: Re: Followers List
Post by: 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)
Title: Re: Followers List
Post by: dougiefresh on July 20, 2014, 03:34:30 PM
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...
Title: Re: Followers List
Post by: samborabora on July 20, 2014, 04:38:44 PM
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.
Title: Re: Followers
Post by: 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.

Title: Re: Followers
Post by: samborabora on July 22, 2014, 01:22:32 PM
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?
Title: Re: Followers
Post by: dougiefresh on July 26, 2014, 08:49:35 PM
Uploaded v1.3 - July 23th, 2014
o Included SSI function ssi_getFollowers to pull the list of followers

EDIT: Corrected release date...
Title: Re: Followers
Post by: Hj Ahmad Rasyid Hj Ismail on July 26, 2014, 11:02:16 PM
@dougiefresh, any sample for portal block?
Title: Re: Followers
Post by: dougiefresh on July 27, 2014, 07:24:51 PM
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...
Title: Re: Followers
Post by: Hj Ahmad Rasyid Hj Ismail on July 28, 2014, 03:24:32 AM
Thanks for the updates...
Title: Re: Followers
Post by: samborabora on July 28, 2014, 07:35:12 AM
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?
Title: Re: Followers
Post by: dougiefresh on July 28, 2014, 05:12:13 PM
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.....  :-\
Title: Re: Followers
Post by: Arantor on July 28, 2014, 05:14:49 PM
Fifth: including SSI.php inside SMF's actual runtime is guaranteed to be a world of pain.
Title: Re: Followers
Post by: dougiefresh on July 28, 2014, 05:21:17 PM
 :o Great, I love giving bad advice....  O:) Struck out first thing 2 posts ago...  ::)
Title: Re: Followers
Post by: Arantor on July 28, 2014, 05:28:43 PM
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.
Title: Re: Followers
Post by: samborabora on July 28, 2014, 06:16:04 PM
Quote from: dougiefresh on July 28, 2014, 05:12:13 PM
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.....  :-\

I tried to call the SSI function in page, it didn't do anything, but then again I didn't think SSI was intended for use IN forum? The ssi_examples page works perfectly, but the code I gave you is what I tried in profile.template, and that's exactly what SSI Examples uses, so I don't know why it's not displaying on profile.template?
Title: Re: Followers
Post by: dougiefresh on July 28, 2014, 06:59:07 PM
Uploaded v1.5 - July 28th, 2014
o Moved ssi_getFollowers function from SSI.php to Subs-Followers.php....
o Modified SSI.php to include Subs-Followers.php...
o Fixed ssi_getFollowers function - function is 1st parameter is wrongly inverted
o Fixed all dates in the changelog, as they said June instead of July...



@samborabora: Include the Subs-Followers.php in your copy of Profile-Modify.php instead of the code....  If it still doesn't work, send me the Profile-Modify.php and Profile-Modify.template.php and that your using so I can see what is going on....  Those files are right, correct?
Title: Re: Followers
Post by: Hj Ahmad Rasyid Hj Ismail on July 28, 2014, 09:15:58 PM
dougiefresh, i like your enthusiasm. Maybe you could write or rewrite a better buddy/ies system that have:
1. Approval feature.
2. Block feature.
3. Option to maintain or remove current follow(add) and ignore buddy system.
4. Page for showing buddy/ies:
(a) approved - list of buddies (already approved)
(b) blocked - list of blocked members (cannot see each other's profile or post)
(c) followers - list of members that are folowing a user.
(d) following - list of members that a user follows.
(e) ignored - list of members that a user ignored but not blocked.
(f) request - a user current request to be added as buddy of other members that is still pending approval.
(g) requested - list of members that requested to be a buddy to a user.
5. A sample to call this inside a block or custom page.

Sorry if this is suggesting too much. ;)
Title: Re: Followers
Post by: samborabora on July 29, 2014, 09:07:30 AM
Quote from: dougiefresh on July 28, 2014, 06:59:07 PM
@samborabora: Include the Subs-Followers.php in your copy of Profile-Modify.php instead of the code....  If it still doesn't work, send me the Profile-Modify.php and Profile-Modify.template.php and that your using so I can see what is going on....  Those files are right, correct?

I've attached my file, I've put the words FOLLOWERS HERE where I need it to appear. Is including a php file the best way to do this? Maybe a variable like, say, $context['member']['followers'] could do this?
Title: Re: Followers
Post by: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo implode(',', $context['followers_list']);
Title: Re: Followers
Post by: samborabora on July 29, 2014, 02:23:02 PM
Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];

I appreciate the time you've taken to help me with this issue. I have done as you have suggested:
// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),
'page_title' => sprintf($txt['profile_of_username'], $memberContext[$memID]['name']),


And in the profile template:
echo '
<dt style="height: 20px;"></dt>
<div id="profefollowers"></div>
';

echo $context['followers_list'];
echo '
</dl>';


Unfortunately, all I get in the space where the followers should display is the word Array. I'm not sure what could have gone wrong, is there anything missing?
Title: Re: Followers
Post by: dougiefresh on July 29, 2014, 02:28:29 PM
Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];
Sorry, I edited the post 20 minutes after I posted....  It should read like this:
echo implode(',', $context['followers_list']);
Title: Re: Followers
Post by: samborabora on July 29, 2014, 02:37:51 PM
Quote from: dougiefresh on July 29, 2014, 02:28:29 PM
Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];
Sorry, I edited the post 20 minutes after I posted....  It should read like this:
echo implode(',', $context['followers_list']);

Wow. I am amazed. You actually coded an entire mod that successfully achieved everything I was lead to believe couldn't be done with SMF, and here it is, working perfectly!!! I'm truly blown away by this, and can't thank you enough for your dedication and talents for pulling this off. THANK YOU!!!

One last question!  ;D Can I put a space between the trailing comma of each result, so it's less user,user,user and more user, user, user? Thanks!
Title: Re: Followers
Post by: dougiefresh on July 29, 2014, 03:00:18 PM
Sure, replace this:
echo implode(',', $context['followers_list']);
with this:
echo implode(', ', $context['followers_list']);
That should work for ya....

You're welcome!
Title: Re: Followers
Post by: samborabora on July 29, 2014, 04:13:53 PM
Quote from: dougiefresh on July 29, 2014, 03:00:18 PM
Sure, replace this:
echo implode(',', $context['followers_list']);
with this:
echo implode(', ', $context['followers_list']);
That should work for ya....

You're welcome!

Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D
Title: Re: Followers
Post by: dougiefresh on July 29, 2014, 04:47:49 PM
Quote from: samborabora on July 29, 2014, 04:13:53 PM
Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D
LOL!!!  Have you moved your mouse over the usernames yet?  (chuckling)  Already done for ya!
Title: Re: Followers
Post by: samborabora on July 29, 2014, 05:00:45 PM
Quote from: dougiefresh on July 29, 2014, 04:47:49 PM
Quote from: samborabora on July 29, 2014, 04:13:53 PM
Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D
LOL!!!  Have you moved your mouse over the usernames yet?  (chuckling)  Already done for ya!

Ahh yes, it works perfectly on the Followers page, but I'd like the usernames to have links to profiles on the SSL include I'm using on the profile view template?
Title: Re: Followers
Post by: dougiefresh on July 29, 2014, 05:15:24 PM
Quote from: ahrasis on July 28, 2014, 09:15:58 PM
dougiefresh, i like your enthusiasm. Maybe you could write or rewrite a better buddy/ies system that have:
1. Approval feature.
2. Block feature.
3. Option to maintain or remove current follow(add) and ignore buddy system.
4. Page for showing buddy/ies:
(a) approved - list of buddies (already approved)
(b) blocked - list of blocked members (cannot see each other's profile or post)
(c) followers - list of members that are folowing a user.
(d) following - list of members that a user follows.
(e) ignored - list of members that a user ignored but not blocked.
(f) request - a user current request to be added as buddy of other members that is still pending approval.
(g) requested - list of members that requested to be a buddy to a user.
5. A sample to call this inside a block or custom page.

Sorry if this is suggesting too much. ;)
At some future point, I would probably be interested in discussing this, but right now, I've got 2 other kinda big mods that I've gotta get finished, as they got put aside about a year ago.....  Not to mention the bugs that people have been reporting....  :P

Quote from: samborabora on July 29, 2014, 05:00:45 PM
Ahh yes, it works perfectly on the Followers page, but I'd like the usernames to have links to profiles on the SSL include I'm using on the profile view template?
(Sigh)  The SSI function does link each follower to their profile page.  Try hovering your mouse cursor over any of the follower's username in the profile page you made....  I even double-checked (just now) to make sure that the link functions as intended....
Title: Re: Followers
Post by: samborabora on July 30, 2014, 05:06:07 AM
Quote from: dougiefresh on July 29, 2014, 05:15:24 PM
(Sigh)  The SSI function does link each follower to their profile page.  Try hovering your mouse cursor over any of the follower's username in the profile page you made....  I even double-checked (just now) to make sure that the link functions as intended....

I can confirm this, the ssi does link, but for some strange reason it doesn't on the include in the profile view?
Title: Re: Followers
Post by: dougiefresh on August 03, 2014, 01:29:45 PM
Attach your Profile.php and Profile.template.php and I'll see what's going on.  I assume you are using the latest Followers mod, right?
Title: Re: Followers
Post by: samborabora on August 03, 2014, 01:48:40 PM
Yes, 1.5, the SSI looks fine and has the links showing, it's just the embed of it that doesn't link, and it looks like an embed problem to me rather than the SSI.

Title: Re: Followers
Post by: dougiefresh on August 03, 2014, 06:38:07 PM
Quote from: samborabora on August 03, 2014, 01:48:40 PM
it looks like an embed problem to me rather than the SSI.
You are correct.  It's definitely a problem with the embed code.....  :o  Okay, what I forgot was that the link processing takes place AFTER the return statement, so yes, you won't get a list of links back to the profiles.  So we need to modify the Profile-View.php so that the links are created....

Look for this:
// Set a canonical URL for this page.
and insert this code before it:
// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="' . $scripturl . '/index.php?action=profile;u=' . $id . '">' . $name . '</a>';

Replace this:
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

with this:
$context += array(
'followers_list' => array(),

Hope this helps!

Attached is a clean copy of Profile-View.php with the modifications listed above....
Title: Re: Followers
Post by: samborabora on August 03, 2014, 06:52:50 PM
Quote from: dougiefresh on August 03, 2014, 06:38:07 PM
Quote from: samborabora on August 03, 2014, 01:48:40 PM
it looks like an embed problem to me rather than the SSI.
You are correct.  It's definitely a problem with the embed code.....  :o  Okay, what I forgot was that the link processing takes place AFTER the return statement, so yes, you won't get a list of links back to the profiles.  So we need to modify the Profile-View.php so that the links are created....

Look for this:
// Set a canonical URL for this page.
and insert this code before it:
// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="' . $scripturl . '/index.php?action=profile;u=' . $id . '">' . $name . '</a>';

Replace this:
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

with this:
$context += array(
'followers_list' => array(),

Hope this helps!

Attached is a clean copy of Profile-View.php with the modifications listed above....

Wow, I think we've finally gotten there!! I just changed it out so the scriptURL part wasn't in the link as it caused a superfluous
directory in the link, for some reason, works perfectly with this:

// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="index.php?action=profile;u=' . $id . '">' . $name . '</a>';


Well, that was everything I came for, bless you and all of your hard work, Dougie, I hope others find this as useful and amazing a mod as I have done!!
Title: Re: Followers
Post by: dougiefresh on August 03, 2014, 06:59:13 PM
You're welcome!
Title: Re: Followers
Post by: samborabora on August 04, 2014, 09:42:28 AM
Just one last question, I think either somehow along the line or it always was and I didn't notice, but the list is displaying MY followers list in everyone's profiles, as opposed to displaying everyone's individual followers via the SSI. I'm not sure what happened here, but I must have missed the most important part of the actual embed, lol! Is it possible to change the include so it shows the followers of whoever's profile you are viewing, rather than my (my being the logged in user's) own followers on the everyones profile pages?
Title: Re: Followers
Post by: dougiefresh on August 04, 2014, 10:44:56 AM
Uploaded v1.6 - August 4th, 2014
o Modified SSI function to accept user ID as a parameter # 3....




@samborabora: In Profile-View.php, you need to change this:
Code (Find This) Select
$followers = ssi_getFollowers(false, 'return');
to this:
Code (Replace With) Select
$followers = ssi_getFollowers(false, 'return', $memID);
That should get you what you're asking for....
Title: Re: Followers
Post by: samborabora on August 04, 2014, 02:00:20 PM
Quote from: dougiefresh on August 04, 2014, 10:44:56 AM
Uploaded v1.6 - August 4th, 2014
o Modified SSI function to accept user ID as a parameter # 3....




@samborabora: In Profile-View.php, you need to change this:
Code (Find This) Select
$followers = ssi_getFollowers(false, 'return');
to this:
Code (Replace With) Select
$followers = ssi_getFollowers(false, 'return', $memID);
That should get you what you're asking for....

At first it seemed to not function, but it's looking fine now! The problem seems to be that the followers table is screwed, even though I resynced it. All the of the previous followers/buddies are still there (since the buddy links on the profiles say stop following instead of add follower) but it says they have no followers. If I click Stop Following (which removes the buddy) and then click Add Follower, it shows under the followers. DId you change anything in the database for this version between this and the last? I have no idea why it's doing this, but since it's still a test environment, I can go through and just un-add and re-add all of the buddies for testing again, but for other users I'm not sure if the new version and the last are compatible? Either way, it's looking good now, thanks so much, Doug! I'll reiterate my thankful sentiments again to you once more!!
Title: Re: Followers
Post by: samborabora on August 05, 2014, 06:17:24 AM
I can confirm that it works, but after uninstalling 1.6 and reinstalling 1.6, it still doesn't recognize buddies added previous to installation. Which is strange, as I never actually remove the table, and I always resync. There was a 404 error after the redirection notice, but I just manually resynced, maybe that had something to do with the failure to find existing buddies?
Title: Re: Followers
Post by: dougiefresh on August 05, 2014, 05:09:35 PM
I'll need to look at the code again and see what's up, cause the only thing changed between v1.5 and v1.6 was the SSI.php function....
Title: Re: Followers
Post by: dougiefresh on August 06, 2014, 07:11:05 PM
Uploaded v1.7 - August 6th, 2014
o Modified resync code to remove buffering of member's buddies list while processing....
o Added some additional input validation code for adding and removing follower functions....

It looks like the resync function wasn't placing all the buddies into the table.  So I removed the part of the resync function that tried to minimize the number of database inserts calls.  This (for some reason) fixed the issue of the followers table not being sync'ed correctly.

As for the 404 issue, I can't reproduce it....
Title: Re: Followers
Post by: Phil De Quincy on August 06, 2014, 09:21:39 PM
I'm pleased that you decided to adapt the resync rode with buffering removal. This would be a useful feature.
Title: Re: Followers
Post by: samborabora on August 07, 2014, 01:11:26 AM
Quote from: dougiefresh on August 06, 2014, 07:11:05 PM
Uploaded v1.7 - August 6th, 2014
o Modified resync code to remove buffering of member's buddies list while processing....
o Added some additional input validation code for adding and removing follower functions....

It looks like the resync function wasn't placing all the buddies into the table.  So I removed the part of the resync function that tried to minimize the number of database inserts calls.  This (for some reason) fixed the issue of the followers table not being sync'ed correctly.

As for the 404 issue, I can't reproduce it....

The 404 is because it was sending me to http://MYSITE.com/admin/index.php?action=admin;area=maintain;sa=members instead of http://MYSITE.com/admin/index.php?area=maintain;sa=members;done=resyncfollowers i think, I need to take that supid pretty urls off, it's been fine up until now, but I think this is one of its boo boos.

I can confirm THIS WORKS!! :D :D :D Thank you, dougie!! Let's hope 1.7 is going gold! ;)
Title: Re: Followers
Post by: dougiefresh on August 11, 2014, 10:23:37 AM
Quote from: Phil De Quincy on August 06, 2014, 09:21:39 PM
I'm pleased that you decided to adapt the resync rode with buffering removal. This would be a useful feature.
Well, the buffering thingy was an attempt to not call the database function for EVERY member that had buddies.  So if you have 1,000 members with buddies, then the database insert function was called 1,000 times....  With the buffering thingy in there, it was only called 10 times (100 members per insert).  Removing the buffering thingy solves the problem of why it wasn't resyncing properly.....  If I can make it function properly, it's going back in for the reason I specified....

Quote from: samborabora on August 07, 2014, 01:11:26 AM
The 404 is because it was sending me to http://MYSITE.com/admin/index.php?action=admin;area=maintain;sa=members instead of http://MYSITE.com/admin/index.php?area=maintain;sa=members;done=resyncfollowers i think, I need to take that supid pretty urls off, it's been fine up until now, but I think this is one of its boo boos.
Interesting.  I betcha that if you look at the Pretty URLs support thread, lots of people have had issues with it.....  It's one of the reasons I don't (and won't) run Pretty URLs....

Quote from: samborabora on August 07, 2014, 01:11:26 AM
I can confirm THIS WORKS!! :D :D :D Thank you, dougie!! Let's hope 1.7 is going gold! ;)
Thank you very much for all your bug reports!
Title: Re: Followers
Post by: Arantor on August 11, 2014, 10:24:47 AM
Fairly sure you can disable pretty URLs just for action=admin.
Title: Re: Followers
Post by: DSystem on November 09, 2014, 10:15:56 AM
Small change in Brazil Portuguese translation. Was breaking the files Profile.portuguese_brazilian
Title: Re: Followers
Post by: dougiefresh on November 09, 2014, 03:13:12 PM
Uploaded v1.8 - November 9th, 2014
o Updated Brazilian Portuguese language by DSystem.

Thanks, DSystem!  I've included the changes in v1.8.  (Actually, it was the only change  :P )
Title: Re: Followers
Post by: dougiefresh on April 06, 2015, 04:52:41 PM
Uploaded v1.9 - January 16th, 2015
o License change to Simplified BSD.  No functionality change.

Uploaded v1.10 - April 6th, 2015
o Updated for SMF 2.1 Beta 1
Title: Re: Followers
Post by: Professor Sea on April 06, 2015, 09:16:22 PM
I will keep a close eye on this mod. This seems well suited to my needs...
Title: Re: Followers
Post by: dougiefresh on August 29, 2015, 09:53:44 AM
Uploaded v1.11 - August 29th, 2015
o Removed support for SMF 2.1 Beta 1
o Added support for SMF 2.1 Beta 2
o Fixed template so that MSN field isn't shown if the text string isn't defined.
Title: Re: Followers
Post by: Stanyy on September 04, 2015, 10:59:35 AM
Hi,
Users get a blank page when they visit the followers area of their profile. I have run the resync function a couple times. SMF 2.0.9
Title: Re: Followers
Post by: dougiefresh on September 04, 2015, 08:43:20 PM
NOTICE: This mod is going to be renamed to "Buddies With Me" to better reflect what it does (or rather, supposed to do), starting with Version 2.0....

@DSystem: Can you translate the attached file into Brazilian Portuguese for me?  I'd like to attach it to the new version.  Thanks!

@Stanyy:  I can't duplicate this complaint.  It shows up fine on my test forum.  When you say "blank page", I'm assuming you mean a completely white page, correct?  Or does it say "No one is following you"?
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 06:22:47 AM
Yes, it's a completely white page.
Title: Re: Followers
Post by: dougiefresh on September 05, 2015, 07:18:15 AM
Huh.... Probably an out-of-memory issue.  Let me see what I can do about rewriting the mod to deal with this issue....
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 07:54:34 AM
Quote from: dougiefresh on September 05, 2015, 07:18:15 AM
Huh.... Probably an out-of-memory issue.  Let me see what I can do about rewriting the mod to deal with this issue....

Ok thank you.

I just checked my followers table. Some members seem to have two instances. See attachment.
Title: Re: Followers
Post by: dougiefresh on September 05, 2015, 08:12:50 AM
The table is built so that each line in the table is basically "who is a buddy with who".  In other words, one line might indicate that I'm a buddy with you, and the next line might indicate that I'm a buddy with a different member.....  What I curious to know is how many buddies do people who get the blank screens have?
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 09:28:55 AM
Looks like everyone is getting the white screen. I just tested with a new member I created.

By the way, I noticed something stange when I sorted the 'follows' column in ascending order. One particular member seems to have budded me multiple times. I checked his entry in the members table and yup its all there.

Edit: Removed duplicate entries, ran resync function.... White screen remains.
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 09:49:26 AM
What I reported above looks like an SMF bug. May not be too important but hey.
If you use the "Add to Buddy List" form in index.php?action=profile;area=lists to add someone as buddy, it adds that persons ID to your list in the database regardless of whether that person was already in your list. This is exactly what the user in my example above was doing.
Title: Re: Followers
Post by: dougiefresh on September 05, 2015, 11:18:05 AM
Let me do some rewriting of the code.  It was next in line for an overhaul, but it just got moved up....

BTW, no, it is not a bug in SMF.  It is definitely a bug in my mod, cause I never thought that someone would repeatedly call the link like that.   ???
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 02:40:13 PM
Quote from: dougiefresh on September 05, 2015, 11:18:05 AM
Let me do some rewriting of the code.  It was next in line for an overhaul, but it just got moved up....

BTW, no, it is not a bug in SMF.  It is definitely a bug in my mod, cause I never thought that someone would repeatedly call the link like that.   ???

No, I wasn't referring to the white screen. I was referring to the multiple buddy instances in the database. It is definitely an SMF bug. The user in question hasn't logged in since I installed the mod, plus I also confirmed this flaw in my other forums. The url to the buddies area is www.example.com/index.php?action=profile;area=lists;sa=buddies;u=1 I only shortened it in my last post.

I probably shouldn't have brought it up in this post as it has nothing to do with this mod. Please kindly focus on the white screen thing. Thank you.
Title: Re: Followers
Post by: Stanyy on September 05, 2015, 02:53:42 PM
I just noticed multiple instances of this error in my error log:


[05-Sep-2015 14:05:58] PHP Parse error:  syntax error, unexpected ',' in /home/user/public_html/example.com/Themes/default/Followers.template.php on line 28
Title: Re: Followers
Post by: dougiefresh on September 05, 2015, 05:11:03 PM
Regarding the multiple template errors, I've fixed them for the next version, as well....  Even though fixing it MAY fix the white screen issue, I'm recoding that function so that memory issues won't be an issue, even if you're buddies with 9,000 people...  ::)

Regarding the duplicate lines in the table, that is a bug I wasn't aware of!  It is a good thing to fix bad bugs, so no worries about reporting it!  When a user is added as a buddy, the line associating the current user and the "user to be buddied" in the table.  Because there is no index, there is no way for MySQL to replace the line because there may be more than one line with the number.  And because multiple lines associated with the same user is permitted, assigned a column to the table to be index is a BAD idea!  The code in the next version checks to make sure that the "current user"/"buddied user" line isn't already there before attempting to insert a new line into the table....
Title: Re: Buddies With Me (formerly Followers)
Post by: dougiefresh on September 06, 2015, 12:40:23 PM
Uploaded v2.0 September 5th, 2015
o IMPORTANT: Name changed from "Followers" to "Buddies With Me"!
o Fixed issue where mod generated duplicate entries within the table.
o Modified template and source files to use SMF list-building code.
o Removed Brazilian Portugese due to multiple changes within the mod.




@DSystem: I've made several new changes to the English language file since last request.  They are attached to this post.  Can you translate the files into Brazilian Portuguese for me so that I can get them back into the mod?  Thanks!
Title: Re: Buddies With Me (formerly Followers)
Post by: Stanyy on September 06, 2015, 02:52:26 PM
Aye, this one works. Thank you very much.   :)
Title: Re: Buddies With Me (formerly Followers)
Post by: Diego Andrés on September 19, 2015, 10:31:22 PM
Hi, I'm getting this issue when adding someone as a buddy

Quote
?action=buddy;u=8;
2: mysql_free_result() expects parameter 1 to be resource, null given
File: */Sources/Subs-BuddiesWithMe.php
Line: 237

Notice the 8, but I'm also getting this error with any other user.

Thanks.
Title: Re: Buddies With Me (formerly Followers)
Post by: dougiefresh on September 21, 2015, 11:39:30 AM
Uploaded v2.1 - September 21st, 2015
o Fixed issue where variable used was null instead of database handle.
Title: Re: Buddies With Me (formerly Followers)
Post by: Diego Andrés on September 21, 2015, 03:21:16 PM
That was fast, thanks.