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

Last change on this file since 32697 was 32612, checked in by plg, 3 years ago

add category_id on url to directly select the current album

File size: 3.8 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  by TEMMII                            |
13// +-----------------------------------------------------------------------+
14// | Copyright(C) 2011-2021 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, $page;
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
78  $url_suffix = '';
79  if (isset($page['category']))
80  {
81    $url_suffix = '&amp;category_id='.$page['category']['id'];
82  }
83
84     //Sending data to the template
85            $template->assign   (
86                array   (
87        'U1MTITLE'     => l10n('Upload your own photos'),
88        'U1MNAME'      => l10n('Upload Photos'),
89        'U1MURL' => get_root_url().'index.php?/add_photos'.$url_suffix,
90                                )                       );
91
92   
93    if (($block = $menu->get_block( 'mbUpload' )) != null) {
94        $template->set_template_dir(U1M_PATH.'template/');
95       
96                if ($user['theme'] == 'bootstrapdefault'||$user['theme'] == 'bootstrap_darkroom'){
97                  $block->template = 'menubar_upload_Bootstrap_Default.tpl';           
98                }else if ($user['theme'] == 'smartpocket'){
99                  $block->template = 'menubar_upload_smartpocket.tpl';         
100                }else{
101                  $block->template = 'menubar_upload.tpl';
102                }
103    }
104}
105        }
106
107?>
Note: See TracBrowser for help on using the repository browser.