Resource icon

vBulletin Mark Thread Unread On Edit 3.0

No permission to download

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
MarkFL submitted a new resource:

Mark Thread Unread On Edit - Marks a thread as unread when a post is edited, and the content of the post actually changes.

Overview:

This simple product will mark a thread as unread when a post is edited, and the content of the post actually changes.

The site I help administrate is a math help forum, and sometimes users will post an incomplete question for which no help can effectively be given, and then they will later edit their post to provide relevant information, and it is nice for that thread to then be returned to unread status.

In the settings for this product, you choose which...

Read more about this resource...
 

I A 1

Enthusiast
Joined
Jun 7, 2015
Messages
138
Is it possible to have it mark the thread as unread from the edited post onward? Currently it is marking the whole thread as unread, making us read from the OP once again.
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
Is it possible to have it mark the thread as unread from the edited post onward? Currently it is marking the whole thread as unread, making us read from the OP once again.

I will look into that, and see what can be done to correct that issue. :D
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
Okay, I tested this product on my local dev site, and it already behaves as I would expect. When a post is edited (by a user set to trigger the product), the thread is marked as unread and the "Go to first new post" button takes you to the edited post.

Can you clarify exactly what the product is not doing that you want it to do?
 

I A 1

Enthusiast
Joined
Jun 7, 2015
Messages
138
When a post is edited (by a user set to trigger the product), the thread is marked as unread and the "Go to first new post" button takes you to the edited post.

On my forum, it takes me to the first post of the thread when I click on first new post instead of going to the edited post. This might be because the plugin marks the thread as unread, not the post.

Code:
while ($forum_read = $db->fetch_array($forums_read)) 
        { 
            $threads_to_markread = $vbulletin->db->query_read("SELECT thread.* FROM " . TABLE_PREFIX . "thread AS thread WHERE forumid = " . $foruminfo['forumid'] . " AND (lastpost BETWEEN " . $cutoff . " AND " . $forum_read['readtime'] . ")");

            while ($thread_to_markread = $db->fetch_array($threads_to_markread)) 
            { 
                $vbulletin->db->query_write("REPLACE INTO " . TABLE_PREFIX . "threadread SET userid = " . $forum_read['userid'] . ", threadid = " . $thread_to_markread['threadid'] . ", readtime = ". TIMENOW); 
            } 
        }

I am using the latest version 2.2.2 from https://www.vbulletin.org/forum/showthread.php?t=318686
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
In vB 4.2.x, there is a table to track read forums, and a table to track read threads, but there is no table to track read posts. Perhaps there is some kind of lag during the queries on your site...try replacing the code in the plugin hooked at "editpost_update_thread" with the following:

PHP:
$marktime = TIMENOW;

global $vbulletin, $db;

