Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threadMarkAsRead() changes only last forum ID #3338

Closed
Jimmi08 opened this issue Jul 30, 2018 · 0 comments
Closed

threadMarkAsRead() changes only last forum ID #3338

Jimmi08 opened this issue Jul 30, 2018 · 0 comments
Labels
plugin: forum type: bug A problem that should not be happening
Milestone

Comments

@Jimmi08
Copy link
Contributor

Jimmi08 commented Jul 30, 2018

I do this in plugin - marking more than one forum as viewed

if (e_QUERY == 'mark_all_as_read')
{
	unset($u_new);
	$qry = 'WHERE thread_lastpost > ' . $lvisit;
	if ($rows = $sql->retrieve('forum_thread', 'thread_id', $qry, true))
	{   
		foreach($rows as $forumrow)
		{               
			$forum->threadMarkAsRead($forumrow['thread_id']);
		}                                     
    e107::redirect(e_REQUEST_SELF);
		exit;
	}
}

Because $currentUser['user_plugin_forum_viewed'] is not refreshed after adding one thread (I don't know how to call this), it's still the same and so only last thread is changed

	function threadMarkAsRead($threadId)
	{
		global $currentUser;                 
		$_tmp = preg_split('#\,+#', $currentUser['user_plugin_forum_viewed']);
		if(!is_array($threadId)) { $threadId = array($threadId); }
		foreach($threadId as $tid)
		{
			$_tmp[] = (int)$tid;
		}                            
		$tmp = array_unique($_tmp);              
		$viewed = trim(implode(',', $tmp), ',');   
   
		return e107::getDb()->update('user_extended', "user_plugin_forum_viewed = '{$viewed}' WHERE user_extended_id = ".USERID);
	}

image

@Moc Moc added type: bug A problem that should not be happening plugin: forum labels Aug 7, 2018
@Moc Moc added this to the e107 2.1.9 milestone Aug 7, 2018
@CaMer0n CaMer0n closed this as completed in 1811496 Aug 7, 2018
CaMer0n added a commit that referenced this issue Aug 7, 2018
Fixes #3338 typo and e_SELF calling itself (infinite loop)
@Moc Moc reopened this Jan 6, 2019
@Moc Moc modified the milestones: e107 2.1.9, e107 2.2.0 Jan 6, 2019
@CaMer0n CaMer0n closed this as completed in 3b15821 Jan 6, 2019
CaMer0n added a commit that referenced this issue Jan 6, 2019
Fixes #3338 - marked more than one forum as read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: forum type: bug A problem that should not be happening
Projects
None yet
Development

No branches or pull requests

2 participants