Advertisement:

Author Topic: Option to post Anonymously on topics  (Read 33143 times)

Offline machinenoob

  • Semi-Newbie
  • *
  • Posts: 49
Option to post Anonymously on topics
« on: July 11, 2015, 10:21:14 PM »
Recently I was building a forum for a work project and the users must be able to post anonymously when they want.  I saw the anonymous board mod, but I didn't want to make the whole board anonymous, just the actual topic/post.  I took the code and modified it a little so that users can post the topic anonymously if they want.  More could be added and a mod with permissions could be made, but for now here is the solution.  Thanks to the original coders/developers.

In Modifications.english.php (located in Themes\Default\languages)

At the bottom BEFORE
Code: [Select]
?>
Paste this
Code: [Select]
$txt['post_anon'] = 'Post message anonymously';
In Post.template.php (located in Themes\Default)

AFTER this
Code: [Select]
// Finally, the submit buttons.
Paste this
Code: [Select]
echo '<br>'. $txt['post_anon'] .' <input type="checkbox" name="post_anon" />';
In Display.template.php (located in Themes\Default)

AFTER this
Code: [Select]
// Is visual verification enabled?
if ($context['require_verification'])
echo '
<strong>', $txt['verification'], ':</strong>', template_control_verification($context['visual_verification_id'], 'quick_reply'), '<br />';

echo '
<div class="quickReplyContent">
<textarea cols="600" rows="7" name="message" tabindex="', $context['tabindex']++, '"></textarea>
</div>

Paste this
Code: [Select]
<br>'. $txt['post_anon'] .' <input type="checkbox" name="post_anon" />

In Post.php (located in Sources)


AFTER this
Code: [Select]
// No errors as yet.
$post_errors = array();

Paste this
Code: [Select]
if (isset($_POST['post_anon']))
{
// Destroy the identifing user data
$user_info['username'] = 'Anonymous';
$user_info['name'] = 'Anonymous';
$user_info['email'] = '';
$user_info['id'] = 0;
}

//didn't try it, but if you change the $user_info['id'] = # to another number corresponding to a users number then it SHOULD take over the post.  So if you actually created an Anonymous account with a picture/profile and the ID (hover over a users name and you should see u=#) then that will show up so you dont' have a plain jane looking Guest post..hopefully 

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #1 on: July 27, 2015, 01:33:01 PM »
I'd like to create a mod using this concept/code, if you don't mind....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,122
  • Gender: Male
    • Kindred-999 on GitHub
Re: Option to post Anonymously on topics
« Reply #2 on: July 27, 2015, 01:42:47 PM »
I did have a mod -- which allowed configuration of the setting per board - I handed it off a while back...

I am not certain it is still supported.... but it was an open license, so, please feel free to fork it
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline machinenoob

  • Semi-Newbie
  • *
  • Posts: 49
Re: Option to post Anonymously on topics
« Reply #3 on: August 02, 2015, 12:41:56 PM »
after all this I figured that if i changed the Original MOD just a little it works the same and added some code.. however in the original MOD there is a FIX that needs to be implemented because it doesn't install it correctly.

Refer to the  original mod last page I stated the fix still needs to be done, I hope DougieFresh can do it... properly..

Thanks Dougie...

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">

<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>JMV290:AnonymousBoard</id>
<version>1.1</version>

<file name="$themedir/ManageBoards.template.php">
<operation>
<search position="before"><![CDATA[ <div id="count_posts_div">
<dl class="settings">
<dt>
<strong>', $txt['mboards_count_posts'], ':</strong><br />
<span class="smalltext">', $txt['mboards_count_posts_desc'], '</span><br />
</dt>
<dd>
<input type="checkbox" name="count" ', $context['board']['count_posts'] ? ' checked="checked"' : '', ' class="input_check" />
</dd>
</dl>
</div>';
]]></search>
<add><![CDATA[
//Anonymous Board Mod
echo '
<div id="anon_board_div">
<dl class="settings">
<dt>
<strong>', $txt['makeBoard_anonymous'], ':</strong><br />
<span class="smalltext">', $txt['mboards_anon_board_desc'], '</span><br />
</dt>
<dd>
<input type="checkbox" name="anonymous_board" ', $context['board']['anonymous_board'] ? ' checked="checked"' : '', ' class="input_check" />
</dd>
</dl>
</div>';

]]></add>
</operation>
</file>

