Option to post Anonymously on topics

Started by machinenoob, July 11, 2015, 10:21:14 PM

Previous topic - Next topic

machinenoob

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
?>

Paste this
$txt['post_anon'] = 'Post message anonymously';

In Post.template.php (located in Themes\Default)

AFTER this
// Finally, the submit buttons.

Paste this
echo '<br>'. $txt['post_anon'] .' <input type="checkbox" name="post_anon" />';

In Display.template.php (located in Themes\Default)

AFTER this
// 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
<br>'. $txt['post_anon'] .' <input type="checkbox" name="post_anon" />


In Post.php (located in Sources)


AFTER this
// No errors as yet.
$post_errors = array();


Paste this

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 

dougiefresh

I'd like to create a mod using this concept/code, if you don't mind....

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

machinenoob

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...

<?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

samk2824

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

Kindred

??? ??? ???


What?


What does this thread have to do with facebook in any way, shape or form?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Antes

Quote from: Kindred on August 18, 2015, 12:10:22 PM
??? ??? ???


What?


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

Spam ?

dougiefresh

Quote from: samk2824 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)
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.

RVB

Is this working for every kind of forum ? (Example : forumactif)

Quote from: samk2824 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)

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:

Desgu

Thanks !!! Finally what I was looking for a while!!

dougiefresh

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....

Kindred

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. ;)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

dougiefresh

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?

margarett

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

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

Steve

Quote from: Kindred on December 10, 2015, 07:07:00 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
DO NOT pm me for support!

Kindred

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.)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Steve

DO NOT pm me for support!

dougiefresh

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....

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

dougiefresh

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

Advertisement: