[XTR] Old Thread Notice

[XTR] Old Thread Notice 1.0.3

No permission to download
After installing the new version (1.0.3), I could not approve any posts from the "approval queue". The back end kept triggering errors.

Code:
ErrorException: [E_NOTICE] Trying to get property 'is_staff' of non-object src/addons/XENTR/ThreadNotice/XF/Entity/Post.php:16

Only after uninstalling this, I was able to approve posts.
 
How can i adjust the alert to match the messageUserBlockWidth?

1610712826302.png

In template: xtr_thread_notice.less adjust this value.
CSS:
.col-xs-2 {
  -ms-flex-preferred-size: 16.66666667%;
  flex-basis: 16.66666667%;
  max-width: 150px;
}

It looks more matching your forums layout.
1610718799300.png
 
Last edited:
After installing the new version (1.0.3), I could not approve any posts from the "approval queue". The back end kept triggering errors.

Code:
ErrorException: [E_NOTICE] Trying to get property 'is_staff' of non-object src/addons/XENTR/ThreadNotice/XF/Entity/Post.php:16

Only after uninstalling this, I was able to approve posts.

I have same issue here. Any ideas why @XDinc ?
 
Last edited:
I found a bug:

The file XENTR\ThreadNotice\XF\Entity\Post has a bug:
PHP:
namespace XENTR\ThreadNotice\XF\Entity;
class Post extends XFCP_Post {
    protected function _preSave()
    {
        $options = \XF::options();
        if($options->ThreadNotice_Enable && $options->ThreadNotice_Unapprove && !$this->User->is_staff && !$this->isFirstPost()) {
            $now = \XF::$time;
            
            $timeout = $options->ThreadNotice_Day * 24 * 60 * 60;
            
            if($timeout + $this->Thread->post_date < $now) {
                $this->message_state = 'moderated';
            }
        }
        parent::_preSave();
    }
}
Imagine I am about to approve a very old post. Whenever the system does the following:
PHP:
$post->message_state = 'visible';
$post->save();
As it tries to save, it gets set to 'moderated' because the thread is older than the timeout defined in $timeout. This makes posts impossible to approve as the thread gets old.
 
After installing the new version (1.0.3), I could not approve any posts from the "approval queue". The back end kept triggering errors.

Code:
ErrorException: [E_NOTICE] Trying to get property 'is_staff' of non-object src/addons/XENTR/ThreadNotice/XF/Entity/Post.php:16

Only after uninstalling this, I was able to approve posts.
I found a bug:

The file XENTR\ThreadNotice\XF\Entity\Post has a bug:
PHP:
namespace XENTR\ThreadNotice\XF\Entity;
class Post extends XFCP_Post {
    protected function _preSave()
    {
        $options = \XF::options();
        if($options->ThreadNotice_Enable && $options->ThreadNotice_Unapprove && !$this->User->is_staff && !$this->isFirstPost()) {
            $now = \XF::$time;
          
            $timeout = $options->ThreadNotice_Day * 24 * 60 * 60;
          
            if($timeout + $this->Thread->post_date < $now) {
                $this->message_state = 'moderated';
            }
        }
        parent::_preSave();
    }
}
Imagine I am about to approve a very old post. Whenever the system does the following:
PHP:
$post->message_state = 'visible';
$post->save();
As it tries to save, it gets set to 'moderated' because the thread is older than the timeout defined in $timeout. This makes posts impossible to approve as the thread gets old.

I confirm this bug

If you disable this feature it works fine tho:
1625112210532.webp
 
Useful addon. However the moderation function does not work. Using the "unapprove" option does put the post into moderation, but it cannot be approved by admin or mod.

Would also be valuable to return the age in days, month, and years so we can select in the phrase (or make it a config option)

It would also be nice to bypass the notice on locked threads or in forums where posting isn't allowed.
 
Top Bottom