<file name="$themedir/languages/Modifications.english.php">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[
$txt['makeBoard_anonymous']='Allow this board the option to post anonymous.';
$txt['Post_anonymous'] = '<b>Post anonymously</b>';
$txt['mboards_anon_board_desc'] = 'New replies and topics will be posted anonymously by default';

]]></add>
</operation>
</file>

<file name="$sourcedir/ManageBoards.php">
<operation>
<search position="before"><![CDATA[
'theme' => 0,
'profile' => 1,
'override_theme' => 0,
]]></search>
<add><![CDATA[
'anonymous_board' => 0,
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
$boardOptions['posts_count'] = isset($_POST['count']);
$boardOptions['override_theme'] = isset($_POST['override_theme']);
]]></search>
<add><![CDATA[
$boardOptions['anonymous_board'] = isset($_POST['anonymous_board']);
]]></add>
</operation>
</file>

<file name="$sourcedir/Subs-Boards.php">
<operation>
<search position="before"><![CDATA[
// Should the board theme override the user preferred theme?
if (isset($boardOptions['override_theme']))
{
$boardUpdates[] = 'override_theme = {int:override_theme}';
$boardUpdateParameters['override_theme'] = $boardOptions['override_theme'] ? 1 : 0;
}

]]></search>
<add><![CDATA[
  // Should the board allow anonymous posts?
if (isset($boardOptions['anonymous_board']))
{
$boardUpdates[] = 'anonymous_board = {int:anonymous_board}';
$boardUpdateParameters['anonymous_board'] = $boardOptions['anonymous_board'] ? 1 : 0;
}

]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
b.num_posts, b.num_topics, c.id_cat, c.name AS cat_name, c.cat_order, c.can_collapse
]]></search>
<add><![CDATA[
, b.anonymous_board
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
'prev_board' => $prevBoard
]]></search>
<add><![CDATA[
'anonymous_board' => $row['anonymous_board'],
]]></add>
</operation>
</file>

<file name="$sourcedir/Load.php">
<operation>
<search position="before"><![CDATA[
c.id_cat, b.name AS bname, b.description, b.num_topics, b.member_groups,
]]></search>
<add><![CDATA[
 b.anonymous_board,
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
// Load the membergroups allowed, and check permissions.
$board_info['groups'] = $row['member_groups'] == '' ? array() : explode(',', $row['member_groups']);
]]></search>
<add><![CDATA[
$context['anonymous_board'] = $row['anonymous_board'];

]]></add>
</operation>
</file>

<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA[
// Finally, the submit buttons.
]]></search>
<add><![CDATA[
// anonymous board mod
if ( $context['anonymous_board'] )
echo '<br>'. $txt['Post_anonymous'] .' <input type="checkbox" name="post_anon" />';

]]></add>
</operation>
</file>

