Navigation Menu

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

problem with newflag in forum page #2137

Closed
Jimmi08 opened this issue Dec 11, 2016 · 15 comments
Closed

problem with newflag in forum page #2137

Jimmi08 opened this issue Dec 11, 2016 · 15 comments
Labels
type: bug A problem that should not be happening
Milestone

Comments

@Jimmi08
Copy link
Contributor

Jimmi08 commented Dec 11, 2016

I noticed this:
image

in this function:

	function sc_newflag()
	{

		if(USER && is_array($this->newFlagList) && in_array($this->var['forum_id'], $this->newFlagList))
		{
			$url = $this->sc_lastpost('url');
			return "<a href='".$url."'>".IMAGE_new.'</a>';
		}
		elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies'))
		{
			return IMAGE_noreplies;
		}

		return IMAGE_nonew;

	}

if I echo $url, output has already a tags:
<a href='/user.php?id.2'>username</a> <a href='/forum/dkdhvdbd/3/test/?last=1#post-3'><span data-livestamp="1481490078">36 mins ago</span></a>

@tgtje
Copy link
Contributor

tgtje commented Dec 12, 2016

No chance to test but forum_viewforum php line 821 :

$tVars->NEWFLAG = "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$subInfo['forum_id'])."'>".IMAGE_new."' < / a > ';

should it not be :

$tVars->NEWFLAG = "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$subInfo['forum_id'])."'>".IMAGE_new." " < / a > ";

see last quotation as code line starts with " should also end with " ? I added spaces to keep code visible, else it will delete the close A tag (the A tag is NOW surrounded by 2 " instead of ' tag ' .

edit : same goes for lines : 265; 500; 831

@Jimmi08
Copy link
Contributor Author

Jimmi08 commented Dec 12, 2016

@tgtje I really don't know, first time working with forum plugin and I was able to find this code just by trying to change something and will see if something was changed.
Problem is from forum_template.php

$FORUM_TEMPLATE['main']['forum']			= 	"<tr>
											<td>{NEWFLAG}</td>

and there is code from shortcode above.
By the way, I am still on main forum page, maybe you are right, I will find this later.

@Moc Moc added the type: bug A problem that should not be happening label Dec 12, 2016
@martyshep
Copy link
Contributor

Same issue
image

@rica-carv
Copy link
Contributor

rica-carv commented Dec 12, 2016

@Jimmi08 @martyshep As soon i can, i'll give it a look, to see if i can solve it.
@tgtje Aren't you using a old forum code? Those $tvars are long gonne...

P.S.: It has something to do with the lastpost shortcode. As soon i can, i'll debug it...

@Moc Moc added this to the e107 v2.1.3 milestone Dec 12, 2016
@rica-carv
Copy link
Contributor

rica-carv commented Dec 12, 2016

@ALL Definetly, it's with sc_lastpost call. My fault...
Try change
$url = $this->sc_lastpost('url');
to this
$url = $this->sc_lastpost(array( 'type' => 'url'));

Please test it...
Currently i can't, so i'm trying to solve this from memory....

@martyshep
Copy link
Contributor

Hi @rica-carv I can't see the code similar to $url = $this->sc_lastpost('url'); within viewforum_shortcodes.php on master or on your branch of it. Wait.. Master is same as your branch for viewforum_shortcode.php anyway.

What I do see are:
function sc_newflag()
{
//-- global $newflag_list;
global $forum;
$newflag_list = $forum->forumGetUnreadForums();
/--
if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
{
return "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$this->var['forum_id'])."'>".IMAGE_new.'';
}
return IMAGE_nonew;
--
/

	//	$url = e107::getUrl()->create('forum/forum/mfar', 'id=' . $this->var['forum_id']);
		$url = e107::url('forum', 'markread', $this->var);
		return (USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list)) ? "<a href='" . $url . "'>" . IMAGE_new . '</a>' : IMAGE_nonew;

and

function sc_newflag()
		{
		global $newflag_list;
			if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
		{
			return "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$this->var['forum_id'])."'>".IMAGE_new.'</a>';
		}
			return IMAGE_nonew;

	  }

@rica-carv
Copy link
Contributor

@martyshep It's not in viewforum_shortcodes.php, it's in forum_shortcodes.php.
Sorry for all this mess...

@tgtje
Copy link
Contributor

tgtje commented Dec 12, 2016

Ok, my bad, files a little older.
After deeper investigation i discovered it actually is a break not fully implemented ? ..

i changed line 352 forum_shortcodes to
return "<a href='".$url."<br />".IMAGE_new."</a>";
outcome top 2 images
the bottom one is same but AFTER applied proposed patch

f5

What to do ?

@martyshep
Copy link
Contributor

martyshep commented Dec 12, 2016 via email

@rica-carv
Copy link
Contributor

rica-carv commented Dec 12, 2016

@ALL This issue was because of a commit made 6 days ago, therefore if you don't have the latest github files and after apply my patch, it will still give a error.
I've tested my patch with latest files, in a clean e107 setup, and it returns the new forum flag with the correct url to the latest topic, as is intended to be...
untitled 1

@tgtje
Copy link
Contributor

tgtje commented Dec 12, 2016

@rica-carv correct your patch works 👍 but what i meant to express : in pre patch there was also the author and the time (textual) (linkage IS divided in 2 url's, correct). (left 1st column).
What to do : keep that extra info ? or use the new patching (only fa-star)? ( do we need/want User + text time?) It is an extra pointer, but also happens on right side too....

@martyshep the appearance of the old is correct by means of execute > when the post is 'read' the function is done, and will only show up in right side from there on. This untill a newer post exists (unread).

@rica-carv
Copy link
Contributor

@tgtje The appearence is exactly the same as was before this mess up.
The last poster name & date is always on the right, there's no need (or logic) to have it again on the left side, above the star.
Old newflag code ($fVars->NEWFLAG):

	if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
	{
		$fVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', $f)."'>".IMAGE_new.'</a>';
	}
	elseif(empty($f['forum_replies']) && defined('IMAGE_noreplies'))
	{
		$fVars->NEWFLAG = IMAGE_noreplies;
	}
	else
	{
		$fVars->NEWFLAG = IMAGE_nonew;
	}

As you can see, the newflag shortcode has never returned the last post author or date....

@martyshep
Copy link
Contributor

martyshep commented Dec 12, 2016

I'm no coder but I returned my forum to previous behaviour with this:

		$url = $this->sc_lastpost('url');
	         return IMAGE_new;
	}
	elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies'))
	{
		return IMAGE_noreplies;
	}

	return IMAGE_nonew;

@tgtje
Copy link
Contributor

tgtje commented Dec 13, 2016

Ok, before messup( harsh : code error) the code should NOT have been displayed in the first column.
Hence the original post asked as it was visible.

quote : no need (or logic) ?? hmmmm it does trigger possible use for other things .... (despite wrong used code before). ( a keeper)
As for the eye of the beholder i leave it open. (logic = right = ok). I can vision users that are drawn to text instead of knowledge of the glyphs.

@rica-carv
Copy link
Contributor

@martyshep If you have the latest github files, there's no way that code is acting correct... Have you cleaned cache before testing it?

@tgtje You can still have the lastpost user name & date via shortcode:
{LASTPOST:type=username} {LASTPOST:type=datelink}
You can put them wherever you like, even twice in the same template....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A problem that should not be happening
Projects
None yet
Development

No branches or pull requests

5 participants