source: extensions/uploadt1menu/main.inc.php @ 31447

Last change on this file since 31447 was 31447, checked in by ddtddt, 9 years ago

[extensions] - uploadt1menu

File size: 3.3 KB
Line 
1<?php
2/*
3Plugin Name: Upload 1 menu
4Version: auto
5Description: Add Upload Photos link as menu level 1
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=577
7Author: ddtddt
8Author URI: http://temmii.com/piwigo/
9*/
10
11// +-----------------------------------------------------------------------+
12// | Upload 1 menu plugin for piwigo                                       |
13// +-----------------------------------------------------------------------+
14// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
15// +-----------------------------------------------------------------------+
16// | This program is free software; you can redistribute it and/or modify  |
17// | it under the terms of the GNU General Public License as published by  |
18// | the Free Software Foundation                                          |
19// |                                                                       |
20// | This program is distributed in the hope that it will be useful, but   |
21// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
22// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
23// | General Public License for more details.                              |
24// |                                                                       |
25// | You should have received a copy of the GNU General Public License     |
26// | along with this program; if not, write to the Free Software           |
27// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
28// | USA.                                                                  |
29// +-----------------------------------------------------------------------+
30
31if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
32
33define('U1M_DIR' , basename(dirname(__FILE__)));
34define('U1M_PATH' , PHPWG_PLUGINS_PATH . U1M_DIR . '/');
35
36$desac = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'community';"));
37
38if($desac['state'] != 'active') 
39        {
40if (script_basename() == 'admin')   
41{
42  include_once(dirname(__FILE__).'/initadmin.php');
43}
44        }
45else
46        {
47
48add_event_handler('blockmanager_register_blocks', 'register_u1m_menubar_blocks');
49add_event_handler('blockmanager_apply', 'u1m_apply');
50
51function register_u1m_menubar_blocks( $menu_ref_arr )
52{
53  $menu = & $menu_ref_arr[0];
54  if ($menu->get_id() != 'menubar')
55    return;
56  $menu->register_block( new RegisteredBlock( 'mbUpload', 'Upload', 'U1M'));
57}
58
59function u1m_apply($menu_ref_arr)
60{
61  global $template;
62
63 $menu = & $menu_ref_arr[0];
64 
65   global $conf, $user;
66
67  $user_permissions = community_get_user_permissions($user['id']);
68
69  if (count($user_permissions['upload_categories']) == 0 and !$user_permissions ['create_whole_gallery'])
70  {
71    return;
72  }
73 
74 
75 load_language('plugin.lang', COMMUNITY_PATH);
76 load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
77     //Sending data to the template
78            $template->assign   (
79                array   (
80        'U1MTITLE'     => l10n('Upload your own photos'),
81        'U1MNAME'      => l10n('Upload Photos'),
82        'U1MURL' => get_root_url().'index.php?/add_photos',
83                                )                       );
84
85   
86    if (($block = $menu->get_block( 'mbUpload' )) != null) {
87        $template->set_template_dir(U1M_PATH.'template/');
88        $block->template = 'menubar_upload.tpl';
89    }
90}
91        }
92
93?>
Note: See TracBrowser for help on using the repository browser.