public function training() { if (!isset($_GET["username"])) { exit; } $user = User::fromUsername($_GET["username"]); $t_items = TrainingLog::getItemsForUser($user->uid); $feed = new Rss_Feed("Training entries for {$user->username}", "http://{$_SERVER["SERVER_NAME"]}", "Includes the training data for a given user."); $feed->pubDate = date(DATE_RSS); $feed->defineImageForFeed(new Rss_Image("running logo", "http://byroni.us", "http://runndaily.com/img/logo.png")); foreach ($t_items as $item) { $rss_item = new Rss_Item(); $rss_item->guid = "http://{$_SERVER["SERVER_NAME"]}/training/view/{$item->tid}"; $rss_item->link = "http://{$_SERVER["SERVER_NAME"]}/training/view/{$item->tid}"; $rss_item->description = "{$item->date} : {$item->distance} miles"; $rss_item->pubDate = date(DATE_RSS, $item->date); $rss_item->title = "{$user->username} logged an entry on " . date("F j, Y, g:i a", $item->date); $feed->addItemToFeed($rss_item); } //die(var_dump($feed)); RoutingEngine::getSmarty()->assign("RssFeed", $feed); $rss_out = RoutingEngine::getSmarty()->fetch("generic/rss.tpl"); header("Content-Type: application/rss+xml"); echo $rss_out; }
/** * Find or create the user from the username and the client_id * @param $username Username of the user * @param $client_id Client id of the user * @return User|null */ public static function findOrCreate($username, $client_id) { $user = User::fromUsername($username, $client_id); if ($user) { return $user; } User::create(new User(-1, $username, $client_id)); return User::fromUsername($username, $client_id); }