<file name="$sourcedir/Post.php">
<operation>
<search position="before"><![CDATA[
// No errors as yet.
$post_errors = array();
]]></search>
<add><![CDATA[
// Anonymous board mod
if ( $context['anonymous_board'] && isset($_POST['post_anon']) )
{
// Destroy the identifing user data
$user_info['username'] = 'Anonymous';
$user_info['name'] = 'Anonymous';
$user_info['email'] = '';
$user_info['id'] = 0;
}

]]></add>
</operation>
</file>
<file name="$sourcedir/Who.php">
<operation>
<search position="before"><![CDATA[
if (!empty($board_ids))
{
$result = $smcFunc['db_query']('', '
SELECT b.id_board, b.name
FROM {db_prefix}boards AS b
WHERE {query_see_board}
AND b.id_board IN ({array_int:board_list})
]]></search>
<add><![CDATA[
AND b.anonymous_board = 0
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if (!empty($topic_ids))
{
$result = $smcFunc['db_query']('', '
SELECT t.id_topic, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE {query_see_board}
]]></search>
<add><![CDATA[
AND b.anonymous_board = 0
]]></add>
</operation>
</file>
<file name="$themedir/Display.template.php">
<operation>
<search position="before"><![CDATA[ <div class="quickReplyContent">
<textarea cols="600" rows="7" name="message" tabindex="', $context['tabindex']++, '"></textarea>
</div>
]]></search>
<add><![CDATA[';

if ( $context['anonymous_board'] )
echo '<br>'. $txt['Post_anonymous'] .' <input type="checkbox" name="post_anon" />';

echo '
]]></add>
</operation>
</file>

</modification>

here is the CACHE fix for it, I give all credit to the original modder.

http://www.simplemachines.org/community/index.php?topic=204149.msg3380492#msg3380492

Thanks

Offline samk2824

  • Newbie
  • *
  • Posts: 8
Re: Option to post Anonymously on topics
« Reply #4 on: August 18, 2015, 10:28:41 AM »
Thank you for sharing this amazing trick Over Here. May I know Any how it would be applied on facebook too or not ? 8)

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,122
  • Gender: Male
    • Kindred-999 on GitHub
Re: Option to post Anonymously on topics
« Reply #5 on: August 18, 2015, 12:10:22 PM »
??? ??? ???


What?


What does this thread have to do with facebook in any way, shape or form?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Antes

  • Evil Black Cat
  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,649
  • Gender: Male
  • Black cat rulz!
    • Antes on GitHub
    • merta on LinkedIn
    • @antesistan on Twitter
    • Lunarfall
Re: Option to post Anonymously on topics
« Reply #6 on: August 18, 2015, 12:59:21 PM »
??? ??? ???


What?


What does this thread have to do with facebook in any way, shape or form?

Spam ?
Active Project(s): [ SimpleDesk ] # [ Lunarfall ] # [ CoreStore ]

Past Project(s): [ ezPortal ]

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #7 on: August 18, 2015, 06:24:14 PM »
Thank you for sharing this amazing trick Over Here. May I know Any how it would be applied on facebook too or not ? 8)
I'm going to answer this INCREDIBLY STUPID question....  Facebook is not a forum, so no, this cannot be applied to Facebook in any form or fashion.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline RVB

  • Semi-Newbie
  • *
  • Posts: 10
  • Gender: Male
    • RVB
Re: Option to post Anonymously on topics
« Reply #8 on: August 30, 2015, 04:09:16 AM »
Is this working for every kind of forum ? (Example : forumactif)

Thank you for sharing this amazing trick Over Here. May I know Any how it would be applied on facebook too or not ? 8)

Rofl thank you for you're amazing spam message, but facebook is not a forum.
You think you can modify the code of facebook ?  :laugh:

Offline Desgu

  • Newbie
  • *
  • Posts: 1
Re: Option to post Anonymously on topics
« Reply #9 on: October 19, 2015, 04:42:06 AM »
Thanks !!! Finally what I was looking for a while!!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #10 on: December 10, 2015, 04:04:36 AM »
Here's a little update on the mod I'm writing that's based on this tip:
I finally started on this mod a few days ago.  I got to thinking that there are plenty of people that would rather be nasty to other people given the possibility of anonymity using this mod, so I'm writing code so that there is a membergroup permission to use the "post anonymous" feature, as well as a "see who posted anonymously" (SWPA) permission.  The SWPA permission allows those with the permission to see which member made the post.  In addition, the original poster can see which posts they made.  All anonymous posts that can be seen by the original post and people with the SWPA permission have a little ghosty beside the poster's name.  The post can even be made un-anonymous easily....  I haven't "fixed" the message index or board index, and there are plenty of other things to "fix" so that everything is visible to the right people....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,122
  • Gender: Male
    • Kindred-999 on GitHub
Re: Option to post Anonymously on topics
« Reply #11 on: December 10, 2015, 07:07:00 AM »
dougiefresh...

one of the things that I did with the original anonymous mod was completely remove the poster information (with the exception of the IP)

this is actually a critical ability  because the point of many anonymous post boards is to enable the user to post without fear of ADMIN retribution.  Allowing a permission to bypass the anonymous might work for some uses of the anon-post - but ignores (what I consider) the main reason for using it. ;)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #12 on: December 10, 2015, 08:03:17 PM »
Ah.... Okay, away with the SWPA permission, then.  But the original poster can see his/her own anonymous posts in order to modify them is okay, right?
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: Option to post Anonymously on topics
« Reply #13 on: December 10, 2015, 08:09:53 PM »
It really depends on the interpretation, 'ya know? At least it's my view...

Some paranoia dudes will want a completely anonymous post, no user no IP no nothing (which would prevent also the author from editing own post). Totally ninja! :)
 I (as an admin) would never allow a user to post anonymously from the admin (as Kindred suggests) so that permission for me would be gold!

