1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | Plugin Name: See photos by user |
---|
5 | Version: auto |
---|
6 | Description: See photos by user |
---|
7 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=723 |
---|
8 | Author: ddtddt |
---|
9 | Author URI: |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('PHPWG_ROOT_PATH')) |
---|
13 | die('Hacking attempt!'); |
---|
14 | |
---|
15 | define('SPBA_DIR', basename(dirname(__FILE__))); |
---|
16 | define('SPBA_PATH', PHPWG_PLUGINS_PATH . SPBA_DIR . '/'); |
---|
17 | define('SPBA_ADMIN',get_root_url().'admin.php?page=plugin-'.SPBA_DIR); |
---|
18 | load_language('plugin.lang', SPBA_PATH); |
---|
19 | |
---|
20 | include_once(SPBA_PATH . 'include/function.see.inc.php'); |
---|
21 | global $conf; |
---|
22 | |
---|
23 | /*init plugin - filter http*/ |
---|
24 | add_event_handler('loc_end_section_init', 'section_init_SPBA'); |
---|
25 | function section_init_SPBA() { |
---|
26 | /*init plugin lang*/ |
---|
27 | load_language('plugin.lang', SPBA_PATH); |
---|
28 | load_language('lang', PHPWG_ROOT_PATH . 'local/', array('no_fallback' => true, 'local' => true)); |
---|
29 | |
---|
30 | global $tokens, $conf, $template; |
---|
31 | if(strpbrk('user-', $_SERVER['REQUEST_URI'])!=false){ |
---|
32 | $testa = explode('user-', $_SERVER['REQUEST_URI']); |
---|
33 | if(!empty($testa[1])){ |
---|
34 | $testd = explode('-', $testa[1]); |
---|
35 | if(is_numeric($testd[0])){ |
---|
36 | $username= see_username($testd[0]); |
---|
37 | $result=see_userlist_nb_photo(); |
---|
38 | $userok = array(); |
---|
39 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
40 | $userok[] = $row['id']; |
---|
41 | } |
---|
42 | if (in_array($testd[0], $userok)) { |
---|
43 | $me = 'user-' . $testd[0].'-'.$username; |
---|
44 | $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/user-">' . l10n('Users').'</a>'. $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/' . $me . '">'.$username . '</a>'; |
---|
45 | } else { |
---|
46 | $me = 'user-'; |
---|
47 | $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/user-">' . l10n('Users').'</a>'; |
---|
48 | } |
---|
49 | }else{ |
---|
50 | $me = 'user-'; |
---|
51 | } |
---|
52 | }else{ |
---|
53 | $me = 'user-'; |
---|
54 | } |
---|
55 | if(isset($me)){ |
---|
56 | if (in_array($me, $tokens)) |
---|
57 | include(SPBA_PATH . 'pagespba.php'); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | //$template->assign('SPBA2', 'toto'); |
---|
62 | $template->set_filename('SPBA', realpath(SPBA_PATH . 'pagespba.tpl')); |
---|
63 | $template->assign_var_from_handle('CONTENT', 'SPBA'); //2.6 |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | /*Schow link in menu*/ |
---|
71 | if ($conf['see_photos_by_user_show']==1) { |
---|
72 | add_event_handler('blockmanager_apply', 'add_link_SPBA'); |
---|
73 | } |
---|
74 | |
---|
75 | function add_link_SPBA($menu_ref_arr) { |
---|
76 | global $conf, $user; |
---|
77 | $menu = & $menu_ref_arr[0]; |
---|
78 | if (($block = $menu->get_block('mbSpecials')) != null) { |
---|
79 | load_language('plugin.lang', SPBA_PATH); |
---|
80 | $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data) + 1; |
---|
81 | array_splice |
---|
82 | ($block->data, $position - 1, 0, array |
---|
83 | ('user-' => |
---|
84 | array |
---|
85 | ( |
---|
86 | 'URL' => make_index_url(array('section' => 'user-')), |
---|
87 | 'TITLE' => l10n('See photos by user'), |
---|
88 | 'NAME' => l10n('See photos by user') |
---|
89 | ) |
---|
90 | ) |
---|
91 | ); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | /*schow users menu*/ |
---|
97 | if ($conf['see_photos_by_user_show']==2) { |
---|
98 | add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks'); |
---|
99 | add_event_handler('blockmanager_apply', 'users_apply'); |
---|
100 | } |
---|
101 | |
---|
102 | function register_users_menubar_blocks($menu_ref_arr) { |
---|
103 | $menu = & $menu_ref_arr[0]; |
---|
104 | if ($menu->get_id() != 'menubar') |
---|
105 | return; |
---|
106 | $menu->register_block(new RegisteredBlock('mbUsers', 'Users', ('See photos by user'))); |
---|
107 | } |
---|
108 | |
---|
109 | function users_apply($menu_ref_arr) { |
---|
110 | global $template, $conf, $user; |
---|
111 | $menu = & $menu_ref_arr[0]; |
---|
112 | |
---|
113 | $userslistemenu1 = see_userlist_nb_photo(); |
---|
114 | |
---|
115 | if (pwg_db_num_rows($userslistemenu1)) { |
---|
116 | while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1)) { |
---|
117 | $items = array( |
---|
118 | 'USERSSPBYLID' => $userslistemenu['id'], |
---|
119 | 'USERSSPBYL' => $userslistemenu['username'], |
---|
120 | 'USERSSPBYLC' => $userslistemenu['PBU'], |
---|
121 | ); |
---|
122 | |
---|
123 | $template->append('userslistemenu1', $items); |
---|
124 | } |
---|
125 | } |
---|
126 | $linkusersliste = get_root_url() . 'index.php?/user-'; |
---|
127 | $template->assign('USERSSPBY', $linkusersliste); |
---|
128 | |
---|
129 | if (($block = $menu->get_block('mbUsers')) != null) { |
---|
130 | $template->set_template_dir(SPBA_PATH); |
---|
131 | $block->template = 'menubar_users.tpl'; |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | /*Add admin menu*/ |
---|
136 | add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu'); |
---|
137 | |
---|
138 | function SPBA_admin_menu($menu) { |
---|
139 | /*load_language('plugin.lang', SPBA_PATH); |
---|
140 | array_push( |
---|
141 | $menu, array( |
---|
142 | 'NAME' => l10n('Photos by user'), |
---|
143 | 'URL' => get_admin_plugin_menu_link(SPBA_PATH . 'admin.php') |
---|
144 | ) |
---|
145 | );*/ |
---|
146 | load_language('plugin.lang', SPBA_PATH); |
---|
147 | $menu[] = array( |
---|
148 | 'NAME' => l10n('Photos by user'), |
---|
149 | 'URL' => SPBA_ADMIN, |
---|
150 | ); |
---|
151 | |
---|
152 | |
---|
153 | return $menu; |
---|
154 | } |
---|
155 | |
---|
156 | ?> |
---|