source: extensions/see_photos_by_user/pagespba.php @ 27429

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

[extensions] - see_photos_by_user -

File size: 2.6 KB
RevLine 
[26635]1<?php
2load_language('plugin.lang', SPBA_PATH);
3
4global $page, $conf, $user, $template;
[27391]5
[27392]6$testa = explode('user-', $_SERVER['REQUEST_URI']); 
7if (!empty ($testa[1]))
8{
9$testd= explode('/', $testa[1]);
10$me = 'user-'.$testd[0];
[27391]11$page['section'] = $me;
12
13$query = '
14SELECT id, username
15 FROM ' . USERS_TABLE . '
[27392]16 WHERE username = \''.$testd[0].'\'
[27391]17;';
18$result = pwg_query($query);
19$row = pwg_db_fetch_assoc($result);
[27392]20$coutantuser = $row['id'];
[27391]21  $template->assign(
22    'gestionB',
23    array(
[27392]24      'USERUSBU' => $testd[0],
[27391]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}
[27428]59$showSPBU = $conf['see_photos_by_user_show'];
60
[27429]61if (in_array($showSPBU, array(1,2,3)))
[27428]62{
[26635]63//read auteur list
64$groups = array();
[27391]65
[26635]66$query = '
[27396]67SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
[27391]68 FROM ' . USERS_TABLE . ' as UT
69 INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
70 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
71  '.get_sql_condition_FandF
72  (
73    array
74      (
75        'forbidden_categories' => 'category_id',
76        'visible_categories' => 'category_id',
77        'visible_images' => 'id'
78      ),
79    'WHERE'
80  ).'
81 GROUP BY IT.added_by
82 HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
83 ORDER BY '.$conf['see_photos_by_user_order'].'
84 LIMIT '.$conf['see_photos_by_user_limit'].';';
85
[26635]86$result = pwg_query($query);
87
88while ($row = pwg_db_fetch_assoc($result))
[26643]89 {
[27391]90  $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')';
[26643]91}
92  $selected = 0;
[27391]93  if (empty ($testd[1]))
94        {$options[] = l10n('select user');}
95 else
96  {$options[] = l10n('select other user');}
[26635]97        $options['a'] = '----------------------';
98
99  foreach ($groups as $metalist => $metalist2)
100        {
[26643]101   $options[$metalist] = $metalist2;
[26635]102        }
103  $template->assign(
104    'gestionA',
105    array(
106      'OPTIONS' => $options,
107      'SELECTED' => $selected
108      ));
109       
110if (isset($_POST['submitchoixauteur']))
[26643]111 {
[27391]112 $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']);
113 redirect($redirect_url);
114 }
[26635]115
[26643]116$template->assign('SPBA2', 'toto');
[26635]117$template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl'));
[27428]118$template->assign_var_from_handle('CONTENT', 'SPBA');}
[26635]119?>
Note: See TracBrowser for help on using the repository browser.