You need to analyze your "audience" and establish a method ;)
/2 cents
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Online Steve

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 3,942
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: Option to post Anonymously on topics
« Reply #14 on: December 11, 2015, 09:16:24 AM »
... the point of many anonymous post boards is to enable the user to post without fear of ADMIN retribution ...

Then what's the point of owning/running a board? I can't imagine an admin allowing users to freely post without any expectation of control unless maybe one is running an intentional flame war forum. I just can't understand this reasoning. jmo
Please do not PM me for support.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,122
  • Gender: Male
    • Kindred-999 on GitHub
Re: Option to post Anonymously on topics
« Reply #15 on: December 11, 2015, 09:41:05 AM »
Oh, we used it quite constructively...

we had one anonymous board for users to vent - without fear of repercussion or retaliation from the target of the vent - even if it was directed at an admin.

I see no issue with the permission, per say -- but having the ability to make something completely anonymous seems important to me as well.
(with the exception of the IP address -- since I always left SOMETHING in place in case some law enforcement came around at some future date -- so, I guess I COULD still have tracked the user by IP)

(and yes, in my original mod, that did mean that the user could nor edit the post after it was made.)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Online Steve

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 3,942
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: Option to post Anonymously on topics
« Reply #16 on: December 12, 2015, 12:50:20 PM »
we had one anonymous board for users to vent

Ah. That makes sense. :)
Please do not PM me for support.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #17 on: December 12, 2015, 06:01:06 PM »
Hmmm....  Well, I guess I could put a switch-thingy in Settings.php to close the "i saw you posted anonymously" loophole (or cancel it out)....  But I'm not entirely fond of the idea of totally anonymous posting as a default, either....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,122
  • Gender: Male
    • Kindred-999 on GitHub
Re: Option to post Anonymously on topics
« Reply #18 on: December 12, 2015, 07:20:04 PM »
that's fair
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #19 on: December 12, 2015, 07:34:13 PM »
I'll make an admission: I'm doing this one because it looks like it could be fun.....  :P Yes, I have a weird definition of the word "fun"  ::)  I really don't know anybody who wants this mod, but I'm writing it anyway....

Off-topic: Oh boy, the profile area is such fun..... :P
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #20 on: December 25, 2015, 01:42:48 PM »
Tackled all challenges that this mod threw my way...  Now it's up for approval at Post Anonymously In Topics and, if you really want it this badly, you can get it from my website XPtsp.com!
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #21 on: March 17, 2016, 08:58:20 PM »
For those interested, my Post Anonymously In Topic mod has been approved.....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline trilok

  • Newbie
  • *
  • Posts: 3
Re: Option to post Anonymously on topics
« Reply #22 on: March 21, 2016, 04:40:13 AM »
Make Anonymous link on the question page.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #23 on: March 21, 2016, 04:58:56 AM »
Make Anonymous link on the question page.
I don't understand.  What "question page"?
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline JMV290

  • Jr. Member
  • **
  • Posts: 120
  • Gender: Male
    • Boyah Forums
Re: Option to post Anonymously on topics
« Reply #24 on: March 30, 2016, 05:09:23 PM »
I did have a mod -- which allowed configuration of the setting per board - I handed it off a while back...

I am not certain it is still supported.... but it was an open license, so, please feel free to fork it
Kind of a late reply, but I was the one who took it over.

Unfortunately, I got stuck on a bug that happened about 5-10% of the time (I forget what happened) and the post didn't actually work. I got caught up with some work in my final semester of school and never got back around to fixing it.  There had been a few revisions of SMF after that point and I don't think the mod even works with the newer ones, but someone released a version that works better at some point afterwards.

Offline PyroTech03

  • Semi-Newbie
  • *
  • Posts: 20
  • Gender: Male
    • @pyrotech03 on Twitter
    • Obtenebration Network
Re: Option to post Anonymously on topics
« Reply #25 on: October 20, 2016, 03:11:30 AM »
Getting an error on this mod if anyone is still updating/watching....

Quote
The database value you're trying to insert does not exist: anonymous

I get that when someone tries to activate.  Running smf 2.0.11
YouTube personality PyroTech03 http://www.youtube.com/pyrotech03stream [nofollow]

Owner of Obtenebration Network, home for YouTube gaming content creators and fans! http://www.obten.net [nofollow]

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Option to post Anonymously on topics
« Reply #26 on: October 20, 2016, 06:50:13 AM »
Yup, still watching this thread....  The proper place to report bugs in my bug is here.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!