Index: project_usage.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project/usage/project_usage.module,v retrieving revision 1.32 diff -u -p -r1.32 project_usage.module --- project_usage.module 17 Mar 2009 23:16:13 -0000 1.32 +++ project_usage.module 10 Apr 2009 18:56:04 -0000 @@ -143,6 +143,38 @@ function project_usage_perm() { } /** +* Return an array of the most active projects with the given taxonomy term. +* +* @return +* An array of of the most active projects. The array includes the node +* ID and node title. +*/ +function project_usage_get_most_active_projects($tid, $limit = 5) { + $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {project_projects} pp ON n.nid = pp.nid INNER JOIN {project_usage_week_project} pw ON pp.nid = pw.nid INNER JOIN {term_node} tn ON tn.nid = pp.nid WHERE pw.timestamp = (SELECT MAX(timestamp) FROM {project_usage_week_project}) AND tn.tid = %d AND n.status = 1 ORDER BY pw.count DESC LIMIT %d', $tid, $limit); + $projects = array(); + while ($project = db_fetch_object($result)) { + $projects[] = $project; + } + return $projects; +} + +/** +* Return an array of the most recently created projects with the given taxonomy term. +* +* @return +* An array of of the most recently created projects. The array includes the node +* ID and node title. +*/ +function project_usage_get_most_recent_projects($tid, $limit = 5) { + $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {project_projects} pp ON n.nid = pp.nid INNER JOIN {term_node} tn ON tn.nid = pp.nid WHERE tn.tid = %d AND n.status = 1 ORDER BY n.created DESC LIMIT %d', $tid, $limit); + $projects = array(); + while ($project = db_fetch_object($result)) { + $projects[] = $project; + } + return $projects; +} + +/** * Implementation of hook_simpletest(). */ function project_usage_simpletest() {