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

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

[extensions] - see_my_photos - change permission - link

File size: 1.7 KB
RevLine 
[26634]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:
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13
14define('SMP_DIR' , basename(dirname(__FILE__)));
15define('SMP_PATH' , PHPWG_PLUGINS_PATH . SMP_DIR . '/');
16
17add_event_handler('blockmanager_apply' , 'add_link_SMP');
18add_event_handler('loc_end_section_init', 'section_init_SMP');
19
20
21function add_link_SMP($menu_ref_arr)
[26641]22 {
[26634]23  global $conf, $user;
[26651]24       
[26641]25   $query = '
26  SELECT DISTINCT(id)
[26634]27  FROM '.IMAGES_TABLE.'
28  INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
[27486]29    '.get_sql_condition_FandF
30  (
31    array
32      (
33        'forbidden_categories' => 'category_id',
34        'visible_categories' => 'category_id',
35        'visible_images' => 'id'
36      ),
37    'WHERE'
38  ).'
39  AND added_by = \''.$user['id'].'\'
[26634]40;';
[26641]41  $result = pwg_query($query);
42  $row = pwg_db_fetch_assoc($result);
[26651]43$nbp=count(array_from_query($query, 'id'));
44
[26641]45 if (!is_a_guest() and !empty($row))
46  { 
[26634]47  $menu = & $menu_ref_arr[0];
48  if (($block = $menu->get_block('mbSpecials')) != null)
[26641]49   {
50   load_language('plugin.lang', SMP_PATH);
51   $position = (isset($conf['SMP_position']) and is_numeric($conf['SMP_position'])) ? $conf['SMP_position'] : count($block->data)+1;
52   array_splice($block->data, $position-1, 0, array('see_my_photos' =>
[26634]53      array(
54        'URL' => make_index_url(array('section' => 'see_my_photos')),
55        'TITLE' => l10n('My photos'),
[26651]56        'NAME' => l10n('My photos').' ('.$nbp.')',
[26634]57        )
58      )
59    );
[26641]60   }
61        }
[26634]62}
63
64function section_init_SMP()
[26641]65 {
66 global $tokens;
[26634]67  if (in_array('see_my_photos', $tokens))
[26641]68  include(SMP_PATH . 'pagessmp.php');
69 }
[26634]70?>
Note: See TracBrowser for help on using the repository browser.