source: extensions/see_my_photos/main.inc.php @ 31953

Last change on this file since 31953 was 31459, checked in by ddtddt, 8 years ago

[extensions] - see_my_photos - 2.8

File size: 3.2 KB
Line 
1<?php
2/*
3Plugin Name: See My Photos
4Version: auto
5Description: See photos I've added
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=722
7Author: ddtddt
8Author URI: http://temmii.com/piwigo/
9*/
10// +-----------------------------------------------------------------------+
11// | See My Photos plugin for piwigo                                       |
12// +-----------------------------------------------------------------------+
13// | Copyright(C) 2014 - 2016 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
30if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
31
32
33define('SMP_DIR' , basename(dirname(__FILE__)));
34define('SMP_PATH' , PHPWG_PLUGINS_PATH . SMP_DIR . '/');
35
36add_event_handler('blockmanager_apply' , 'add_link_SMP');
37add_event_handler('loc_end_section_init', 'section_init_SMP');
38
39add_event_handler('loading_lang', 'see_my_photos_loading_lang');         
40function see_my_photos_loading_lang(){
41  load_language('plugin.lang', SMP_PATH);
42}
43
44
45function 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
79function section_init_SMP(){
80  global $tokens;
81  if (in_array('see_my_photos', $tokens))
82    include(SMP_PATH . 'pagessmp.php');
83}
84?>
Note: See TracBrowser for help on using the repository browser.