// If user is known, welcome them
{
if($mybb->user['uid'] != 0)
{
if($mybb->user['receivepms'] != "no" && $mybb->usergroup['canusepms'] != "no" && $mybb->settings['portal_showpms'] != "no" && $mybb->settings['enablepms'] != "no")
{
$query = $db->simple_select(TABLE_PREFIX."privatemessages", "COUNT(*) AS pms_total, SUM(IF(dateline>'".$mybb->user['lastvisit']."' AND folder='1','1','0')) AS pms_new, SUM(IF(status='0' AND folder='1','1','0')) AS pms_unread", "uid='".$mybb->user['uid']."'");
$messages = $db->fetch_array($query);
if(!$messages['pms_new'])
{
$messages['pms_new'] = 0;
}
// the SUM() thing returns "" instead of 0
if($messages['pms_unread'] == "")
{
$messages['pms_unread'] = 0;
}
$lang->pms_received_new = sprintf($lang->pms_received_new, $mybb->user['username'], $messages['pms_new']);
eval("\$pms = \"".$templates->get("portal_pms")."\";");
}
// get number of new posts, threads, announcements
$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS newposts", "dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
$newposts = $db->fetch_field($query, "newposts");
if($newposts)
{ // if there aren't any new posts, there is no point in wasting two more queries
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS newthreads", "dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
$newthreads = $db->fetch_field($query, "newthreads");
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS newann", "dateline>'".$mybb->user['lastvisit']."' AND fid IN (".$mybb->settings['portal_announcementsfid'].") $unviewwhere");
$newann = $db->fetch_field($query, "newann");
if(!$newthreads)
{
$newthreads = 0;
}
if(!$newann)
{
$newann = 0;
}
}
else
{
$newposts = 0;
$newthreads = 0;
$newann = 0;
}
// Make the text
if($newann == 1)
{
$lang->new_announcements = $lang->new_announcement;
}
else
{
$lang->new_announcements = sprintf($lang->new_announcements, $newann);
}
if($newthreads == 1)
{
$lang->new_threads = $lang->new_thread;
}
else
{
$lang->new_threads = sprintf($lang->new_threads, $newthreads);
}
if($newposts == 1)
{
$lang->new__portal_posts = $lang->new_post;
}
else
{
$lang->new_portal_posts = sprintf($lang->new_portal_posts, $newposts);
}
eval("\$welcometext = \"".$templates->get("index_welcome_membertext")."\";");
}
else
{
$lang->guest_welcome_registration = sprintf($lang->guest_welcome_registration, $mybb->settings['bburl'] . '/member.php?action=register');
$mybb->user['username'] = $lang->guest;
eval("\$welcometext = \"".$templates->get("portal_welcome_guesttext")."\";");
}
$lang->welcome = sprintf($lang->welcome, $mybb->user['username']);
}