<?php
defined('IN_JAMROOM') or exit();
function jrGetChanges(&$_args)
{
global $jamroom, $config;
$myvar = $_args["band_id"];
$type = $_args["type"];
$height = $_args["height"];
$width = $_args["width"];
$text = $_args["textcolor"];
$background = $_args["background"];
if (!isset($width))
{
$width = "100%";
}
if (!isset($text))
{
$text = "#f4f4f4";
}
if (!isset($background))
{
$background = "#acc95f";
}
$thearray = get_friendsActivity("$myvar");
//organize the array by date Start
function cmp($a, $b)
{
if($a["when"] == $b["when"]) { return 0; }
return ($a["when"] > $b["when"]) ? -1 : 1;
}
usort($thearray, 'cmp');
echo ' <script type="text/javascript" src="/include/accordian/plugins/updates/mootools.v1.1.js"></script>
<script type="text/javascript" src="/include/accordian/plugins/updates/accordionscript.js"></script>
<link href="/include/accordian/plugins/updates/accordion.css" rel="stylesheet" type="text/css" />
<style>
.accToggler a:active
{
color:'.$text.';
}
.accToggler a:visited
{
color:'.$text.';
}
.accToggler a:hover
{
color:'.$text.';
}
</style>';
//organize the array by date End
echo "<table width=\"".$width."\" cellpadding=\"0\" cellspacing=\"0\" class=\"jmButton\"><tr><td class=\"jmButton\" style=\"padding:25px;text-align:left\">
<span style=\"vertical-align: middle;\"><h1>My Friend's Latest Activities</h1></span>
</td></tr>";
if($thearray)
{
for($i=0;$i<20;$i++)
{
if($thearray[$i])
{
echo"<tr><td><div class=\"accToggler\" style=\"background: ".$background.";color: ".$text.";a:".$text."\">";
echo"<img src=\"/include/accordian/plugins/updates/icons/".$thearray[$i]["type"].".jpg\"> ";
echo $thearray[$i]["from"] . ' ' . $thearray[$i]["notice"] . ' ' . $thearray[$i]["to"]." - ".date("m.d.y g:i a",$thearray[$i]["when"]);
echo"</div>";
echo "<div class=\"accContent\">";
echo $thearray[$i]["what"]."<br />";
echo "</div></td></tr>";
}
}
}
else
{
echo"<tr><td colspan=\"3\" class=\"jmButton\" style=\"padding:25px;text-align:left\">You have no recent updates.</td></tr>";
}
echo "<tr><td> </td></tr></table><br /><br />";
return($out);
}
function get_userComments($user,$notice)
{
$n = 0;
$day = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
$comments = mysql_query("SELECT x.comment_id , x.comment_nick , x.band_id , x.user_id, x.comment_text , x.comment_time , y.band_name as band_name FROM jamroom_comments x, jamroom_band_info y WHERE x.band_id = y.band_id AND x.user_id = \"$user\" && x.comment_time > '1148579248' ORDER BY x.comment_time DESC LIMIT 10 ");
if ($therow = mysql_fetch_array($comments))
{
do
{
$userid = $therow["user_id"] + 1;
$action[$n]["from"] = $therow["comment_nick"];
$action[$n]["from"] = "<a target=\"_top\" href=\"members/" . $userid . "/\">" . $therow["comment_nick"] . "</a>";
$action[$n]["to"] = "<a target=\"_top\" href=\"members/" . $therow["band_id"] . "/\">" . $therow["band_name"] . "</a>";
$action[$n]["what"] = $therow["comment_text"];
$action[$n]["when"] = $therow["comment_time"];
$action[$n]["type"] = "new-comment";
$action[$n]["notice"] = $notice;
$n++;
}
while ($therow = mysql_fetch_array($comments));
return $action;
}
}
//SELECTS ALL MUSIC RELATIVE TO THE USER AS PARAMETER
function get_userMusic($user,$notice)
{
$n = 0;
$user = $user + 1;
$day = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
$songs = mysql_query("SELECT x.song_name,y.band_name,x.song_time,x.band_id FROM jamroom_song_info x,jamroom_band_info y WHERE x.band_id=y.band_id and x.band_id=\"$user\"");
if ($therow = mysql_fetch_array($songs))
{
do
{
$action[$n]["from"] = "<a target=\"_top\" href=\"members/" . $therow["band_id"] . "/\">" . $therow["band_name"] . "</a>";
$action[$n]["to"] = "";
$action[$n]["what"] = $therow["song_name"];
$action[$n]["when"] = $therow["song_time"];
$action[$n]["notice"] = $notice;
$action[$n]["type"] = "music";
$n++;
}
while ($therow = mysql_fetch_array($comments));
return $action;
}
}
//SELECTS ALL BLOGS RELATIVE TO THE USER AS PARAMETER
function get_userBlog($user,$notice)
{
$n = 0;
$day = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
$user = $user + 1;
$comments = mysql_query("SELECT x.message_update,x.band_id,x.message_title,y.band_name FROM jamroom_messages x,jamroom_band_info y WHERE x.band_id=y.band_id AND x.band_id=\"$user\"");
if ($therow = mysql_fetch_array($comments))
{
do
{
$id = $therow["band_id"];
$action[$n]["from"] = "<a target=\"_top\" href=\"members/" . $id . "/\">" . $therow["band_name"] . "</a>";
$action[$n]["to"] = "";
$action[$n]["what"] = $therow["message_title"];
$action[$n]["when"] = $therow["message_update"];
$action[$n]["notice"] = $notice;
$action[$n]["type"] = "blog";
$n++;
}
while ($therow = mysql_fetch_array($comments));
return $action;
}
}
//SELECTS Fans
function get_userFan($user,$notice)
{
$n = 0;
$day = mktime(0, 0, 0, date("m") , date("d")-4, date("Y"));
$comments = mysql_query("SELECT x.fan_id,y.user_nickname,z.band_name,x.fan_time, x.band_id FROM jamroom_band_fans x,jamroom_user y, jamroom_band_info z WHERE x.band_id = z.band_id AND x.fan_id=y.user_id AND x.band_id=\"$user\"");
if ($therow = mysql_fetch_array($comments))
{
do
{
$action[$n]["from"] = "<a target=\"_top\" href=\"members/" . $therow["band_id"] . "/\">" . $therow["band_name"] . "</a>";
$action[$n]["to"] = "<a target=\"_top\" href=\"members/" . $therow["fan_id"] . "/\">" . $therow["user_nickname"] . "</a>";
$action[$n]["what"] = "Friend Link Completed";
$action[$n]["when"] = $therow["fan_time"];
$action[$n]["notice"] = $notice;
$action[$n]["type"] = "poll-answer";
$n++;
}
while ($therow = mysql_fetch_array($comments));
return $action;
}
}
function get_friendsActivity($user)
{
$commentsMsg = " sent a comment to ";
$bulletinsMsg = " wrote this bulletin: ";
$shoutsMsg = " wrote in the shoutbox: ";
$eventsMsg = " will make this event ";
$favMsg = ", as a friend, prefers ";
$blogMsg = " wrote this new blog:";
$videoMsg = " uploaded this video: ";
$videoCommentsMsg = " thinks this about this video ";
$musicMsg = " uploaded the song ";
$pollsMsg = " wants you to answer: ";
$pollVoteMsg = " answered to the poll ";
$isFriend = " has added as a friend: ";
//GET ALL THE USER'S FRIENDS
$ALLfriends = mysql_query("SELECT fan_id FROM `jamroom_band_fans` WHERE band_id=\"$user\"");
//IF THE USER HAS FRIENDS, GET THEIR ACTIVITY AND ADD EM TO EVERYONE'S
if ($row = mysql_fetch_array($ALLfriends))
{
do
{
if($row["fan_id"]!=$user)
{
//GET ALL COMMENTS
$newArray = get_userComments($row["fan_id"],$commentsMsg);
if(is_array($activity)&&is_array($newArray))
{
$activity = array_merge($activity,$newArray);
}
else if(!is_array($activity)&&is_array($newArray))
{
$activity = $newArray;
}
//GET UPLOADED MUSIC
$newArray = get_userMusic($row["fan_id"],$musicMsg);
if(is_array($activity)&&is_array($newArray))
{
$activity = array_merge($activity,$newArray);
}else if(!is_array($activity)&&is_array($newArray))
{
$activity = $newArray;
}
//GET BLOG
$newArray = get_userBlog($row["fan_id"],$blogMsg);
if(is_array($activity)&&is_array($newArray)){
$activity = array_merge($activity,$newArray);
}else if(!is_array($activity)&&is_array($newArray)){
$activity = $newArray;
}
//GET FANS
$newArray = get_userFan($row["fan_id"],$isFriend);
if(is_array($activity)&&is_array($newArray)){
$activity = array_merge($activity,$newArray);
}else if(!is_array($activity)&&is_array($newArray)){
$activity = $newArray;
}
}
}
while ($row = mysql_fetch_array($ALLfriends));
}
return $activity;
}
?> |