1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | See photos by user plugin for piwigo | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2014 - 2016 ddtddt http://temmii.com/piwigo/ | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | This program is free software; you can redistribute it and/or modify | |
---|
8 | // | it under the terms of the GNU General Public License as published by | |
---|
9 | // | the Free Software Foundation | |
---|
10 | // | | |
---|
11 | // | This program is distributed in the hope that it will be useful, but | |
---|
12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
14 | // | General Public License for more details. | |
---|
15 | // | | |
---|
16 | // | You should have received a copy of the GNU General Public License | |
---|
17 | // | along with this program; if not, write to the Free Software | |
---|
18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
19 | // | USA. | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | function see_username($id_user){ |
---|
22 | $query = 'SELECT id, username FROM ' . USERS_TABLE . ' WHERE id = \'' . $id_user . '\';'; |
---|
23 | $result = pwg_query($query); |
---|
24 | $row = pwg_db_fetch_assoc($result); |
---|
25 | $username = str_replace(' ','_',$row['username']); |
---|
26 | $username = str_replace('.','_',$username); |
---|
27 | return $username; |
---|
28 | } |
---|
29 | |
---|
30 | function see_userlist_nb_photo(){ |
---|
31 | global $conf; |
---|
32 | $query = ' |
---|
33 | SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU |
---|
34 | FROM ' . USERS_TABLE . ' as UT |
---|
35 | INNER JOIN ' . IMAGES_TABLE . ' AS IT ON IT.added_by = UT.id |
---|
36 | INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON IT.id = ic.image_id |
---|
37 | ' . get_sql_condition_FandF( |
---|
38 | array( |
---|
39 | 'forbidden_categories' => 'category_id', |
---|
40 | 'visible_categories' => 'category_id', |
---|
41 | 'visible_images' => 'id' |
---|
42 | ), 'WHERE' |
---|
43 | ) . ' |
---|
44 | GROUP BY IT.added_by |
---|
45 | HAVING PBU >' . $conf['see_photos_by_user_nbphotos'] . ' |
---|
46 | ORDER BY ' . $conf['see_photos_by_user_order'] . ' |
---|
47 | LIMIT ' . $conf['see_photos_by_user_limit'] . ';'; |
---|
48 | |
---|
49 | $result = pwg_query($query); |
---|
50 | return $result; |
---|
51 | } |
---|
52 | |
---|
53 | function see_nb_photo(){ |
---|
54 | $query = 'SELECT COUNT(DISTINCT(id)) AS PBU FROM ' . IMAGES_TABLE . ';'; |
---|
55 | $result = pwg_query($query); |
---|
56 | $row = pwg_db_fetch_assoc($result); |
---|
57 | return $row['PBU']; |
---|
58 | } |
---|
59 | |
---|
60 | ?> |
---|