Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

Author Topic: Delete Control for V 1.5.x  (Read 19534 times)

0 Members and 1 Guest are viewing this topic.

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Delete Control for V 1.5.x
« on: March 19, 2011, 05:23:55 am »

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

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #1 on: March 19, 2011, 07:37:47 pm »

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

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #2 on: March 20, 2011, 03:43:45 am »

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. 

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #3 on: March 20, 2011, 10:53:46 am »

I'll have a look at that plugin asap.
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #4 on: March 27, 2011, 07:22:22 am »

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).
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #5 on: April 11, 2011, 03:09:52 pm »

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):
Code: [Select]
//  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!

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #6 on: April 11, 2011, 03:34:46 pm »

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:
Code: [Select]
// $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
Code: [Select]
$what = isset($_GET['what']) ? $_GET['what'] : $_POST['what'];with
Code: [Select]
$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__);
}
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #7 on: April 11, 2011, 05:15:46 pm »

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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #8 on: April 12, 2011, 10:32:21 am »

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

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #9 on: April 12, 2011, 12:36:03 pm »

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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #10 on: April 12, 2011, 04:45:57 pm »

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.
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #11 on: April 12, 2011, 05:18:50 pm »

Quote
Which 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)

 
Quote
Additionally, 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
        
Code: [Select]
if (($what != 'albmgr') || (($what == 'albmgr') && $_POST['delete_album'])) which is the next instance of $_POST?

Thanks in advance....
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #12 on: May 23, 2011, 09:17:38 am »

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? 

Code: [Select]
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! ???
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #13 on: May 23, 2011, 09:55:32 am »

I haven't looked at the code, but in any case you have to replace
Code: [Select]
$_POST['delete_album']with
Code: [Select]
$superCage->post->keyExists('delete_album')
For more information, read http://documentation.coppermine-gallery.net/en/dev_superglobals.htm
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #14 on: May 24, 2011, 03:53:39 am »

There is one last $_POST which is:

Code: [Select]
  if (isset($_POST['delete'.$pid])) $try_to_delete = true;
Can you let me know what the modified code would be?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #15 on: May 24, 2011, 09:07:13 am »

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

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #16 on: May 26, 2011, 10:12:55 am »

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?

Code: [Select]
          $pid_array = $_POST['pid'];

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #17 on: May 26, 2011, 12:25:03 pm »

it is not working (the way I changed it).
Please post your solution.
Logged

macmiller

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 80
Re: Delete Control for V 1.5.x
« Reply #18 on: May 27, 2011, 10:46:11 am »

Code: [Select]
        $pid_array = $superCage->post->keyExists('pid');
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Delete Control for V 1.5.x
« Reply #19 on: May 27, 2011, 11:00:40 am »

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:
Code: [Select]
        $pid_array = $superCage->post->getInt('pid');
Logged
Pages: [1] 2   Go Up
 

Page created in 0.024 seconds with 19 queries.