2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 /* This file is used by both the photo album and the my start page->profile picture */
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 include (AT_PA_INCLUDE.'lib.inc.php');
17 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
18 //$_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
19 $_custom_head .= '<script src="'.$_base_path . AT_PA_BASENAME . 'include/ajaxupload.js" type="text/javascript"></script>';
20 $member_id = intval($_GET['member_id']);
21 $member_id = ($member_id==0)? $_SESSION['member_id']: $member_id;
23 //run a check to see if any personal album exists, if not, create one.
24 $sql = 'SELECT * FROM '.TABLE_PREFIX.'pa_albums WHERE member_id='.$_SESSION['member_id'].' AND type_id='.AT_PA_TYPE_PERSONAL;
25 $result = mysql_query($sql, $db);
27 $rows = mysql_num_rows($result);
30 $pa = new PhotoAlbum();
31 $result = $pa->createAlbum(_AT('pa_profile_album'), '', '', AT_PA_TYPE_PERSONAL, AT_PA_PRIVATE_ALBUM, $_SESSION['member_id']);
32 $id = mysql_insert_id();
34 $row = mysql_fetch_assoc($result); //album info.
40 $pa = new PhotoAlbum($id);
41 $info = $pa->getAlbumInfo();
44 $page = intval($_GET['p']);
45 $photos_count = sizeof($pa->getAlbumPhotos());
46 $last_page = ceil($photos_count/AT_PA_PHOTOS_PER_PAGE);
48 if (!$page || $page < 0) {
50 } elseif ($page > $last_page){
54 $count = (($page-1) * AT_PA_PHOTOS_PER_PAGE) + 1;
55 $offset = ($page-1) * AT_PA_PHOTOS_PER_PAGE;
58 $photos = $pa->getAlbumPhotos($offset);
59 $comments = $pa->getComments($id, false);
60 //TODO: Can improve performance by adding this to a session variable
61 $memory_usage = memoryUsage($_SESSION['member_id']);
63 include (AT_INCLUDE_PATH.'header.inc.php');
64 $savant->assign('album_info', $info);
65 $savant->assign('photos', $photos);
66 $savant->assign('comments', $comments);
67 $savant->assign('page', $page);
68 $savant->assign('num_rows', $photos_count);
69 $savant->assign('memory_usage', $memory_usage/(1024*1024)); //mb
70 $savant->assign('allowable_memory_usage', $_config['pa_max_memory_per_member']); //mb
71 $savant->assign('action_permission', $pa->checkAlbumPriv($_SESSION['member_id']));
72 $savant->display('photos/pa_profile_albums.tmpl.php');
73 include (AT_INCLUDE_PATH.'footer.inc.php');