• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[InfisJSC] Topic (thread) starter's permissions 1.2.12

No permission to download
Extends topic starter's permissions, adds some functions of management for threads and posts

yavuz

Well-known member
#5
Hi infis, to troubleshoot a problem addon related I had to removed this addon. Now members which I set permissions for, are having permission problems. For instance, one user who had topic starter rights set, now belongs to a group which has moderator rights, also the user was given moderator permissons. Unfortunately the moderation tools don't show up anymore. I double checked but couldn't find a a problem on my side.
 

infis

Well-known member
#6
Strange... At plug-in removal any rights cannot be mentioned. Expansions only will cease to operate. Also there are no editings in templates or somewhere else. Original files XenForo Engine also do not change.
Therefore the situation which is described by you, is impossible as a result of work or plug-in removal.
I tend to that somewhere you have changed the rights by default for groups or for the user.
 

duderuud

Active member
#7
First of all, thanks for the plugin! Much appreciated!

I have a little problem though: When I enable your plugin my test forum gives me the following error:

Server Error
Call-time pass-by-reference has been deprecated
  1. XenForo_Application::handlePhpError() in XenForo/Autoloader.php at line 119
  2. XenForo_Autoloader::autoload() in XenForo/Autoloader.php at line 119
  3. XenForo_Autoloader->autoload() in XenForo/Application.php at line 858
  4. XenForo_Application::autoload() in XenForo/Application.php at line 397
  5. XenForo_Application::resolveDynamicClass() in XenForo/Model.php at line 189
  6. XenForo_Model::create() in XenForo/Controller.php at line 101
  7. XenForo_Controller->getModelFromCache() in XenForo/ControllerPublic/Thread.php at line 1617
  8. XenForo_ControllerPublic_Thread->_getPostModel() in XenForo/ControllerPublic/Thread.php at line 37
  9. XenForo_ControllerPublic_Thread->actionIndex() in XenForo/FrontController.php at line 310
  10. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  11. XenForo_FrontController->run() in /var/www/xf/index.php at line 13
Errorlog:
ErrorException: Call-time pass-by-reference has been deprecated - library/InfisJSC/TopicStarter/Model/Post.php:21

#0 /var/www/xf/library/XenForo/Autoloader.php(119): XenForo_Application::handlePhpError(8192, 'Call-time pass-...', '/var/www/xf/lib...', 21, Array)
#1 /var/www/xf/library/XenForo/Autoloader.php(119): XenForo_Autoloader::autoload()
#2 /var/www/xf/library/XenForo/Application.php(858): XenForo_Autoloader->autoload('InfisJSC_TopicS...')
#3 /var/www/xf/library/XenForo/Application.php(397): XenForo_Application::autoload('InfisJSC_TopicS...')
#4 /var/www/xf/library/XenForo/Model.php(189): XenForo_Application::resolveDynamicClass('XenForo_Model_P...', 'model')
#5 /var/www/xf/library/XenForo/Controller.php(101): XenForo_Model::create('XenForo_Model_P...')
#6 /var/www/xf/library/XenForo/ControllerPublic/Thread.php(1617): XenForo_Controller->getModelFromCache('XenForo_Model_P...')
#7 /var/www/xf/library/XenForo/ControllerPublic/Thread.php(37): XenForo_ControllerPublic_Thread->_getPostModel()
#8 /var/www/xf/library/XenForo/FrontController.php(310): XenForo_ControllerPublic_Thread->actionIndex()
#9 /var/www/xf/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#10 /var/www/xf/index.php(13): XenForo_FrontController->run()
#11 {main}
Any ideas how to solve this?
 
R

ragtek

Guest
#8
search inInfisJSC_TopicStarter_Model_Post for

$response = parent::canEditPost($post, $thread, $forum, &$errorPhraseKey, $nodePermissions, $viewingUser);


and replace it with

$response = parent::canEditPost($post, $thread, $forum, $errorPhraseKey, $nodePermissions, $viewingUser);

(THIS SHOULD ALSO BE REMOVED IN ALL OTHER parent calls
 

duderuud

Active member
#9
Thanks ragtek, changed the code but get the same error.

And removing it in all parent calls, can you tell me what that means? I'm no developer...(guess that's why your solution doesn't work now, I only changed that one line)

Edit: Weird...now it all seems to work fine ?
 

infis

Well-known member
#10
Call-time pass-by-reference has been deprecated
It's generated if use & before variable.
You may change this by remove symbol '&' from &$errorPhraseKey in all lines such as
Code:
$response = parent::canEditPost($post, $thread, $forum, &$errorPhraseKey, $nodePermissions, $viewingUser);
It in library/InfisJSC/TopicStarter/Model/Post.php and library/InfisJSC/TopicStarter/Model/Thread.php

Also you can add to php.ini:
Code:
allow_call_time_pass_reference = on
 
#16
I think there's a bug with this plugin that will let registered users see moderated messages on all forums, regardless of whether they started the thread or not.

As you can see here, the current user is not the thread starter.

I have ensured that "view moderated threads/posts" was set to no on all groups and nodes. When I disabled the plugin, the problem went away.

 

infis

Well-known member
#17
Hm. I test this situation with user test1 and test2. If user test1 post message and message is awaiting moderator approval, then user test2 is not view this message. Users test1 and test2 are in group Registered only.
If your user TestingTree is moderator, then it can view this message.
Check rights for user TestingTree. I can't confirm this bug.
 
#18
I already checked, he is not a moderator. I tested it by using an admin to make a post unapproved.

The only permission checked is Edit own thread, but the same problem happens if it is not set.

It must be a plugin problem because the problem disappears when I disable Topic Starters' Rights. If he was a moderator this problem wouldn't disappear if I disabled the plugin.







 
#19
I think getPermissionBasedPostFetchOptions is broken.

It will always say $response['moderated'] is true. When I set it to false, then regular users can't see everyone's moderated posts.

I don't know how to fix this.
 
#20
Oh I finally figured out how to fix it. This is my mod. I moved the defaults from the original function into the inherited function.

I think the issue is that the original function has a side effect so you can't call it 2 times.

Anyway great plugin. I just have a few suggestions.
  • Change "Any" to "Others", this way you can let someone edit/delete other posts, and if you want the "Any" feature, you can select "Self" and "Others". Otherwise it is impossible to only allow editing/deleting of other users' posts.
  • If a user cannot delete his own thread, make it so the first post cannot be deleted, because that will delete the thread.

PHP:
    public function getPermissionBasedPostFetchOptions(array $thread, array $forum, array $nodePermissions = null, array $viewingUser = null)
    {
        //$response = parent::getPermissionBasedPostFetchOptions($thread, $forum, $nodePermissions, $viewingUser);
        $this->standardizeViewingUserReferenceForNode($thread['node_id'], $viewingUser, $nodePermissions);
 
        $default_moderated = XenForo_Permission::hasContentPermission($nodePermissions, 'viewModerated');
        $default_deleted = XenForo_Permission::hasContentPermission($nodePermissions, 'viewDeleted');
   
        if (XenForo_Permission::hasContentPermission($nodePermissions, 'tsRighTviewModerated'))
        {
            $viewModerated = true;
        }
        else if ($viewingUser['user_id'])
        {
            $viewModerated = $viewingUser['user_id'];
        }
        else
        {
            $viewModerated = false;
        }
 
        return array(
            'deleted' => $default_deleted || XenForo_Permission::hasContentPermission($nodePermissions, 'tsRighTviewDeleted'),
            'moderated' => $default_moderated || $viewModerated
        );
    }