1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: See photos by user |
---|
4 | Version: auto |
---|
5 | Description: See photos by user |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=723 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('SPBA_DIR' , basename(dirname(__FILE__))); |
---|
14 | define('SPBA_PATH' , PHPWG_PLUGINS_PATH . SPBA_DIR . '/'); |
---|
15 | load_language('plugin.lang', SPBA_PATH); |
---|
16 | |
---|
17 | global $conf; |
---|
18 | $showSPBU = $conf['see_photos_by_user_show']; |
---|
19 | |
---|
20 | if ($showSPBU == 1 OR $showSPBU == 3) |
---|
21 | { |
---|
22 | add_event_handler('blockmanager_apply' , 'add_link_SPBA'); |
---|
23 | } |
---|
24 | function add_link_SPBA($menu_ref_arr) |
---|
25 | { |
---|
26 | global $conf, $user; |
---|
27 | $menu = & $menu_ref_arr[0]; |
---|
28 | if (($block = $menu->get_block('mbSpecials')) != null) |
---|
29 | { |
---|
30 | load_language('plugin.lang', SPBA_PATH); |
---|
31 | $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data)+1; |
---|
32 | array_splice |
---|
33 | ($block->data, $position-1, 0, array |
---|
34 | ('user-' => |
---|
35 | array |
---|
36 | ( |
---|
37 | 'URL' => make_index_url(array('section' => 'user-')), |
---|
38 | 'TITLE' => l10n('See photos by user'), |
---|
39 | 'NAME' => l10n('See photos by user') |
---|
40 | ) |
---|
41 | ) |
---|
42 | ); |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | add_event_handler('loc_end_section_init', 'section_init_SPBA'); |
---|
47 | function section_init_SPBA() |
---|
48 | { |
---|
49 | global $tokens; |
---|
50 | $testa = explode('user-', $_SERVER['REQUEST_URI']); |
---|
51 | if (!empty ($testa[1])) |
---|
52 | { |
---|
53 | $testd= explode('/', $testa[1]); |
---|
54 | $me = 'user-'.$testd[0]; |
---|
55 | } |
---|
56 | else |
---|
57 | {$me = 'user-';} |
---|
58 | |
---|
59 | if (in_array($me, $tokens)) |
---|
60 | include(SPBA_PATH . 'pagespba.php'); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | if ($showSPBU == 2 OR $showSPBU == 3 OR $showSPBU == 4) |
---|
66 | { |
---|
67 | add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks'); |
---|
68 | add_event_handler('blockmanager_apply', 'users_apply'); |
---|
69 | } |
---|
70 | function register_users_menubar_blocks( $menu_ref_arr ) |
---|
71 | { |
---|
72 | $menu = & $menu_ref_arr[0]; |
---|
73 | if ($menu->get_id() != 'menubar') |
---|
74 | return; |
---|
75 | $menu->register_block( new RegisteredBlock( 'mbUsers','Users',('See photos by user'))); |
---|
76 | } |
---|
77 | |
---|
78 | function users_apply($menu_ref_arr) |
---|
79 | { |
---|
80 | global $template, $conf, $user; |
---|
81 | $menu = & $menu_ref_arr[0]; |
---|
82 | load_language('plugin.lang', SPBA_PATH); |
---|
83 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true)); |
---|
84 | |
---|
85 | $userslistemenu1 = pwg_query(' |
---|
86 | SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id |
---|
87 | FROM ' . USERS_TABLE . ' as UT |
---|
88 | INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id |
---|
89 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id |
---|
90 | '.get_sql_condition_FandF |
---|
91 | ( |
---|
92 | array |
---|
93 | ( |
---|
94 | 'forbidden_categories' => 'category_id', |
---|
95 | 'visible_categories' => 'category_id', |
---|
96 | 'visible_images' => 'id' |
---|
97 | ), |
---|
98 | 'WHERE' |
---|
99 | ).' |
---|
100 | GROUP BY IT.added_by |
---|
101 | HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].' |
---|
102 | ORDER BY '.$conf['see_photos_by_user_order'].' |
---|
103 | LIMIT '.$conf['see_photos_by_user_limit'].';'); |
---|
104 | |
---|
105 | if (pwg_db_num_rows($userslistemenu1)) { |
---|
106 | while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1)) |
---|
107 | { |
---|
108 | $items = array( |
---|
109 | 'USERSSPBYL' => $userslistemenu['username'], |
---|
110 | 'USERSSPBYLC' => $userslistemenu['PBU'], |
---|
111 | ); |
---|
112 | |
---|
113 | $template->append('userslistemenu1', $items); |
---|
114 | } |
---|
115 | } |
---|
116 | $linkusersliste = get_root_url().'index.php?/user-'; |
---|
117 | $template->assign('USERSSPBY', $linkusersliste); |
---|
118 | |
---|
119 | if (($block = $menu->get_block( 'mbUsers' )) != null) { |
---|
120 | $template->set_template_dir(SPBA_PATH); |
---|
121 | $block->template = 'menubar_users.tpl';} |
---|
122 | } |
---|
123 | |
---|
124 | add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu'); |
---|
125 | function SPBA_admin_menu($menu) |
---|
126 | { |
---|
127 | array_push( |
---|
128 | $menu, |
---|
129 | array( |
---|
130 | 'NAME' => l10n('See photos by user'), |
---|
131 | 'URL' => get_admin_plugin_menu_link(SPBA_PATH . 'admin.php') |
---|
132 | //'URL' => get_root_url().'admin.php?page=plugin-See_photos_by_user' |
---|
133 | ) |
---|
134 | ); |
---|
135 | |
---|
136 | return $menu; |
---|
137 | } |
---|
138 | |
---|
139 | ?> |
---|