MyBB Community Forums

Full Version: Disable view from mod when member is not login.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I have a MOD installed called "A clear news bar" and everything works fine, but I want to have someting.

you can see the newsbar at anny time, but now I want to have that the bar is only visible after login, so guests can't see the news.

So wat do I need to change or add to that the bar is only visible afther loging in???

This is the mod:

<?php

/*

*/

if(!defined('IN_MYBB'))
{
	die();
}

$plugins->add_hook('pre_output_page','aclearnewsbar');

function aclearnewsbar_info()
{
	return array
	(
		"name"=>"A clear news bar",
		"description"=>"Shows a clear news bar on your forum pages.",
		"website"=>"http://www.ajdija.com",
		"author"=>"Mateusz Grzesiukiewicz",
		"authorsite"=> "http://www.ajdija.com",
		"version"=>"1.0",
		"guid"=>"6ea8e913cc025947b8ed07ec1d6a2c77",
		"compatibility"=>"14*"
	);
}

function aclearnewsbar($page)
{
	global $mybb,$theme, $db;
		if(THIS_SCRIPT!='portal.php') // do not show news bar on portal(news) page
		{
		$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
	foreach($announcementsfids as $fid)
	{
		$fid_array[] = intval($fid);
	}
	$announcementsfids = implode(',', $fid_array);
}
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
    $forum[$forumrow['fid']] = $forumrow;
}

$pids = '';
$tids = '';
$comma = '';
$query = $db->query("
	SELECT p.pid, p.message, p.tid
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	WHERE t.fid IN (".$announcementsfids.") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
	ORDER BY t.dateline DESC 
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);
while($getid = $db->fetch_array($query))
{
	$pids .= ",'{$getid['pid']}'";
	$tids .= ",'{$getid['tid']}'";
	$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0{$pids})";
$query = $db->simple_select("attachments", "*", $pids);
while($attachment = $db->fetch_array($query))
{
	$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
}

if(is_array($forum))
{
	foreach($forum as $fid => $forumrow)
	{
		$forumpermissions[$fid] = forum_permissions($fid);
	}
}

$announcements = '';
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE t.fid IN (".$announcementsfids.") AND t.tid IN (0{$tids}) AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);

$news = '--- ';
while($announcement = $db->fetch_array($query))
{
$news = $news.'<a href="'.htmlspecialchars_uni($announcement['threadlink']).'">'.htmlspecialchars_uni(		$announcement['subject']).'</a> --- ';	
	
	
}
		
			$page=preg_replace('#<div class="navigation">(.*)</div>#Usi','<div class="navigation">$1</div><br />
<table border="0" cellspacing="'.$theme["borderwidth"].'" cellpadding="'.$theme["tablespace"].'" class="tborder">
	<thead>
		<tr> 
			<td class="thead" width="120" align="center"><strong>Latest '.
			/* Use below code and set ^^(width) higher if you want board name to be said:
			$mybb->settings['bbname'] 
			*/
			'nieuws: </strong></td><td class="thead"><strong><marquee direction="left" scrollamount="5">'.$news.'</marquee></strong></td>
		</tr>
	</thead>
</table>',$page);
		return $page;
		}
	}

?>

Thanks for helping me and the sollution!!!
This is support for a modification to MyBB.
/Moved to correct forum.
I don't need support for the MOD but I want to know the code that I need to use for disable the view for guests and only visible for members that are login. This has (I think) nothing to do with this MOD, you can use this option with diffrent things or I see this wrong????
Someone with a sollution????
???????
Never mind I have the sollution and now its shows only when the members are login, so this can close!!!