source: extensions/see_photos_by_user/pagespba.php @ 27428

Revision 27428, 2.7 KB checked in by ddtddt, 5 years ago (diff)

[extensions] - see_photos_by_user - new function menu / show

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$showSPBU = $conf['see_photos_by_user_show'];
60
61if ($showSPBU == 1 OR $showSPBU == 2 OR $showSPBU == 3)
62{
63//read auteur list
64$groups = array();
65
66$query = '
67SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
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
86$result = pwg_query($query);
87
88while ($row = pwg_db_fetch_assoc($result))
89 {
90  $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')';
91}
92  $selected = 0;
93  if (empty ($testd[1]))
94        {$options[] = l10n('select user');}
95 else
96  {$options[] = l10n('select other user');}
97        $options['a'] = '----------------------';
98
99  foreach ($groups as $metalist => $metalist2)
100        {
101   $options[$metalist] = $metalist2;
102        }
103  $template->assign(
104    'gestionA',
105    array(
106      'OPTIONS' => $options,
107      'SELECTED' => $selected
108      ));
109       
110if (isset($_POST['submitchoixauteur']))
111 {
112 $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']);
113 redirect($redirect_url);
114 }
115
116$template->assign('SPBA2', 'toto');
117$template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl'));
118$template->assign_var_from_handle('CONTENT', 'SPBA');}
119?>
Note: See TracBrowser for help on using the repository browser.