coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 permissions => Topic started by: mr.bena on April 02, 2012, 03:22:38 PM

Title: Disable Right Click for a Specific Album
Post by: mr.bena 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.
Title: Re: Disable Right Click for a Specific Album
Post by: Αndré 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?
Title: Re: Disable Right Click for a Specific Album
Post by: mr.bena 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..
Title: Re: Disable Right Click for a Specific Album
Post by: Αndré on April 03, 2012, 03:13:45 PM
Please post a link to the album where the right click should be disabled.
Title: Re: Disable Right Click for a Specific Album
Post by: mr.bena on April 03, 2012, 03:28:36 PM
It is : http://www.zofate.com/album/thumbnails.php?album=2
Title: Re: Disable Right Click for a Specific Album
Post by: Αndré on April 03, 2012, 04:18:27 PM
Copy this to your theme's theme.php file:
/******************************************************************************
** 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
******************************************************************************/
Title: Re: Disable Right Click for a Specific Album
Post by: mr.bena 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.?
Title: Re: Disable Right Click for a Specific Album
Post by: Αndré on April 03, 2012, 08:29:26 PM
Correct.