MyBB Community Forums

Full Version: Issue - hardcoded HTML tags in private.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
After revamping private messages i have noticed that variables $msgprefix, $msgsuffix and $msgimage are hardcoded in private.php. Instead of moving them in new templates i have made few edits to private.php:


Line 366 - 387

		if($message['status'] == 0)
		{
			$msgfolder = 'new_pm.png';
			$msgalt = $lang->new_pm;
			$msgprefix = "<strong>";
			$msgsuffix = "</strong>";
		}
		elseif($message['status'] == 1)
		{
			$msgfolder = 'old_pm.png';
			$msgalt = $lang->old_pm;
		}
		elseif($message['status'] == 3)
		{
			$msgfolder = 're_pm.png';
			$msgalt = $lang->reply_pm;
		}
		else if($message['status'] == 4)
		{
			$msgfolder = 'fw_pm.png';
			$msgalt = $lang->fwd_pm;
		}

to


		// Determine Folder Icon
		if($message['status'] == 0)
		{
			$msgstatus = 'new_pm';
			$msgalt = $lang->new_pm;
		}
		elseif($message['status'] == 1)
		{
			$msgstatus = 'old_pm';
			$msgalt = $lang->old_pm;
		}
		elseif($message['status'] == 3)
		{
			$msgstatus = 're_pm';
			$msgalt = $lang->reply_pm;
		}
		else if($message['status'] == 4)
		{
			$msgstatus = 'fw_pm';
			$msgalt = $lang->fwd_pm;
		}




Line 2257 - 2278

if($message['status'] == 0)
			{
				$msgfolder = 'new_pm.png';
				$msgalt = $lang->new_pm;
				$msgprefix = "<strong>";
				$msgsuffix = "</strong>";
			}
			elseif($message['status'] == 1)
			{
				$msgfolder = 'old_pm.png';
				$msgalt = $lang->old_pm;
			}
			elseif($message['status'] == 3)
			{
				$msgfolder = 're_pm.png';
				$msgalt = $lang->reply_pm;
			}
			elseif($message['status'] == 4)
			{
				$msgfolder = 'fw_pm.png';
				$msgalt = $lang->fwd_pm;
			}


to



			if($message['status'] == 0)
			{
				$msgstatus = 'new_pm';
				$msgalt = $lang->new_pm;
			}
			elseif($message['status'] == 1)
			{
				$msgstatus = 'old_pm';
				$msgalt = $lang->old_pm;
			}
			elseif($message['status'] == 3)
			{
				$msgstatus = 're_pm';
				$msgalt = $lang->reply_pm;
			}
			elseif($message['status'] == 4)
			{
				$msgstatus = 'fw_pm';
				$msgalt = $lang->fwd_pm;
			}


New template content:

private_messagebit
<tr>
<td align="center" class="trow1" width="1%"><img src="{$theme['imgdir']}/{$msgstatus}.png" alt="{$msgalt}" title="{$msgalt}" /></td>
<td align="center" class="trow2" width="1%">{$icon}</td>
<td class="trow1" width="35%"><a class="{$msgstatus}" href="private.php?action=read&amp;pmid={$message['pmid']}">{$message['subject']}</a>{$denyreceipt}</td>
<td align="center" class="trow2">{$tofromusername}</td>
<td class="trow1" align="right" style="white-space: nowrap"><span class="smalltext">{$senddate}</span></td>
<td class="trow2" align="center"><input type="checkbox" class="checkbox" name="check[{$message['pmid']}]" value="1" /></td>
</tr>

private_search_messagebit

<tr>
<td align="center" class="trow1" width="1%"><img src="{$theme['imgdir']}/{$msgstatus}.png" alt="{$msgalt}" title="{$msgalt}" /></td>
<td align="center" class="trow2" width="1%">{$icon}</td>
<td class="trow1" width="35%"><a class="{$msgstatus}" href="private.php?action=read&amp;pmid={$message['pmid']}">{$message['subject']}</a>{$denyreceipt}
<br />{$message['message']}</td>
<td align="center" class="trow2">{$tofromusername}</td>
<td align="center" class="trow1"><a href="private.php?fid={$message['folder']}">{$foldername}</a></td>
<td class="trow2" align="center" style="white-space: nowrap"><span class="smalltext">{$senddate}</span></td>
<td class="trow1" align="center"><input type="checkbox" class="checkbox" name="check[{$message['pmid']}]" value="1" /></td>
</tr>

and in usercp.css at the bottom

.new_pm { font-weight:bold;}

Also

$msgalt = $msgsuffix = $msgprefix = '';

at lines 363 and 2257 can be removed (i guess there is no need for it since suffix and prefix variables are removed ?).
Johnny, you should get involved through GitHub and make issues / pull requests. That will reduce rework of importing these from here to there.
Nice find Johnny. I wonder why these are hardcoded. Using templates is much easier.
Thanks for report, added here: https://github.com/mybb/mybb/issues/1150 (concerns your other hardcoded HTML thread too).