Everything
Timeline of the latest topics and ING updates of mine and my friends.
usr_id;
if ($timeline_cached = $c->load($tag_cache)) {
$_timeline = unserialize($timeline_cached);
} else {
/* Create a new empty array for timeline. */
$_timeline = array();
/* Get 30 new topics and convert them. */
$sql = "SELECT usr_id, usr_nick, usr_gender, usr_portrait, tpc_id, tpc_title, tpc_hits, tpc_posts, tpc_created, nod_id, nod_name, nod_title FROM babel_topic, babel_user, babel_node WHERE tpc_uid IN ({$all_sql}) AND tpc_uid = usr_id AND tpc_pid = nod_id ORDER BY tpc_created DESC LIMIT 30";
$rs = mysql_query($sql) or die ($sql . mysql_error());
while ($_topic = mysql_fetch_array($rs)) {
$_timeline[$_topic['tpc_created']] = array();
$_timeline[$_topic['tpc_created']]['type'] = 'topic';
$_timeline[$_topic['tpc_created']]['link'] = '/topic/view/' . $_topic['tpc_id'] . '.html';
$_timeline[$_topic['tpc_created']]['weight'] = Dashboard::vxCalcWeightFromTopic($_topic['tpc_hits'], $_topic['tpc_posts']);
$_timeline[$_topic['tpc_created']]['title'] = $_topic['tpc_title'];
$_timeline[$_topic['tpc_created']]['usr_nick'] = $_topic['usr_nick'];
$_timeline[$_topic['tpc_created']]['img_p'] = ($_topic['usr_portrait'] == '') ? '/img/p_' . $_topic['usr_gender'] . '_n.gif' : '/img/p/' . $_topic['usr_portrait'] . '_n.jpg';
$_timeline[$_topic['tpc_created']]['nod_name'] = $_topic['nod_name'];
$_timeline[$_topic['tpc_created']]['nod_title'] = $_topic['nod_title'];
}
mysql_free_result($rs);
/* Get 20 new ING updates and convert them. */
$sql = "SELECT usr_id, usr_nick, usr_gender, usr_portrait, ing_id, ing_doing, ing_created FROM babel_ing_update, babel_user WHERE usr_id = ing_uid AND ing_uid IN ({$all_sql}) ORDER BY ing_created DESC LIMIT 20";
$rs = mysql_query($sql);
while ($_ing = mysql_fetch_array($rs)) {
$_timeline[$_ing['ing_created']] = array();
$_timeline[$_ing['ing_created']]['type'] = 'ing';
$_timeline[$_ing['ing_created']]['link'] = '/ing-' . $_ing['ing_id'] . '.html';
$_timeline[$_ing['ing_created']]['weight'] = 12;
$_timeline[$_ing['ing_created']]['title'] = $_ing['ing_doing'];
$_timeline[$_ing['ing_created']]['usr_nick'] = $_ing['usr_nick'];
$_timeline[$_ing['ing_created']]['img_p'] = ($_ing['usr_portrait'] == '') ? '/img/p_' . $_ing['usr_gender'] . '_n.gif' : '/img/p/' . $_ing['usr_portrait'] . '_n.jpg';
}
/* Sort the timeline. */
krsort($_timeline);
$c->save(serialize($_timeline), $tag_cache);
}
foreach ($_timeline as $time => $event) {
echo('
');
switch ($event['type']) {
case 'topic':
echo('
');
echo('
');
break;
case 'ing':
echo('
');
echo('
');
break;
}
echo('
');
}
?>