Page 1 of 2

Users are allowed to moderate their own topics

Posted: Mon Sep 29, 2008 6:41 pm
by Seether
Hi,

I'm looking für a mod (a snippet) or at least some hints to the following situation:
A User should moderate (in a certain forum) his own topics. The idea is to use a forum as a place for user blogs. Some users like smalltalk others don't. So with this modification it's up to the user to watch his topic.


S.

Re: Users are allowed to moderate their own topics

Posted: Wed Jan 13, 2010 7:50 am
by dontcoz
yes, pls. i've been looking for something like that everywhere:)
it existed for phpBB2 but for some reason not for 3.

Re: Users are allowed to moderate their own topics

Posted: Sun Jan 31, 2010 1:46 am
by dontcoz
and by moderate, having an option to delete posts in their own topics would suffice, nothing more. lock own topics already exists.

Re: Users are allowed to moderate their own topics

Posted: Tue Mar 30, 2010 6:33 pm
by Jarode
I'm looking for a such MOD too. :P

Re: Users are allowed to moderate their own topics

Posted: Fri Jul 30, 2010 3:24 am
by tonia
Hello!
I also need this, I want to be able to have users be able to move their own topics. Any say on if anybody is working on this?

Re: Users are allowed to moderate their own topics

Posted: Sat Jul 31, 2010 11:57 am
by BadBlock
Interested. Subscribed.

Re: Users are allowed to moderate their own topics

Posted: Tue Aug 03, 2010 2:13 am
by Jarode
What's new ? :)

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 12:55 pm
by Sonya*
I have created a quick mod that works for me. This mod allows the topic starter to edit and delete all posts in the own topics. This permission is local and can be assigned to any user in combination with any forum.

I appreciate any feedback, if somebody would give it a try.

##############################################################
## MOD Title: Moderate own topics
## MOD Author: Sonya
## MOD Description: This mod allows you assign permission to moderate
## (edit and delete) posts in the topics where the user is the
## topic starter.
## MOD Version: 1.1
##
## Installation Level: Moderate
## Installation Time: 10 Minutes
## Files To Edit: viewtopic.php, posting.php
##############################################################
# Before Installing This MOD, You Should Back Up All Related Files
##############################################################
## History:
## 1.1 - 20110324 - Fix check for edit time.
## 1.0 - 20100819 - Initial release.
##############################################################

#
#-----[ DIY INSTRUCTIONS ]--------------------------
#
Create a file addpermission.php on your local disk and paste the code below into it:

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Setup $auth_admin class so we can add permission options
include($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
$auth_admin = new auth_admin();

// Add permissions
$auth_admin->acl_add_option(array(
    'local'     => array('f_author'),
));
?>
#
#-----[ COPY ]------------------------------------------
#
addpermission.php -> /

#
#-----[ DIY INSTRUCTIONS ]--------------------------
#
Call the file addpermission.php from your browser, e. g. http://www.myforum.com/addpermission.php. The new permission will be created. Delete the file addpermission.php, you do not need it any more.

#
#-----[ OPEN ]------------------------------------------
#
language/en/acp/permissions_phpbb.php

#
#-----[ FIND ]------------------------------------------
#

Code: Select all

	'acl_f_noapprove'	=> array('lang' => 'Can post without approval', 'cat' => 'misc'),
#
#-----[ AFTER, ADD ]------------------------------------
#

Code: Select all

	'acl_f_author'	        => array('lang' => 'Can moderate own topics', 'cat' => 'misc'),

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

#
#-----[ FIND ]------------------------------------------
#

Code: Select all

	$postrow = array(
#
#-----[ BEFORE, ADD ]------------------------------------------
#

Code: Select all

        if ($auth->acl_get('f_author', $forum_id) && $user->data['user_id'] == $topic_data['topic_poster']) {
            $edit_allowed = true;
            $delete_allowed = true;
        }
#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#

Code: Select all

		if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id))
#
#-----[ REPLACE WITH ]----------------------------------
#

Code: Select all

		if ($user->data['is_registered'] && ($auth->acl_gets('f_edit', 'm_edit', $forum_id) ||  ($auth->acl_get('f_author', $forum_id) && $post_data['topic_poster'] == $user->data['user_id'])))
#
#-----[ FIND ]------------------------------------------
#

Code: Select all

		trigger_error('CANNOT_EDIT_TIME');
#
#-----[ REPLACE WITH ]----------------------------------
#

Code: Select all

		            if (!($auth->acl_get('f_author', $forum_id))) {
		trigger_error('CANNOT_EDIT_TIME');
            }
#
#-----[ FIND ]------------------------------------
#

Code: Select all

	if ($user->data['user_id'] != $post_data['poster_id'])
#
#-----[ REPLACE WITH ]----------------------------------
#

Code: Select all

	if ($user->data['user_id'] != $post_data['poster_id']  && !($auth->acl_get('f_author', $forum_id) && $user->data['user_id'] == $post_data['topic_poster']))
#-----[ FIND ]------------------------------------
#

Code: Select all

	if ($user->data['user_id'] != $post_data['poster_id'])
#
#-----[ REPLACE WITH ]----------------------------------
#

Code: Select all

	if ($user->data['user_id'] != $post_data['poster_id']  && !($auth->acl_get('f_author', $forum_id) && $user->data['user_id'] == $post_data['topic_poster']))
#
#-----[ FIND ]------------------------------------
#

Code: Select all

	if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))


#
#-----[ REPLACE WITH ]----------------------------------
#

Code: Select all

	if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) ||  ($auth->acl_get('f_author', $forum_id) && $user->data['user_id'] == $post_data['topic_poster']))
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#

To test the permission, go to the admin panel and assign the user a forum permission "Can moderate own topics" found under Misc permissions.

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 2:15 pm
by BadBlock
So it does not work for groups, is that right?

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 2:29 pm
by Sonya*
BadBlock wrote:So it does not work for groups, is that right?
It works as group's forum permission. You can set the permission for the group(s) on the chosen forum.

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 3:04 pm
by BadBlock
Wow!

BTW it seems that addpermission.php file contents is incomplete.

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 3:10 pm
by Sonya*
BadBlock wrote:Wow!

BTW it seems that addpermission.php file contents is incomplete.
It is complete. If you miss ?> at the end, you do not need it :) This is optional in PHP and, if included, can cause problems with trailing whitespaces in files
The closing tag of a PHP block at the end of a file is optional
http://de2.php.net/basic-syntax.instruction-separation

EDIT: I have added the closing tag into my instructions to avoid confusion. However, you still do not need it ;)

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 7:59 pm
by Jarode
Great ! :P
If one day I want to uninstall this MOD, how to remove the permission added by addpermision.php ?
Thanks

Re: Users are allowed to moderate their own topics

Posted: Thu Aug 19, 2010 10:34 pm
by tonia
what about being able to move your own topic?
(on one forum of my board, users want to be able to move their topics of items they want to give away for free to a subforum of 'taken items' when they have already given the items away

Re: Users are allowed to moderate their own topics

Posted: Fri Aug 20, 2010 1:57 am
by dontcoz
why not submit it for validation sonya? this is awesome btw, thank you for posting it here:)