1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: rightClick |
---|
4 | Version: auto |
---|
5 | Description: rightClick deactivates the context menu on websized pictures and more. |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=401 |
---|
7 | Author: VDigital |
---|
8 | Author URI: http://piwigo.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | define('RIGHTCK_DIR' , basename(dirname(__FILE__))); |
---|
13 | define('RIGHTCK_PATH' , PHPWG_PLUGINS_PATH . RIGHTCK_DIR . '/'); |
---|
14 | |
---|
15 | if ( !function_exists( 'rightClick_protect' ) ) |
---|
16 | { |
---|
17 | if ( defined('IN_ADMIN') and IN_ADMIN ) return false; |
---|
18 | |
---|
19 | add_event_handler('loc_after_page_header', 'rightClick_protect', 20); |
---|
20 | |
---|
21 | function rightClick_protect() |
---|
22 | { |
---|
23 | global $template, $user, $conf; |
---|
24 | if (!isset($conf['rightClick_level'])) |
---|
25 | $Maxlvl = max($conf['available_permission_levels']); |
---|
26 | else |
---|
27 | $Maxlvl = $conf['rightClick_level']; |
---|
28 | |
---|
29 | if ($user['level'] >= $Maxlvl) return; |
---|
30 | |
---|
31 | $default = array( '#theImage img', '#akPicture', '#colorbox', '#sb-container', '#prevnext', '#theMainImage',); |
---|
32 | if (!isset($conf['rightClick_selectors'])) |
---|
33 | $conf['rightClick_selectors'] = array(); |
---|
34 | |
---|
35 | $conf['rightClick_selectors'] = array_unique( array_merge($default, $conf['rightClick_selectors']) ); |
---|
36 | |
---|
37 | $template->set_filenames(array( |
---|
38 | 'rightClick_protect' => dirname(__FILE__) . '/template/rightClick_protect.tpl', |
---|
39 | )); |
---|
40 | $Path = embellish_url($template->get_template_vars('ROOT_URL').RIGHTCK_PATH); |
---|
41 | $protect = array( |
---|
42 | 'Dir' => RIGHTCK_DIR, |
---|
43 | 'Path' => $Path, |
---|
44 | 'Selectors' => $conf['rightClick_selectors'], |
---|
45 | ); |
---|
46 | $template->assign( array( 'RIGHTCK' => $protect ) ); |
---|
47 | $template->parse('rightClick_protect'); |
---|
48 | } |
---|
49 | } |
---|
50 | ?> |
---|