[26635] | 1 | <?php |
---|
| 2 | load_language('plugin.lang', SPBA_PATH); |
---|
| 3 | |
---|
| 4 | global $page, $conf, $user, $template; |
---|
[27391] | 5 | |
---|
[27392] | 6 | $testa = explode('user-', $_SERVER['REQUEST_URI']); |
---|
| 7 | if (!empty ($testa[1])) |
---|
| 8 | { |
---|
| 9 | $testd= explode('/', $testa[1]); |
---|
| 10 | $me = 'user-'.$testd[0]; |
---|
[27391] | 11 | $page['section'] = $me; |
---|
[27473] | 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.'">'.l10n('Users').'-'.$testd[0].'</a>'; |
---|
[27391] | 13 | |
---|
| 14 | $query = ' |
---|
| 15 | SELECT id, username |
---|
| 16 | FROM ' . USERS_TABLE . ' |
---|
[27392] | 17 | WHERE username = \''.$testd[0].'\' |
---|
[27391] | 18 | ;'; |
---|
| 19 | $result = pwg_query($query); |
---|
| 20 | $row = pwg_db_fetch_assoc($result); |
---|
[27392] | 21 | $coutantuser = $row['id']; |
---|
[27391] | 22 | $template->assign( |
---|
| 23 | 'gestionB', |
---|
| 24 | array( |
---|
[27392] | 25 | 'USERUSBU' => $testd[0], |
---|
[27391] | 26 | )); |
---|
| 27 | |
---|
| 28 | $query = ' |
---|
| 29 | SELECT 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 | } |
---|
| 55 | else |
---|
| 56 | { |
---|
| 57 | $me = 'user-'; |
---|
| 58 | $page['section'] = $me; |
---|
[27473] | 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.'">'.l10n('Users').'</a>'; |
---|
[27391] | 60 | } |
---|
[27428] | 61 | $showSPBU = $conf['see_photos_by_user_show']; |
---|
| 62 | |
---|
[27459] | 63 | if (in_array($showSPBU, array(1,2,3,5))) |
---|
[27428] | 64 | { |
---|
[26635] | 65 | //read auteur list |
---|
| 66 | $groups = array(); |
---|
[27391] | 67 | |
---|
[26635] | 68 | $query = ' |
---|
[27396] | 69 | SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id |
---|
[27391] | 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 | |
---|
[26635] | 88 | $result = pwg_query($query); |
---|
| 89 | |
---|
| 90 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[26643] | 91 | { |
---|
[27391] | 92 | $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')'; |
---|
[26643] | 93 | } |
---|
| 94 | $selected = 0; |
---|
[27459] | 95 | if (empty ($testd[0])) |
---|
[27391] | 96 | {$options[] = l10n('select user');} |
---|
| 97 | else |
---|
| 98 | {$options[] = l10n('select other user');} |
---|
[26635] | 99 | $options['a'] = '----------------------'; |
---|
| 100 | |
---|
| 101 | foreach ($groups as $metalist => $metalist2) |
---|
| 102 | { |
---|
[26643] | 103 | $options[$metalist] = $metalist2; |
---|
[26635] | 104 | } |
---|
| 105 | $template->assign( |
---|
| 106 | 'gestionA', |
---|
| 107 | array( |
---|
| 108 | 'OPTIONS' => $options, |
---|
| 109 | 'SELECTED' => $selected |
---|
| 110 | )); |
---|
| 111 | |
---|
| 112 | if (isset($_POST['submitchoixauteur'])) |
---|
[26643] | 113 | { |
---|
[27391] | 114 | $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']); |
---|
| 115 | redirect($redirect_url); |
---|
| 116 | } |
---|
[26635] | 117 | |
---|
[26643] | 118 | $template->assign('SPBA2', 'toto'); |
---|
[26635] | 119 | $template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl')); |
---|
[27472] | 120 | //$template->assign_var_from_handle('CONTENT', 'SPBA'); |
---|
| 121 | $template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEGIN', 'SPBA'); |
---|
| 122 | } |
---|
[26635] | 123 | ?> |
---|