if (!in_array(THIS_SCRIPT, array('vbcms', 'blog')) AND $vbulletin->options['markfl_mtuoe_enabled']  AND !($vbulletin->options['markfl_mtuoe_usergroup_unread'] == '-1' AND !$vbulletin->options['markfl_mtuoe_userids']) AND $postinfo['dateline'] > ($marktime - ($vbulletin->options['markinglimit'] * 86400)) AND ($vbulletin->options['markfl_mtuoe_group_include'] == '0' OR is_member_of($userinfo, explode(',', $vbulletin->options['markfl_mtuoe_group_include']))) AND ($postinfo['pagetext'] != $edit['message']))
{
   $userids = '';
   $groups = '';
   $q_users = false;
   $query = "SELECT user.userid FROM " . TABLE_PREFIX . "user AS user";

   if ($vbulletin->options['markfl_mtuoe_usergroup_unread'] != '-1' AND $vbulletin->options['markfl_mtuoe_usergroup_unread'] != '0')
   {
       $q_users = true;
       $groups = $vbulletin->options['markfl_mtuoe_usergroup_unread'];
       $query .= " WHERE usergroupid IN ($groups)";
       $groups_arr = explode(',', $groups);
       foreach ($groups_arr AS $group)
       {
           $query .= " OR find_in_set(" . $group . ", membergroupids)";
       }
   }

   if ($vbulletin->options['markfl_mtuoe_userids'] AND $vbulletin->options['markfl_mtuoe_usergroup_unread'] != '0')
   {
       $q_users = true;
       $users_arr = array_map('trim', array_map('strtolower', explode(PHP_EOL, $vbulletin->options['markfl_mtuoe_userids'])));
       $n = false;
       foreach ($users_arr AS $username)
       {
           if (strtolower($vbulletin->userinfo['username']) != $username)
           {
               if (!$n AND !$groups)
               {
                   $query .= " WHERE username = '" . $username . "'";
                   $n = true;
               }
               else
               {
                   $query .= " OR username = '" . $username . "'";
               }
           }
       }
   }

   if ($q_users OR $vbulletin->options['markfl_mtuoe_usergroup_unread'] == '0')
   {
       $f_read_query = "SELECT forumread.* FROM " . TABLE_PREFIX . "forumread AS forumread WHERE forumid = " . $foruminfo['forumid'];
       $f_query = "DELETE FROM " . TABLE_PREFIX . "forumread WHERE forumid = " . $foruminfo['forumid'];
       $t_query = "DELETE FROM " . TABLE_PREFIX . "threadread WHERE threadid = " . $threadinfo['threadid'];
       $u_add = '';

       if ($q_users)
       {
           $users = $db->query_read($query);

           while ($user = $db->fetch_array($users))
           {
               $userids .= (strval($user['userid']) . ',');
           }

           $userids = rtrim($userids, ",");
           $u_add = " AND userid IN ($userids)";
       }

       $forums_read = $vbulletin->db->query_read($f_read_query . $u_add);
       $cutoff = $marktime - ($vbulletin->options['markinglimit'] * 86400);

       while ($forum_read = $db->fetch_array($forums_read))
       {
           $threads_to_markread = $vbulletin->db->query_read("SELECT thread.* FROM " . TABLE_PREFIX . "thread AS thread WHERE forumid = " . $foruminfo['forumid'] . " AND (lastpost BETWEEN " . $cutoff . " AND " . $forum_read['readtime'] . ")");

           while ($thread_to_markread = $db->fetch_array($threads_to_markread))
           {
               $vbulletin->db->query_write("REPLACE INTO " . TABLE_PREFIX . "threadread SET userid = " . $forum_read['userid'] . ", threadid = " . $thread_to_markread['threadid'] . ", readtime = ". $marktime);
           }
       }

Please let me know if this fixes the issue.
       $vbulletin->db->query_write($f_query . $u_add);
       $vbulletin->db->query_write($t_query. $u_add);
   }
}
 

I A 1

Enthusiast
Joined
Jun 7, 2015
Messages
138
Tried this but no, it didn't work as expected. Still takes us to the first post.

I have now created a new test installation at www.vb424.tk and tested there once again. Still same issue. PM'ing you test credentials.

Edit: Can't find the PM link. Can you PM me? and I will reply back.
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
What version of vB are you using? From your URL it appears you are using vB 4.2.4...and if so, are you using the now defunct cookie based "Thread/Forum Read Marking Type?"
 

I A 1

Enthusiast
Joined
Jun 7, 2015
Messages
138
What version of vB are you using? From your URL it appears you are using vB 4.2.4...and if so, are you using the now defunct cookie based "Thread/Forum Read Marking Type?"

Yes, 4.2.4. It is Database making, as set by the product.

You may create disposable test accounts on that site to test it.
 

I A 1

Enthusiast
Joined
Jun 7, 2015
Messages
138
Also noticed, the thread gets marked as unread for the author as well even if he himself edits the post.
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
My product doesn't change the marking type...you need to check which type you are using in your AdminCP...
 

MarkFL

La Villa Strangiato
Joined
Jul 3, 2017
Messages
1,245
Just checked, yes it is Database (automatic forum making).

At the moment, I am fresh out of ideas. All I can say for now is that this product works correctly for me on multiple sites. o_O
 
Top