source: extensions/see_photos_by_user/pagespba.php @ 27396

Last change on this file since 27396 was 27396, checked in by ddtddt, 10 years ago

[extensions] - see_photos_by_user - erreur count select user list

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