MyBB Community Forums

Full Version: Post notifications on subscribed threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I allready have a notification system on my forum, when somebody reply on my own thread, I get notification in a header.

This is the code:

<?php
define("IN_MYBB", 1);
include("global.php");
include("funkcije.php");



$ref = $_SERVER["HTTP_REFERER"];
$notifikacije = "";
$pretplate = "";

$akcija = preg_replace("/[^a-z]/","",$_GET["akcija"]);
$uid = preg_replace("/[^0-9]/","",$_GET["uid"]);
$id = intval($_GET["id"]);

if($akcija == "garaze" && !empty($uid)){
//Garaže	
$sql = mysql_query("SELECT tid,uid,fid,subject FROM forum_threads WHERE uid = '$uid' AND fid IN (26,72,73,74,75,76,77) ORDER BY lastpost DESC");
while($red = mysql_fetch_array($sql)){$garaze.=('<a href="/showthread.php?tid='.$red["tid"].'">'.$red["subject"].'</a><br/>');}
$sql = mysql_query("SELECT tid,uid,fid,subject FROM forum_threads WHERE uid = '$uid' AND fid = 96 ORDER BY lastpost DESC");
while($red = mysql_fetch_array($sql)){$komentari.=('<a href="/showthread.php?tid='.$red["tid"].'">'.$red["subject"].'</a><br/>');}

echo("<h4>Garaže / Projekti</h4>$garaze<h4>Komentari</h4>$komentari");
}

if($akcija == "notifikacije"){
$sql = mysql_query('SELECT * FROM notifikacije WHERE y = '.$mybb->user['uid'].' AND procitana = 0 ORDER BY unix DESC');
if($sql){
while($row = mysql_fetch_array($sql)){
$korisnik = get_user($row["x"]);
$tema = get_thread($row["tid"]);
$notifikacije.= '<li><a href="/ajax.php?akcija=notifikacija&amp;id='.$row["id"].'"><strong>'.$korisnik["username"].'</strong> je pisao u vašoj temi <strong>'.$tema["subject"].'</strong> '.prije($row["unix"]).'</a></li>';
}}
if(!empty($notifikacije)){
$notifikacije = '<h3>Notifikacije</h3><ul>'.$notifikacije.'
<li><a href="/ajax.php?akcija=onotifikacije"><img src="/gfx/ico/x.png"/> Ukloni sve notifikacije</a></li></ul>';
echo $notifikacije;}
}

and it's working perfect.

Now what I want is the same notifications when someone replies on threas on which you had subscribed. I allready done this peace of code, but it seems to not working:

if($akcija == "notifikacije"){			
$sql = mysql_query("SELECT mybb_posts.tid,username FROM mybb_posts,mybb_threadsubscriptions WHERE mybb_threadsubscriptions.uid = ".$mybb->user['uid']." AND mybb_posts.dateline > ".$timelimit." AND mybb_posts.tid = mybb_threadsubscriptions.tid AND mybb_posts.uid !=".$mybb->user['uid']." ORDER BY mybb_posts.dateline DESC");

while($data = $db->fetch_array($sql)){
$pretplate.= "<li><a href=\"{$mybb->settings['bburl']}/showthread.php?tid={$data['tid']}&action=newpost\">{$data['username']} je pisao u temi na kojoj ste se pretplatili</a>";
}

}

Can someone help about this...

sorry for my bad english...