1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: See My Photos |
---|
4 | Version: auto |
---|
5 | Description: See photos I've added |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=722 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://temmii.com/piwigo/ |
---|
9 | */ |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | // | See My Photos plugin for piwigo by TEMMII | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | Copyright(C) 2014 - 2021 ddtddt http://temmii.com/piwigo/ | |
---|
14 | // +-----------------------------------------------------------------------+ |
---|
15 | // | This program is free software; you can redistribute it and/or modify | |
---|
16 | // | it under the terms of the GNU General Public License as published by | |
---|
17 | // | the Free Software Foundation | |
---|
18 | // | | |
---|
19 | // | This program is distributed in the hope that it will be useful, but | |
---|
20 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
21 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
22 | // | General Public License for more details. | |
---|
23 | // | | |
---|
24 | // | You should have received a copy of the GNU General Public License | |
---|
25 | // | along with this program; if not, write to the Free Software | |
---|
26 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
27 | // | USA. | |
---|
28 | // +-----------------------------------------------------------------------+ |
---|
29 | |
---|
30 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
31 | |
---|
32 | |
---|
33 | define('SMP_DIR' , basename(dirname(__FILE__))); |
---|
34 | define('SMP_PATH' , PHPWG_PLUGINS_PATH . SMP_DIR . '/'); |
---|
35 | |
---|
36 | add_event_handler('blockmanager_apply' , 'add_link_SMP'); |
---|
37 | add_event_handler('loc_end_section_init', 'section_init_SMP'); |
---|
38 | |
---|
39 | add_event_handler('loading_lang', 'see_my_photos_loading_lang'); |
---|
40 | function see_my_photos_loading_lang(){ |
---|
41 | load_language('plugin.lang', SMP_PATH); |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | function add_link_SMP($menu_ref_arr){ |
---|
46 | global $conf, $user; |
---|
47 | $query = ' |
---|
48 | SELECT DISTINCT(id) |
---|
49 | FROM '.IMAGES_TABLE.' |
---|
50 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
---|
51 | '.get_sql_condition_FandF |
---|
52 | ( |
---|
53 | array |
---|
54 | ( |
---|
55 | 'forbidden_categories' => 'category_id', |
---|
56 | 'visible_categories' => 'category_id', |
---|
57 | 'visible_images' => 'id' |
---|
58 | ), |
---|
59 | 'WHERE' |
---|
60 | ).' |
---|
61 | AND added_by = \''.$user['id'].'\';'; |
---|
62 | $result = pwg_query($query); |
---|
63 | $row = pwg_db_fetch_assoc($result); |
---|
64 | $nbp=count(array_from_query($query, 'id')); |
---|
65 | if (!is_a_guest() and !empty($row)){ |
---|
66 | $menu = & $menu_ref_arr[0]; |
---|
67 | if (($block = $menu->get_block('mbSpecials')) != null){ |
---|
68 | $position = (isset($conf['SMP_position']) and is_numeric($conf['SMP_position'])) ? $conf['SMP_position'] : count($block->data)+1; |
---|
69 | array_splice($block->data, $position-1, 0, array('see_my_photos' => |
---|
70 | array( |
---|
71 | 'URL' => make_index_url(array('section' => 'see_my_photos')), |
---|
72 | 'TITLE' => l10n('My photos'), |
---|
73 | 'NAME' => l10n('My photos').' ('.$nbp.')', |
---|
74 | ))); |
---|
75 | } |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | function section_init_SMP(){ |
---|
80 | global $tokens; |
---|
81 | if (in_array('see_my_photos', $tokens)) |
---|
82 | include(SMP_PATH . 'pagessmp.php'); |
---|
83 | } |
---|
84 | ?> |
---|