-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathalbum_personal_index.php
More file actions
158 lines (138 loc) · 5.49 KB
/
album_personal_index.php
File metadata and controls
158 lines (138 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
*
* @package InfinityCoreCMS
* @version $Id$
* @copyright (c) 2008 InfinityCoreCMS
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* Smartor (smartor_xp@hotmail.com)
*
*/
define('IN_INFINITYCORECMS', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// Get general album information
include(ALBUM_MOD_PATH . 'album_common.' . PHP_EXT);
$start = request_var('start', 0);
$start = ($start < 0) ? 0 : $start;
$mode = request_var('mode', 'joined');
$sort_order = request_var('order', 'ASC');
$sort_order = ($sort_order == 'ASC') ? 'ASC' : 'DESC';
//
// Memberlist sorting
//
$mode_types_text = array($lang['SORT_JOINED'], $lang['SORT_USERNAME'], $lang['Pics'], $lang['Last_Pic']);
$mode_types = array('joindate', 'username', 'pics', 'last_pic');
$select_sort_mode = '<select name="mode">';
for($i = 0; $i < sizeof($mode_types_text); $i++)
{
$selected = ($mode == $mode_types[$i]) ? ' selected="selected"' : '';
$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';
$select_sort_order = '<select name="order">';
if($sort_order == 'ASC')
{
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
}
else
{
$select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
}
$select_sort_order .= '</select>';
/*
+----------------------------------------------------------
| Start output the page
+----------------------------------------------------------
*/
$nav_server_url = create_server_url();
$album_nav_cat_desc = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album_personal_index.' . PHP_EXT) . '" class="nav-current">' . $lang['Users_Personal_Galleries'] . '</a>';
$breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc;
$template->assign_vars(array(
'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
'L_ORDER' => $lang['Order'],
'L_SORT' => $lang['Sort'],
'L_JOINED' => $lang['Joined'],
'L_PICS' => $lang['Pics'],
'L_USERS_PERSONAL_GALLERIES' => $lang['Users_Personal_Galleries'],
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
'S_MODE_ACTION' => append_sid(album_append_uid('album_personal_index.' . PHP_EXT))
)
);
switch($mode)
{
case 'joined':
$order_by = "user_regdate ASC LIMIT $start, " . $config['topics_per_page'];
break;
case 'username':
$order_by = "username $sort_order LIMIT $start, " . $config['topics_per_page'];
break;
case 'pics':
$order_by = "pics $sort_order LIMIT $start, " . $config['topics_per_page'];
break;
case 'last_pic':
$order_by = "last_pic $sort_order LIMIT $start, " . $config['topics_per_page'];
break;
default:
$order_by = "user_regdate $sort_order LIMIT $start, " . $config['topics_per_page'];
break;
}
$sql = "SELECT u.username, u.user_id, u.user_active, u.user_color, u.user_regdate, COUNT(p.pic_id) AS pics, MAX(p.pic_id) AS last_pic, COUNT(c.cat_user_id) AS cats
FROM " . USERS_TABLE . " AS u, " . ALBUM_TABLE . " AS p, " . ALBUM_CAT_TABLE . " AS c
WHERE u.user_id <> " . ANONYMOUS . "
AND c.cat_user_id = u.user_id
AND c.cat_id = p.pic_cat_id
GROUP BY user_id
ORDER BY $order_by";
$result = $db->sql_query($sql);
$memberrow = array();
while($row = $db->sql_fetchrow($result))
{
$memberrow[] = $row;
}
$row_class = '';
for ($i = 0; $i < sizeof($memberrow); $i++)
{
$username = colorize_username($memberrow[$i]['user_id'], $memberrow[$i]['username'], $memberrow[$i]['user_color'], $memberrow[$i]['user_active'], true, false, false, false);
$row_class = ip_zebra_rows($row_class);
$template->assign_block_vars('memberrow', array(
'ROW_CLASS' => $row_class,
'USERNAME' => $username,
'U_VIEWGALLERY' => append_sid(album_append_uid('album.' . PHP_EXT . '?user_id=' . $memberrow[$i]['user_id'])),
//'U_VIEWGALLERY' => append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . album_get_personal_root_id($memberrow[$i]['user_id']) . 'user_id=' . $memberrow[$i]['user_id'])),
'JOINED' => create_date($lang['DATE_FORMAT'], $memberrow[$i]['user_regdate'], $config['board_timezone']),
'PICS' => $memberrow[$i]['pics']
)
);
}
$sql = "SELECT COUNT(DISTINCT u.user_id) AS total
FROM " . USERS_TABLE . " AS u, " . ALBUM_TABLE . " AS p, " . ALBUM_CAT_TABLE . " AS c
WHERE u.user_id <> " . ANONYMOUS . "
AND c.cat_user_id = u.user_id
AND c.cat_id = p.pic_cat_id";
$result = $db->sql_query($sql);
$pagination = ' ';
if ($total = $db->sql_fetchrow($result))
{
$total_galleries = $total['total'];
$pagination = generate_pagination('album_personal_index.' . PHP_EXT . '?mode=' . $mode . '&order=' . $sort_order, $total_galleries, $config['topics_per_page'], $start);
}
$template->assign_vars(array(
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $total_galleries / $config['topics_per_page'] ))
)
);
full_page_generation('album_personal_index_body.tpl', $lang['Album'], '', '');
?>