source: extensions/see_photos_by_user/pagespba.php @ 27391

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

[extensions] - see_photos_by_user - new options

File size: 2.5 KB
RevLine 
[26635]1<?php
2load_language('plugin.lang', SPBA_PATH);
3
4global $page, $conf, $user, $template;
[27391]5
6$testd = explode('user-', $_SERVER['REQUEST_URI']); 
7if (!empty ($testd[1]))
8{$me = 'user-'.$testd[1];
9$page['section'] = $me;
10
11$query = '
12SELECT 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 = '
25SELECT 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}
51else
52{
53$me = 'user-';
54$page['section'] = $me;
55}
[26635]56//read auteur list
57$groups = array();
[27391]58
[26635]59$query = '
[27391]60SELECT 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
[26635]79$result = pwg_query($query);
80
81while ($row = pwg_db_fetch_assoc($result))
[26643]82 {
[27391]83  $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')';
[26643]84}
85  $selected = 0;
[27391]86  if (empty ($testd[1]))
87        {$options[] = l10n('select user');}
88 else
89  {$options[] = l10n('select other user');}
[26635]90        $options['a'] = '----------------------';
91
92  foreach ($groups as $metalist => $metalist2)
93        {
[26643]94   $options[$metalist] = $metalist2;
[26635]95        }
96  $template->assign(
97    'gestionA',
98    array(
99      'OPTIONS' => $options,
100      'SELECTED' => $selected
101      ));
102       
103if (isset($_POST['submitchoixauteur']))
[26643]104 {
[27391]105 $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']);
106 redirect($redirect_url);
107 }
[26635]108
[26643]109$template->assign('SPBA2', 'toto');
[26635]110$template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl'));
111$template->assign_var_from_handle('CONTENT', 'SPBA');
112?>
Note: See TracBrowser for help on using the repository browser.