[12380] | 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 | |
---|
[18768] | 16 | $desac = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'community';")); |
---|
[12380] | 17 | |
---|
[18768] | 18 | if($desac['state'] != 'active') |
---|
| 19 | { |
---|
| 20 | if (script_basename() == 'admin') |
---|
| 21 | { |
---|
| 22 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | else |
---|
| 26 | { |
---|
| 27 | |
---|
[12380] | 28 | add_event_handler('blockmanager_register_blocks', 'register_u1m_menubar_blocks'); |
---|
| 29 | add_event_handler('blockmanager_apply', 'u1m_apply'); |
---|
| 30 | |
---|
| 31 | function register_u1m_menubar_blocks( $menu_ref_arr ) |
---|
| 32 | { |
---|
| 33 | $menu = & $menu_ref_arr[0]; |
---|
| 34 | if ($menu->get_id() != 'menubar') |
---|
| 35 | return; |
---|
| 36 | $menu->register_block( new RegisteredBlock( 'mbUpload', 'Upload', 'U1M')); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | function u1m_apply($menu_ref_arr) |
---|
| 40 | { |
---|
| 41 | global $template; |
---|
| 42 | |
---|
| 43 | $menu = & $menu_ref_arr[0]; |
---|
| 44 | |
---|
[12382] | 45 | global $conf, $user; |
---|
| 46 | |
---|
| 47 | $user_permissions = community_get_user_permissions($user['id']); |
---|
| 48 | |
---|
| 49 | if (count($user_permissions['upload_categories']) == 0 and !$user_permissions ['create_whole_gallery']) |
---|
| 50 | { |
---|
| 51 | return; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
[12380] | 55 | load_language('plugin.lang', COMMUNITY_PATH); |
---|
| 56 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
| 57 | //Sending data to the template |
---|
| 58 | $template->assign ( |
---|
| 59 | array ( |
---|
| 60 | 'U1MTITLE' => l10n('Upload your own photos'), |
---|
| 61 | 'U1MNAME' => l10n('Upload Photos'), |
---|
| 62 | 'U1MURL' => get_root_url().'index.php?/add_photos', |
---|
| 63 | ) ); |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | if (($block = $menu->get_block( 'mbUpload' )) != null) { |
---|
| 67 | $template->set_template_dir(U1M_PATH.'template/'); |
---|
| 68 | $block->template = 'menubar_upload.tpl'; |
---|
| 69 | } |
---|
| 70 | } |
---|
[18768] | 71 | } |
---|
[12380] | 72 | |
---|
| 73 | ?> |
---|