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 /***********************************************************************/
14 $_user_location = 'public';
15 define('AT_INCLUDE_PATH', '../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
18 include (AT_PA_INCLUDE.'lib.inc.php');
19 $_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
20 $_custom_head .= '<script type="text/javascript" src="'.AT_PA_BASENAME.'include/imageReorderer.js"></script>';
22 $aid = intval($_GET['aid']);
23 $pid = intval($_GET['pid']);
26 $pa = new PhotoAlbum($aid);
29 $info = $pa->getAlbumInfo();
30 $photos = $pa->getAlbumPhotos();
31 $photo_info = $pa->getPhotoInfo($pid);
32 $comments = $pa->getComments($pid, true);
35 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['title'] = _AT('pa_albums') .' - '.$info['name'];
36 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent'] = AT_PA_BASENAME.'index.php';
37 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['children'] = array(
38 AT_PA_BASENAME.'photo.php',
40 $_pages[AT_PA_BASENAME.'photo.php']['parent'] = AT_PA_BASENAME.'albums.php?id='.$aid;
42 //TODO: Validate users, using permission and course album control.
43 if ($info['member_id'] != $_SESSION['member_id']){
44 $visible_albums = $pa->getAlbums($_SESSION['member_id'], $info['type_id']);
45 if(!isset($visible_albums[$aid]) && $info['permission']==AT_PA_PRIVATE_ALBUM){
47 $msg->addError("ACCESS_DENIED");
48 header('location: index.php');
53 if($pa->checkPhotoPriv($pid, $_SESSION['member_id']) || $pa->checkAlbumPriv($_SESSION['member_id'])){
54 $action_permission = true;
56 $action_permission = false;
59 //run a quick query to get the next and previous id
60 if (sizeof($photos) > 1){
61 $sql = 'SELECT id, ordering FROM '.TABLE_PREFIX.'pa_photos WHERE album_id='.$aid.' AND (ordering='.($photo_info['ordering']-1).' OR ordering='.($photo_info['ordering']+1).') ORDER BY ordering';
62 $result = mysql_query($sql, $db);
64 $prev = mysql_fetch_assoc($result);
65 $next = mysql_fetch_assoc($result);
67 //then reassign prev and next
69 if ($prev['ordering'] > $photo_info['ordering']){
79 include (AT_INCLUDE_PATH.'header.inc.php');
80 $savant->assign('total_photos', sizeof($photos));
81 $savant->assign('prev', $prev);
82 $savant->assign('next', $next);
83 $savant->assign('aid', $aid);
84 $savant->assign('photo_info', $photo_info);
85 $savant->assign('comments', $comments);
86 $savant->assign('action_permission', $action_permission);
87 $savant->display('pa_photo.tmpl.php');
88 include (AT_INCLUDE_PATH.'footer.inc.php');