Skip to content
Snippets Groups Projects
Commit da89ff2d authored by Andrew Berezovsky's avatar Andrew Berezovsky
Browse files

Added disabling on context menu on images

Added uninstall function to delete variables
parent bb017860
No related branches found
No related tags found
No related merge requests found
......@@ -9,13 +9,22 @@ function copyprevention_settings_form() {
'#type' => 'checkboxes',
'#title' => t('Body tag attributes'),
'#options' => array(
'selectstart' => t('Add onselectstart="return false;"'),
'copy' => t('Add oncopy="return false;"'),
'contextmenu' => t('Add oncontextmenu="return false;"'),
'selectstart' => t('Disable text selection: onselectstart="return false;"'),
'copy' => t('Disable copy to clipboard operation: oncopy="return false;"'),
'contextmenu' => t('Disable right-click context menu: oncontextmenu="return false;"'),
),
'#default_value' => variable_get('copyprevention_body', array()),
'#description' => t('Apply these attributes to body tag.'),
);
$form['copyprevention_images'] = array(
'#type' => 'checkboxes',
'#title' => t('Images protection'),
'#options' => array(
'contextmenu' => t('Disable right-click context menu: oncontextmenu="return false;"'),
),
'#default_value' => variable_get('copyprevention_images', array()),
'#description' => t('Apply these attributes to images.'),
);
return system_settings_form($form);
}
<?php
/**
* @file
* Install and uninstall functions for Copy Prevention module.
*/
/**
* Implements hook_uninstall().
*/
function copyprevention_uninstall() {
variable_del('copyprevention_body');
variable_del('copyprevention_images');
}
......@@ -7,6 +7,11 @@
return false;
});
});
$.each(Drupal.settings.copyprevention.images, function(index, value) {
$('img').bind(value, function(event) {
return false;
});
});
};
})(jQuery);
......@@ -53,14 +53,18 @@ function copyprevention_preprocess_html(&$vars) {
*/
function copyprevention_page_build(&$page) {
if (user_access('bypass copy prevention')) {
return;
//return;
}
$body_settings = array_filter(variable_get('copyprevention_body', array()));
$copyprevention_body = array_filter(variable_get('copyprevention_body', array()));
$copyprevention_images = array_filter(variable_get('copyprevention_images', array()));
$region = array_shift(element_children($page));
$page[$region]['#attached']['js'][] = array(
'data' => array(
'copyprevention' => array('body' => $body_settings),
'copyprevention' => array(
'body' => $copyprevention_body,
'images' => $copyprevention_images,
),
),
'type' => 'setting',
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment