/** * Returns the list of most recent news items that this person has been * mentioned in. * @param {number} count The max number of news items I need to retreive. */ public function getMostRecentNewsItems($count, $start = 0) { $s = mysql_query("\n SELECT a.id, a.title, a.link, a.time, a.place, a.source, a.photo\n FROM news_people AS p\n LEFT JOIN news_articles AS a ON p.idarticle = a.id\n WHERE p.idperson = {$this->id}\n ORDER BY a.time DESC\n LIMIT {$start}, {$count}"); $news = array(); while ($r = mysql_fetch_array($s)) { foreach ($this->allNames as $n) { $r['title'] = highlightStr($r['title'], $n); } foreach (split(" ", $this->displayName) as $n) { $r['title'] = highlightStr($r['title'], $n); } $r['people'] = getPeopleForNewsId($r['id'], array($this->id)); $r['above_seven'] = count($r['people']) - 7; $news[] = $r; } return $news; }
/** * Returns a list of most recent articles from the news tables. * @param $mod * @param $year * @param $count * @param {Array.<Number>} $restrict_to_ids The list of person ids that I * should restrict this search for news to. Only get news for this list * of people. Usually used for passing in the list of people one user * choses to follow, but could be used for other lists in the future as * well. * @return unknown_type */ function getMostRecentNewsArticles($mod, $year, $count, $source = 'mediafax', $restrict_to_ids = NULL) { $where_clause = ''; if ($mod != NULL && $year != NULL) { $where_clause = "AND h.what = '{$mod}/{$year}'"; } if ($restrict_to_ids) { $ids = implode(",", $restrict_to_ids); $where_clause .= " AND p.idperson in ({$ids})"; } $s = mysql_query("\n SELECT a.id, a.title, a.link, a.time, a.place, a.photo, p.idperson, a.source\n FROM news_people AS p\n LEFT JOIN news_articles AS a ON p.idarticle = a.id\n LEFT JOIN people_history AS h\n ON h.idperson = p.idperson\n WHERE a.source LIKE '{$source}'\n {$where_clause}\n GROUP BY a.id\n ORDER BY a.time DESC\n LIMIT 0, {$count}"); $news = array(); while ($r = mysql_fetch_array($s)) { $r['people'] = getPeopleForNewsId($r['id'], $restrict_to_ids); $r['above_seven'] = count($r['people']) - 7; $news[] = $r; } return $news; }