2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institution */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /***********************************************************************/
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 require(AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
17 require(AT_PA_INCLUDE.'lib.inc.php');
19 //Comparison Function, return reverse results
21 $a = strtotime($a['created_date']);
22 $b = strtotime($b['created_date']);
26 return ($a < $b) ? 1 : -1;
29 global $db, $_base_href;
31 $record_limit = 3; //Numero massimo dei possibili sottocontenuti visualizzabili nella home-page
32 $cnt = 0; // count number of returned forums
34 //grab comments and if new course album/photo
35 $pa = new PhotoAlbum();
36 $visible_albums = array_merge($pa->getAlbums($_SESSION['member_id'], AT_PA_TYPE_COURSE_ALBUM),
37 $pa->getAlbums($_SESSION['member_id'], AT_PA_TYPE_MY_ALBUM));
38 //check if there are any albums
39 if (empty($visible_albums)){
43 foreach($visible_albums as $album){
44 $album_ids .= $album['id'] . ', ';
46 $album_ids = substr($album_ids, 0, strlen($albums_ids) - 2);
49 $sql = 'SELECT * FROM '.TABLE_PREFIX.'pa_album_comments WHERE album_id IN ('.$album_ids.') ORDER BY created_date DESC';
50 $result = mysql_query($sql, $db);
51 while($row = mysql_fetch_assoc($result)){
52 $all_comments[] = $row;
56 $sql = 'SELECT c.*, p.album_id FROM '.TABLE_PREFIX.'pa_photo_comments c LEFT JOIN '.TABLE_PREFIX.'pa_photos p ON p.id=c.photo_id WHERE p.album_id IN ('.$album_ids.') ORDER BY created_date DESC';
57 $result = mysql_query($sql, $db);
58 while($row = mysql_fetch_assoc($result)){
59 $all_comments[] = $row;
62 if (empty($all_comments)){
66 //sort the comments by date in decrement order
67 uasort($all_comments, 'cmp');
69 //assign proper link to the comment list.
70 foreach($all_comments as $comment){
71 if (isset($comment['photo_id'])){
72 $list[] = _AT('comment').': <a href="'.$_base_href.AT_PA_BASENAME.'photo.php?aid='.$comment['album_id'].SEP.'pid='.$comment['photo_id'].'">'.htmlentities_utf82($comment['comment']).'</a>';
73 } elseif (isset($comment['album_id'])){
74 $list[] = _AT('comment').': <a href="'.$_base_href.AT_PA_BASENAME.'albums.php?id='.$comment['album_id'].'">'.htmlentities_utf82($comment['comment']).'</a>';
76 if (++$cnt >= $record_limit) break;
79 if (count($list) > 0) {