Permalink
Browse files

adding talks given by this user

  • Loading branch information...
1 parent 884e875 commit 83b312fdc36124b56e9945cbc0e239fe711fab10 @lornajane lornajane committed May 1, 2012
@@ -21,12 +21,10 @@ public function getAction($request, $db) {
if(isset($request->url_elements[4])) {
switch($request->url_elements[4]) {
- /*
case 'talks':
$talk_mapper = new TalkMapper($db, $request);
- $list = $talk_mapper->getTalksByEventId($event_id, $resultsperpage, $start, $request, $verbose);
+ $list = $talk_mapper->getTalksBySpeaker($user_id, $resultsperpage, $start, $request, $verbose);
break;
- */
default:
throw new InvalidArgumentException('Unknown Subrequest', 404);
break;
@@ -146,4 +146,38 @@ protected function getTracks($talk_id) {
}
return $retval;
}
+
+ public function getTalksBySpeaker($user_id, $resultsperpage, $start, $verbose = false) {
+ // based on getBasicSQL() but needs the speaker table joins
+ $sql = 'select t.*, l.lang_name, e.event_tz_place, e.event_tz_cont, '
+ . '(select COUNT(ID) from talk_comments tc where tc.talk_id = t.ID) as comment_count, '
+ . '(select get_talk_rating(t.ID)) as avg_rating, '
+ . 'CASE
+ WHEN (((t.date_given - 3600*24) < '.mktime(0,0,0).') and (t.date_given + (3*30*3600*24)) > '.mktime(0,0,0).') THEN 1
+ ELSE 0
+ END as comments_enabled '
+ . 'from talks t '
+ . 'inner join events e on e.ID = t.event_id '
+ . 'inner join lang l on l.ID = t.lang '
+ . 'left join talk_speaker ts on t.id = ts.talk_id '
+ . 'where t.active = 1 and '
+ . 'e.active = 1 and '
+ . '(e.pending = 0 or e.pending is NULL) and '
+ . '(e.private <> "y" or e.private is NULL) and '
+ . 'ts.speaker_id = :user_id';
+ $sql .= $this->buildLimit($resultsperpage, $start);
+
+ $stmt = $this->_db->prepare($sql);
+ $response = $stmt->execute(array(
+ ':user_id' => $user_id
+ ));
+ if($response) {
+ $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $retval = $this->transformResults($results, $verbose);
+ return $retval;
+ }
+ return false;
+
+ }
+
}
@@ -107,6 +107,8 @@ public function transformResults($results, $verbose)
$list[$key]['verbose_uri'] = $base . '/' . $version . '/users/'
. $row['ID'] . '?verbose=yes';
$list[$key]['website_uri'] = 'http://joind.in/user/view/' . $row['ID'];
+ $list[$key]['talks_uri'] = $base . '/' . $version . '/users/'
+ . $row['ID'] . '/talks/';
}
}
$retval = array();

0 comments on commit 83b312f

Please sign in to comment.