1 (edited by bingiman 2008-01-20 20:04)

Topic: Excluding myself from a particular feature I am using.

In my viewtopic I added a small feature that simply uses javascript to insert some text that would allow you to insert @usename. The problem I have is that I need to find out how I can make it so that I myself can't address the feature to myself. I have posted the code below and it is the code after the username while in viewtopic:

$username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a> <a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[b][color=red]@'.pun_htmlspecialchars($cur_post['username']).'[/color][/b] - \',\'\');" rel="nofollow" title="'.$lang_topic['Address Post'].'"><img style="vertical-align: middle;" src="'.$pun_config['o_base_url'].'/img/address_to.gif" alt="'.$lang_topic['Address To'].'" title="'.$lang_topic['Address To'].'" /></a>';

2

Re: Excluding myself from a particular feature I am using.

if ($cur_post['username'] != $pun_user['username'])
{
    $username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a> <a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[b][color=red]@'.pun_htmlspecialchars($cur_post['username']).'[/color][/b] - \',\'\');" rel="nofollow" title="'.$lang_topic['Address Post'].'"><img style="vertical-align: middle;" src="'.$pun_config['o_base_url'].'/img/address_to.gif" alt="'.$lang_topic['Address To'].'" title="'.$lang_topic['Address To'].'" /></a>';
}

Re: Excluding myself from a particular feature I am using.

Well, what that does is it makes ever user have the same name.

Re: Excluding myself from a particular feature I am using.

You simply append

 <a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[b][color=red]@'.pun_htmlspecialchars($cur_post['username']).'[/color][/b] - \',\'\');" rel="nofollow" title="'.$lang_topic['Address Post'].'"><img style="vertical-align: middle;" src="'.$pun_config['o_base_url'].'/img/address_to.gif" alt="'.$lang_topic['Address To'].'" title="'.$lang_topic['Address To'].'" /></a>

to the original value of $username only when they're not the same user.

Re: Excluding myself from a particular feature I am using.

Is this correct:

        $username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a> ';

        if ($cur_post['username'] != $pun_user['username']) {
        $username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a> <a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[b][color=red]@'.pun_htmlspecialchars($cur_post['username']).'[/color][/b] - \',\'\');" rel="nofollow" title="'.$lang_topic['Address Post'].'"><img style="vertical-align: middle;" src="'.$pun_config['o_base_url'].'/img/address_to.gif" alt="'.$lang_topic['Address To'].'" title="'.$lang_topic['Address To'].'" /></a>';
        }else{
        $username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a>';
        }

Re: Excluding myself from a particular feature I am using.

Yes, except that first line is completely not required. And you could do it with appending instead, which is what I was talking about. But your way should work fine.

7

Re: Excluding myself from a particular feature I am using.

bingiman wrote:

Well, what that does is it makes ever user have the same name.

Apologies. big_smile Forgot to include the else part. big_smile

Re: Excluding myself from a particular feature I am using.

Well, thank you very much Smartys. I removed the first line. I am learning slowly. smile