Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Disable Right Click for a Specific Album  (Read 7321 times)

0 Members and 1 Guest are viewing this topic.

mr.bena

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Disable Right Click for a Specific Album
« on: April 02, 2012, 03:22:38 pm »

Hi, I want to set one of the albums in my gallery to be right click disable. I know there is overlay image functionality, but this function works for the whole gallery. I want my users to see the pictures but not able to save those pictures from my one special album.

I do hope this is possible by putting some extra code in "displayimage.php".  For example..

if album id equal to 3 (album=3)
{
   HTML Disable right click code.
}

I do not know how to write this code for displayimage.php. Please help me...

Ben.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Disable Right Click for a Specific Album
« Reply #1 on: April 03, 2012, 12:02:51 pm »

Neither disabling the right click nor the transparent overlay will prevent experienced users to save your pictures. However, what's your preferred solution if you want to apply it anyway?
Logged

mr.bena

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Disable Right Click for a Specific Album
« Reply #2 on: April 03, 2012, 02:11:19 pm »

I understand, Andre..  However, I want to discourage the newbies at least. In my case, Overlay will not work because I use Lightbox Plugin which disables the functionality of Image Overlay. So, I have no choice than Right Click Disable functionality here..
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Disable Right Click for a Specific Album
« Reply #3 on: April 03, 2012, 03:13:45 pm »

Please post a link to the album where the right click should be disabled.
Logged

mr.bena

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Disable Right Click for a Specific Album
« Reply #5 on: April 03, 2012, 04:18:27 pm »

Copy this to your theme's theme.php file:
Code: [Select]
/******************************************************************************
** Section <<<theme_javascript_head>>> - START
******************************************************************************/
// Function for the JavaScript inside the <head>-section
function theme_javascript_head()
{
    global $JS, $LINEBREAK;

    $return = '';
   
    // Check if we have any variables being set using set_js_vars function
    if (!empty($JS['vars'])) {
        // Convert the $JS['vars'] array to json object string
        $json_vars = json_encode($JS['vars']);
        // Output the json object
        $return = <<< EOT
<script type="text/javascript">
/* <![CDATA[ */
    var js_vars = $json_vars;
/* ]]> */
</script>

EOT;
    }

    // Check if we have any js includes
    if (!empty($JS['includes'])) {
        // Bring the jquery core library to the very top of the list
        if (in_array('js/jquery-1.3.2.js', $JS['includes']) == TRUE) {
            $key = array_search('js/jquery-1.3.2.js', $JS['includes']);
            unset($JS['includes'][$key]);
            array_unshift($JS['includes'], 'js/jquery-1.3.2.js');
        }
        $JS['includes'] = CPGPluginAPI::filter('javascript_includes',$JS['includes']);
        // Include all the files which were set using js_include() function
        foreach ($JS['includes'] as $js_file) {
            $return .= js_include($js_file, true) . $LINEBREAK;
        }
    }
   
    // Disable right mouse button (context menu)
    global $album;
    if ($album == 2) {
        $return .= <<< EOT
<script type="text/javascript">$(document).ready(function(){
  document.oncontextmenu = function() {return false;};

  $(document).mousedown(function(e){
    if( e.button == 2 ) {
      return false;
    }
    return true;
  });
});
</script>
EOT;
    }
   
    return $return;
}
/******************************************************************************
** Section <<<theme_javascript_head>>> - END
******************************************************************************/
Logged

mr.bena

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Disable Right Click for a Specific Album
« Reply #6 on: April 03, 2012, 06:34:34 pm »

Thank you so much... Andre. So, if I would like to set another album, will it work if I just replace the no. 2 in "if ($album == 2)" with another album ID such as 3, 5, 7 etc.?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Disable Right Click for a Specific Album
« Reply #7 on: April 03, 2012, 08:29:26 pm »

Correct.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 19 queries.