source: extensions/see_photos_by_user/pagespba.php @ 27472

Last change on this file since 27472 was 27472, checked in by ddtddt, 11 years ago

[extensions] - see_photos_by_user - new title page section / change for 2.5

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