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