/** * * @author Ben Dodson * @since 1/27/05 * @version 1/27/05 * @param $type (defaults to nodes) * @param $distance (distance from where we are, defaults no false) * @param $limit how many items to return (defaults to 10) * **/ function getRecentlyPlayed($type = "nodes", $distance = false, $limit = 10) { if ($distance === false) { $distance = $this->getNaturalDepth(); } $pathArray = $this->getPath(); $level = $this->getLevel(); $pathString = jz_db_escape($this->getPath("String")); if ($pathString != "") { $pathString .= "/"; } $sql = "SELECT path,leaf FROM jz_nodes"; if (!($link = jz_db_connect())) { die("could not connect to database."); } if ($distance <= 0) { $sql .= " WHERE level > {$level}"; } else { $level = $level + $distance; $sql .= " WHERE level = {$level}"; } $sql .= " AND path LIKE '{$pathString}%' AND lastplayed != 0"; if ($type == "tracks" || $type == "leaves") { $sql .= " AND leaf = 'true'"; } else { if ($type == "nodes") { $sql .= " AND leaf = 'false'"; } } $sql .= " ORDER BY lastplayed desc LIMIT {$limit}"; return jz_db_object_query($sql); }
/** * Returns a user's play history * * @author Ben Dodson * @since 11/24/09 */ function getPlayHistory($for = false) { $for = jz_db_escape($for); $q = "SELECT n.*,p.user FROM jz_playcounts p,jz_nodes n WHERE p.media_id=n.my_id"; if ($for) { $q .= " AND p.user='******'"; } $q .= " AND n.ptype='track' GROUP BY p.media_id ORDER BY max(date) desc LIMIT 25"; $res = jz_db_object_query($q); // TODO: include user info in result return $res; }