1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Upload 1 menu |
---|
4 | Version: auto |
---|
5 | Description: Add Upload Photos link as menu level 1 |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=577 |
---|
7 | Author: ddtddt |
---|
8 | Author URI:http://piwigo.org |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('U1M_DIR' , basename(dirname(__FILE__))); |
---|
14 | define('U1M_PATH' , PHPWG_PLUGINS_PATH . U1M_DIR . '/'); |
---|
15 | |
---|
16 | |
---|
17 | add_event_handler('blockmanager_register_blocks', 'register_u1m_menubar_blocks'); |
---|
18 | add_event_handler('blockmanager_apply', 'u1m_apply'); |
---|
19 | |
---|
20 | function register_u1m_menubar_blocks( $menu_ref_arr ) |
---|
21 | { |
---|
22 | $menu = & $menu_ref_arr[0]; |
---|
23 | if ($menu->get_id() != 'menubar') |
---|
24 | return; |
---|
25 | $menu->register_block( new RegisteredBlock( 'mbUpload', 'Upload', 'U1M')); |
---|
26 | } |
---|
27 | |
---|
28 | function u1m_apply($menu_ref_arr) |
---|
29 | { |
---|
30 | global $template; |
---|
31 | |
---|
32 | $menu = & $menu_ref_arr[0]; |
---|
33 | |
---|
34 | global $conf, $user; |
---|
35 | |
---|
36 | $user_permissions = community_get_user_permissions($user['id']); |
---|
37 | |
---|
38 | if (count($user_permissions['upload_categories']) == 0 and !$user_permissions ['create_whole_gallery']) |
---|
39 | { |
---|
40 | return; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | load_language('plugin.lang', COMMUNITY_PATH); |
---|
45 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
46 | //Sending data to the template |
---|
47 | $template->assign ( |
---|
48 | array ( |
---|
49 | 'U1MTITLE' => l10n('Upload your own photos'), |
---|
50 | 'U1MNAME' => l10n('Upload Photos'), |
---|
51 | 'U1MURL' => get_root_url().'index.php?/add_photos', |
---|
52 | ) ); |
---|
53 | |
---|
54 | |
---|
55 | if (($block = $menu->get_block( 'mbUpload' )) != null) { |
---|
56 | $template->set_template_dir(U1M_PATH.'template/'); |
---|
57 | $block->template = 'menubar_upload.tpl'; |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | ?> |
---|