Am I ignoring this user (on profiles page)

Started by samborabora, August 22, 2014, 10:56:53 AM

Previous topic - Next topic

samborabora

Quote from: ‽ on August 22, 2014, 01:07:58 PM
You need to globalise it in whichever function you are trying to use it, before you try to use it.

Yep, it's going to be when I'm viewing a members profile, so it's in:

Profile-View.php
function summary($memID)
{
global $context, $memberContext, $txt, $modSettings, $user_info, $user_profile, $sourcedir, $scripturl, $smcFunc;


This follow/unfollow code just needs to be on anyones profile summary page taht isn't mine (hence the check if the user owner).

if (!in_array($context['id_member'], $user_info['ignoreusers']))

Would that be another way to test?

samborabora

Hmm, you're right, I get:

8: Undefined variable: user_info

and:

2: in_array() expects parameter 2 to be array, null given

Which is strange, as I'm sure user_info is in the global? Can I load it into the template before the ignore section?

Arantor

Are you modifying the summary template or some other template? You have to declare global in *each* template you want to use it in.

samborabora

Aha! Now this works! I just did:

function template_summary()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;


and added:
function template_summary()
{
global $context, $user_info, $settings, $options, $scripturl, $modSettings, $txt;


Which is great, but apparently, this link:
<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '">

Isn't functional. Looks okay to me? Can see why this shouldn't work on the profile page?

Arantor

The link's wrong. It needs to point back to *your* profile because it's your ignore list that's being changed. And it is the profile of the person that you're looking at as the person you're removing from the URL.

<a href="', $scripturl, '?action=profile;u=', $user_info['id'], ';area=lists;sa=ignore;remove=', $context['member_id'], ';', $context['session_var'], '=', $context['session_id'], '">

samborabora

Quote from: ‽ on August 22, 2014, 02:15:38 PM
The link's wrong. It needs to point back to *your* profile because it's your ignore list that's being changed. And it is the profile of the person that you're looking at as the person you're removing from the URL.

<a href="', $scripturl, '?action=profile;u=', $user_info['id'], ';area=lists;sa=ignore;remove=', $context['member_id'], ';', $context['session_var'], '=', $context['session_id'], '">

Almost! This works:
<a href="', $scripturl, '?action=profile;area=lists;sa=ignore;remove=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">

Now then, for the final trick! I would adore it if it could redirect back to the profile page instead of going to the ignore list. This would be the absolute icing on the cake and I'll die happy (until the next ridiculous mod :p ) So, how can I have it go back to the profile I'm viewing after clicking unignore?

Arantor

Profile-Modify.php

// Removing a member from the ignore list?
if (isset($_GET['remove']))
{
checkSession('get');

// Heh, I'm lazy, do it the easy way...
foreach ($ignoreArray as $key => $id_remove)
if ($id_remove == (int) $_GET['remove'])
unset($ignoreArray[$key]);

// Make the changes.
$user_profile[$memID]['pm_ignore_list'] = implode(',', $ignoreArray);
updateMemberData($memID, array('pm_ignore_list' => $user_profile[$memID]['pm_ignore_list']));

// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
}


Change the redirectexit to:
if ((int) $_GET['remove'] > 0)
redirectexit('action=profile;u=' . ((int) $_GET['remove']));
else
redirectexit('action=profile');


That'll fix removing a user from redirection, can't vouch for the add-to-ignore list since that's not a standard function. I seem to recall making a mod for it years ago but I don't remember. But similer sort of deal, you'd find the redirectexit call in it and change it to point to the user id that you've added rather than the user's own.

samborabora

WOW!!!! That works!!!

// Removing a member from the ignore list?
if (isset($_GET['remove']))
{
checkSession('get');

// Heh, I'm lazy, do it the easy way...
foreach ($ignoreArray as $key => $id_remove)
if ($id_remove == (int) $_GET['remove'])
unset($ignoreArray[$key]);

// Make the changes.
$user_profile[$memID]['pm_ignore_list'] = implode(',', $ignoreArray);
updateMemberData($memID, array('pm_ignore_list' => $user_profile[$memID]['pm_ignore_list']));

// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
if ((int) $_GET['remove'] > 0)
redirectexit('action=profile;u=' . ((int) $_GET['remove']));
else
redirectexit('action=profile');
}


I am SOOOO incredibly grateful to you guys for ALL of your help, thank you SO MUCH!! :D :D

(as you can tell, when something works I experience euphoria, and this is why i love SMF coding as a hobby :D )

Arantor

I know that euphoria - it's why I'm still here after 5 years.

Hj Ahmad Rasyid Hj Ismail

Congratulations again. You are now in good hand I suppose. :)

samborabora

Quote from: ahrasis on August 23, 2014, 12:19:29 AM
Congratulations again. You are now in good hand I suppose. :)

It's amazing, I feel truly lucky to be in the company of such experienced geniuses, all of you ;) Believe it or not, everything I've set out to do so far has actually happened and there's only a few ideas left to get right, after a year of fiddling! :D

Arantor

The real secret is putting in the effort to make some sense of what's going on. The only difference between you and me is that I've just been doing it longer.

If you're willing to put the effort in to learn, few things will really be hidden from you in the long run. Motivation to be awesome is over half of actually being awesome. You'll get there, and I know that because I'm already seeing the evidence of it.

samborabora

Quote from: ‽ on August 23, 2014, 12:56:07 AM
The real secret is putting in the effort to make some sense of what's going on. The only difference between you and me is that I've just been doing it longer.

If you're willing to put the effort in to learn, few things will really be hidden from you in the long run. Motivation to be awesome is over half of actually being awesome. You'll get there, and I know that because I'm already seeing the evidence of it.

Absolutely, I totally agree. I don't do this for profit or even to expect a forum to take off, it's entirely for the sport of it that I enjoy. That is why I always post working code, for others to benefit from, I just enjoy being educated in the workings of SMF and PHP, since there's no reason to do it otherwise, for me.

Everytime I get help with something, I read it and learn from it. I'm not always quick enough to get it right the next time, but slowly I'm seeing how to do things for myself, believe it or not, there's been three or four times as many things I've done for myself in-between help topics, but I couldn't have done that a year ago, and it's thanks to you guys and your amazing help. I really appreciate it! :D

Arantor

Yup. I wrote most of my mods specifically to get to know SMF better, not because I needed them, and once you get a handle on how SMF works properly, the only barriers to doing what you want with it are the ones you place upon yourself.

For example, I'm currently building a gallery, which in itself is something I've never done but the principle is not significantly different to handling attachments (which I had to learn how SMF did, so I could do it in SimpleDesk), but I decided to be bold and set myself the rule of not making any file edits to SMF if *at all possible*. And so far, it's paying off. It's required some extreme creativity in getting around some of SMF's limitations but it's entirely possible with a bit of thought.

You're getting there, keep at it :)

samborabora

Quote from: ‽ on August 23, 2014, 10:23:50 AM
Yup. I wrote most of my mods specifically to get to know SMF better, not because I needed them, and once you get a handle on how SMF works properly, the only barriers to doing what you want with it are the ones you place upon yourself.

For example, I'm currently building a gallery, which in itself is something I've never done but the principle is not significantly different to handling attachments (which I had to learn how SMF did, so I could do it in SimpleDesk), but I decided to be bold and set myself the rule of not making any file edits to SMF if *at all possible*. And so far, it's paying off. It's required some extreme creativity in getting around some of SMF's limitations but it's entirely possible with a bit of thought.

You're getting there, keep at it :)

Thanks for the boost, mate, really appreciate it. Will be keen to see your gallery when it's complete!

Advertisement: