Delete Control for V 1.5.x Delete Control for V 1.5.x
 

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]

Main Menu

Delete Control for V 1.5.x

Started by macmiller, March 19, 2011, 05:23:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

macmiller

Is there a plugin similar to Delete Control on Users Galleries & Public Albums available for 1.5.x? 

The following plugin does what I want but I can only locate the 1.4.x version:

http://forum.coppermine-gallery.net/index.php/topic,29116.html


Αndré

Afaik such a plugin doesn't exist, but I think it's quite easy to port that plugin to cpg1.5.x.

macmiller

I've been testing the plugin to see if it will work. 

The two things that don't seem to work with the plugin 'as is' (in 1.5.12):

The user can no longer create albums.  This was a noted problem in 1.4.x and fixed with this notation:
* fixed error where user could not create album (function is in delete.php)
(the problem re appears in 1.5.x)

The Delete button appears on the page where albums are listed.  Noted and fixed in 1.4.x with this notation:
* remove delete button from albmgr.php - processing is already disabled in delete.php
(the problem re appears in 1.5.x)

Any hints on what to change appreciated. 


Αndré

I'll have a look at that plugin asap.

macmiller

Any insight?  Not quite sure why this plug interferes with the album creation feature.  Any help greatly appreciated.  Also, just as a note I have tested this version posted of this plug in in CPG 1.4.x and it does not have any of the noted problems (everything works with the plugin in v 1.4.x).

macmiller

I just had a look at this again in my test area.  When I comment out the following code in the plugin the album creation works as normal, with this code active (no commented out) the album creation does not work.  Again, this was a problem at one time for the 1.4.x version which was later fixed.  The fixed and latest version is broken again with CPG 1.5.x (I already verified that this version does in fact work in 1.4.x in my test area).

Here is the code which causes the problem (now commented out):
//  if (defined('DELETE_PHP') && !GALLERY_ADMIN_MODE) {
//  $try_to_delete = false;
// $what = isset($_GET['what']) ? $_GET['what'] : $_POST['what'];
//  if (($what != 'albmgr') || (($what == 'albmgr') && $_POST['delete_album'])) {
//  $try_to_delete = true;
//  }
//  if ($try_to_delete) {
//  load_template();
//  pageheader($lang_error);
//  cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
//  }
//  }


How this causes the album creation to fail in CPG 1.5.x is a mystery to me.  Any clues greatly appreciated as I need to get this operational soon, and I am totally stumped!


Αndré

Sorry that I hadn't found time to look at the code myself. It's quite easy to explain why that code breaks the album creation. New albums will be created with the file delete.php in the back-end. That's why there's the following check, which distinguish the different actions contained in that file:
// $what = isset($_GET['what']) ? $_GET['what'] : $_POST['what'];
//  if (($what != 'albmgr') || (($what == 'albmgr') && $_POST['delete_album'])) {
//  $try_to_delete = true;
//  }


You have to replace the superglobals as described here, otherwise $what is always empty and the check doesn't work.

Try to replace
$what = isset($_GET['what']) ? $_GET['what'] : $_POST['what'];
with
$superCage = Inspekt::makeSuperCage();
if ($superCage->get->keyExists('what')) {
    $what = $superCage->get->getAlpha('what');
} elseif ($superCage->post->keyExists('what')) {
    $what = $superCage->post->getAlpha('what');
} else {
    cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
}

macmiller

Much thanks Andre.  I just tried your suggested code and was able to create an album in my test area.  I will do more testing on this later, but for now seems to be working.

Before closing this out there is one remaining issue, that is the Delete button.  In the 1.4.x environment the button was labeled 'DELETE'.  This plug-in in the 1.4.x environment correctly hides the button, that is it is not displayed.  In the 1.5.x environment the button is labeled 'Delete'.  The plug-in does not hide the button, that is it is still displayed (which is not good, it should not be displayed).

I know it is something simple, but any quick suggestions on code and I will test it and then this plug-in will be ready to go for 1.5.x. 

Thanks in advance.

Αndré

Please attach your cpg1.5.x version of the plugin as zip file to your next reply.

macmiller

The zip of version 1.04 is attached.  Remember it isn't finished yet.  The Delete button still shows up when it shouldn't.  I need help to fix this. 


Thanks for the continuing help.

Αndré

As you can see in the function delcon_filterpage the plugin removes delete buttons at 4 different places:
1. displayimage.php
2. index.php
3. editpics.php
4. albmgr.php

Which delete button do you mean that won't be hidden?


Additionally, you have to replace 3 more $_POST[ superglobals.

macmiller

QuoteWhich delete button do you mean that won't be hidden?
index.php:  The Delete button still shows.  (in error)
displayimage.php:  There is no Delete button showing.  (working correctly) 
albmgr.php:  There is an 'X' button to delete the selected album showing.   (in error)
editpics.php:  There is an 'X' button showing to delete the selected pics.  (in error)


QuoteAdditionally, you have to replace 3 more $_POST[ superglobals.
I'm reading the documentation, still a bit foggy on it.  Can you give me an example of how to access the $_POST and change this line
        if (($what != 'albmgr') || (($what == 'albmgr') && $_POST['delete_album']))
which is the next instance of $_POST?

Thanks in advance....

macmiller

This was marked as 'solved' although it isn't yet as the plug in as is causes other things not to work.   I'm wondering if you could let me know how to change the following line to work in 1.5? 

if (($what != 'albmgr') || (($what == 'albmgr') && $_POST['delete_album']))

I think I will understand how to upgrade a plug in after this, sorry about being so dense! ???

Αndré

I haven't looked at the code, but in any case you have to replace
$_POST['delete_album']
with
$superCage->post->keyExists('delete_album')

For more information, read http://documentation.coppermine-gallery.net/en/dev_superglobals.htm

macmiller

There is one last $_POST which is:

  if (isset($_POST['delete'.$pid])) $try_to_delete = true;

Can you let me know what the modified code would be?

Αndré

Replace
isset($_POST['delete'.$pid])
with
$superCage->post->keyExists('delete'.$pid)

macmiller

I tried to change another _post command but it is not working (the way I changed it).

Can you tell me how this line should be changed?

          $pid_array = $_POST['pid'];


Thanks and I believe this is the last one!!!

Αndré

Quote from: macmiller on May 26, 2011, 10:12:55 AM
it is not working (the way I changed it).
Please post your solution.

macmiller

        $pid_array = $superCage->post->keyExists('pid');

Αndré

Of course it won't work if you use keyExists. The name should be self-explanatory: it only checks if a value has been submitted. If you want to get that value, use getInt:
        $pid_array = $superCage->post->getInt('pid');