1 | <?php |
---|
2 | load_language('plugin.lang', SPBA_PATH); |
---|
3 | |
---|
4 | global $page, $conf, $user, $template; |
---|
5 | |
---|
6 | $testd = explode('user-', $_SERVER['REQUEST_URI']); |
---|
7 | if (!empty ($testd[1])) |
---|
8 | {$me = 'user-'.$testd[1]; |
---|
9 | $page['section'] = $me; |
---|
10 | |
---|
11 | $query = ' |
---|
12 | SELECT id, username |
---|
13 | FROM ' . USERS_TABLE . ' |
---|
14 | WHERE username = \''.$testd[1].'\' |
---|
15 | ;'; |
---|
16 | $result = pwg_query($query); |
---|
17 | $row = pwg_db_fetch_assoc($result); |
---|
18 | $template->assign( |
---|
19 | 'gestionB', |
---|
20 | array( |
---|
21 | 'USERUSBU' => $testd[1], |
---|
22 | )); |
---|
23 | |
---|
24 | $query = ' |
---|
25 | SELECT DISTINCT(id) |
---|
26 | FROM '.IMAGES_TABLE.' |
---|
27 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
---|
28 | '.get_sql_condition_FandF |
---|
29 | ( |
---|
30 | array |
---|
31 | ( |
---|
32 | 'forbidden_categories' => 'category_id', |
---|
33 | 'visible_categories' => 'category_id', |
---|
34 | 'visible_images' => 'id' |
---|
35 | ), |
---|
36 | 'WHERE' |
---|
37 | ).' |
---|
38 | AND added_by = \''.$row['id'].'\' |
---|
39 | '.$conf['order_by'].' |
---|
40 | ;'; |
---|
41 | $page = array_merge |
---|
42 | ( |
---|
43 | $page, |
---|
44 | array |
---|
45 | ( |
---|
46 | 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'.$me.'</a>', |
---|
47 | 'items' => array_from_query($query, 'id'), |
---|
48 | ) |
---|
49 | ); |
---|
50 | } |
---|
51 | else |
---|
52 | { |
---|
53 | $me = 'user-'; |
---|
54 | $page['section'] = $me; |
---|
55 | } |
---|
56 | //read auteur list |
---|
57 | $groups = array(); |
---|
58 | |
---|
59 | $query = ' |
---|
60 | SELECT UT.id, UT.username, COUNT(IT.id) AS PBU, IT.id |
---|
61 | FROM ' . USERS_TABLE . ' as UT |
---|
62 | INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id |
---|
63 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id |
---|
64 | '.get_sql_condition_FandF |
---|
65 | ( |
---|
66 | array |
---|
67 | ( |
---|
68 | 'forbidden_categories' => 'category_id', |
---|
69 | 'visible_categories' => 'category_id', |
---|
70 | 'visible_images' => 'id' |
---|
71 | ), |
---|
72 | 'WHERE' |
---|
73 | ).' |
---|
74 | GROUP BY IT.added_by |
---|
75 | HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].' |
---|
76 | ORDER BY '.$conf['see_photos_by_user_order'].' |
---|
77 | LIMIT '.$conf['see_photos_by_user_limit'].';'; |
---|
78 | |
---|
79 | $result = pwg_query($query); |
---|
80 | |
---|
81 | while ($row = pwg_db_fetch_assoc($result)) |
---|
82 | { |
---|
83 | $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')'; |
---|
84 | } |
---|
85 | $selected = 0; |
---|
86 | if (empty ($testd[1])) |
---|
87 | {$options[] = l10n('select user');} |
---|
88 | else |
---|
89 | {$options[] = l10n('select other user');} |
---|
90 | $options['a'] = '----------------------'; |
---|
91 | |
---|
92 | foreach ($groups as $metalist => $metalist2) |
---|
93 | { |
---|
94 | $options[$metalist] = $metalist2; |
---|
95 | } |
---|
96 | $template->assign( |
---|
97 | 'gestionA', |
---|
98 | array( |
---|
99 | 'OPTIONS' => $options, |
---|
100 | 'SELECTED' => $selected |
---|
101 | )); |
---|
102 | |
---|
103 | if (isset($_POST['submitchoixauteur'])) |
---|
104 | { |
---|
105 | $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']); |
---|
106 | redirect($redirect_url); |
---|
107 | } |
---|
108 | |
---|
109 | $template->assign('SPBA2', 'toto'); |
---|
110 | $template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl')); |
---|
111 | $template->assign_var_from_handle('CONTENT', 'SPBA'); |
---|
112 | ?> |
---|