Advanced search  

News:

cpg1.5.30 maintenance release - upgrade recommended
The Coppermine development team is releasing an update for Coppermine in order to fix several minor issues. All fixes are not security critical, so if your gallery is running fine with cpg1.5.28 you don't need to upgrade. If you are running an older version than cpg1.5.28, you must update to this latest version as soon as possible because of the security impact!
[more]

Pages: 1 [2]   Go Down

Author Topic: Plugin hook suggestions for cpg1.5.x  (Read 26534 times)

0 Members and 1 Guest are viewing this topic.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #20 on: May 11, 2012, 06:41:07 AM »

Both suggestions can already be done without new plugin hooks.

upon upload, have uploader remember last location of last image
Check for the 'album' parameter and if it isn't submitted, get the latest upload from the database (there's also stored the album) and redirect the user accordingly.


remove time limit on selecting images to upload
That's related to the form token config setting.
Logged

Veronica

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Re: Plugin hook suggestions for cpg1.5.x
« Reply #21 on: September 26, 2012, 07:41:32 PM »

I have now been working on this plugin and want to release the plugin version 1.0.
In the install/uninstall functions I have code which will add/delete this hook until an official hook is released.

I'm currently working on an Youtube URL user upload plugin which will work with this plugin Remote videos for cpg1.5.
I have added a third upload form in addition to swf and single file uploads.
Also I have made a conversion tool for the old Youtube hack for cpg1.4 by Nibbler so Coppermine sites still on cpg1.4 can upgrade and keep their Youtube links.

To make this plugin installable by anybody I want a new hook in db_input.php to process "uploads" which are not file uploads.
My suggestion for a new hook is like this in the last lines of db_input.php:
Quote
default:
    if(CPGPluginAPI::action('upload_process',$event)) break;

    // Unknown event
    if ($CONFIG['log_mode'] != 0) {
            log_write('Denied privileged access to db_input.php (unknown event) for user '.$USER_DATA['user_name'].' at ' . $hdr_ip, CPG_SECURITY_LOG);
    }
    cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
}

?>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #22 on: September 27, 2012, 11:36:27 AM »

Why do you need a plugin hook in db_input.php? Isn't it possible to submit the third upload form to another file (which will reside in your plugin folder)? I've currently no time to look into this in detail.
Logged

Veronica

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Re: Plugin hook suggestions for cpg1.5.x
« Reply #23 on: September 27, 2012, 03:29:16 PM »

OK I will do input to another plugin script without going via db_input.php
Logged

Veronica

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Re: Re: Plugin hook suggestions for cpg1.5.x
« Reply #24 on: September 27, 2012, 04:30:49 PM »

Why do you need a plugin hook in db_input.php? Isn't it possible to submit the third upload form to another file (which will reside in your plugin folder)? I've currently no time to look into this in detail.

I made the correct set_include_path to get all script includes to execute with form processing directed to the plugin folder.
Using a submit destination to a script in the plugin folder will make init.inc.php fail in testing
Quote
if (file_exists('include/config.inc.php'))
giving me an attempt to reload install.php from the plugin folder.

Now I will go back to my first setup with a hook in db_input.php
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #25 on: September 27, 2012, 04:45:25 PM »

Access the file via index.php?file=your_plugin_folder/file_name_without_extension. That way it runs in Coppermine's scope and you don't need to include init.inc.php.
Logged

Veronica

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Re: Plugin hook suggestions for cpg1.5.x
« Reply #26 on: September 27, 2012, 09:59:49 PM »

Thanks works OK now
Logged

Veronica

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Re: Re: Plugin hook suggestions for cpg1.5.x
« Reply #27 on: September 29, 2012, 06:55:27 PM »

Access the file via index.php?file=your_plugin_folder/file_name_without_extension. That way it runs in Coppermine's scope and you don't need to include init.inc.php.

Disadvantage with this method is that language file setup is according to index.php requirements and not as db_input.php
which will not give me standard phrases for define('DB_INPUT_PHP', true); like error messages
I can add these texts used in the plugin to my plugin language file but it's not a good solution with duplicates so my hook request is still best solution for me.
Logged

gmc

  • Dev Team member
  • Coppermine frequent poster
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 367
    • GMC Design Photo Gallery
Re: Plugin hook suggestions for cpg1.5.x
« Reply #28 on: February 10, 2014, 11:20:46 PM »

Email on comments:
Building on thread http://forum.coppermine-gallery.net/index.php/topic,71072.0.html which sends email when a comment is posted.
I adapted a variation on this for a customer - looking at implementing a plugin to handle this function, but lacking appropriate hookpoints from what I can see.

The related thread updates db_input.php, but this only addresses comment submission, and not approval (if approval is required...)

Looking for hookpoints in db_input.php and reviewcom.php...
A zip of patch file based on SVN 8668 is attached to detail my thoughts.  All 'action' plugins with no data returned.
Addition of 5 hookpoints:
  • 'comment_updated' in db_input.php
  • 'comment_posted_anonymous' in db_input.php
  • 'comment_posted_registered' in db_input.php
  • 'comment_approval_processed' in reviewcom.php
  • 'comment_multiple_approvals' in reviewcom.php

If this looks acceptable, I'll work on the plugin code to exploit... Obviously will have a min version at whatever level the hookpoints get included.  I haven't done any testing with this in plugin form yet - wanted to see if I was approaching this correctly, and if additional plugin points like this would be considered.

Thanks!
Logged
Thanks!
Greg

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #29 on: February 11, 2014, 09:55:40 AM »

Without reviewing the core code parts or your patch file yet, some hook names should be replaced in my opinion:

  • Replace comment_posted_anonymous and comment_posted_registered with comment_posted, or is there a good reason to use 2 different hook names?
  • Replace comment_approval_processed and comment_multiple_approvals with comment_approved, or is there a good reason to use 2 different hook names?
Logged

gmc

  • Dev Team member
  • Coppermine frequent poster
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 367
    • GMC Design Photo Gallery
Re: Re: Plugin hook suggestions for cpg1.5.x
« Reply #30 on: February 11, 2014, 03:41:53 PM »

Without reviewing the core code parts or your patch file yet, some hook names should be replaced in my opinion:

  • Replace comment_posted_anonymous and comment_posted_registered with comment_posted, or is there a good reason to use 2 different hook names?
  • Replace comment_approval_processed and comment_multiple_approvals with comment_approved, or is there a good reason to use 2 different hook names?
Thanks for the input...
For #1, I can easily change to one name.  I didn't need the distinction, was just thinking about other possible uses, but enough data is passed (or will be in next revision) for the plugin to easily determine if needed.

For #2, the parameters passed are quite different... (as is the core code)
For single comment, I was passing the 'single approval array' from base code while for the multiple, an array containing 2 strings - list of approved and list of rejected as generated by the base code...  I could reformat the single case to look like the multiple if a single hook name is desired...

I'll do a little testing with it and post a revised patch.
Logged
Thanks!
Greg

gmc

  • Dev Team member
  • Coppermine frequent poster
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 367
    • GMC Design Photo Gallery
Re: Plugin hook suggestions for cpg1.5.x
« Reply #31 on: February 13, 2014, 12:30:26 AM »

Revised proposal:
Looking for hookpoints in db_input.php and reviewcom.php...
A zip of patch file based on SVN 8668 is attached to detail my thoughts.  All 'action' plugins with no data returned.
Addition of 3 hookpoints:

    'comment_updated' in db_input.php - called when an existing comment is updated in database
    'comment_posted' in db_input.php - called when a comment is inserted to the database
    'comment_approvals' in reviewcom.php - called when a comment(s) are approved/rejected with list of approved/rejected comments

I've syntax checked - but haven't yet written the plugin code to process (convert existing mod code with some additional features)...
If acceptable to add these hooks, I will proceed.
Greg
Logged
Thanks!
Greg

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #32 on: February 13, 2014, 01:12:26 PM »

I slightly renamed all hooks and the variable names of the comment_approve hook (formerly comment_approvals) for consistency reasons. Patch file attached.

I had no closer look at the hooks (i.e. if the submitted data is sufficient), so please report if we can use them as they are and I'll commit them to our SVN repository.
Logged

gmc

  • Dev Team member
  • Coppermine frequent poster
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 367
    • GMC Design Photo Gallery
Re: Plugin hook suggestions for cpg1.5.x
« Reply #33 on: February 13, 2014, 06:51:47 PM »

Modifications look fine (of course :) )
Name changes are fine in hooknames and variables (I almost made that variable change myself... ) - and moving cpg_db_last_insert_id() into the API call makes sense over a separate assignment.

Plugin now on the 'todo' list... :)
Logged
Thanks!
Greg

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 13639
Re: Plugin hook suggestions for cpg1.5.x
« Reply #34 on: March 05, 2014, 03:57:21 PM »

Added plugin hooks 'comment_update', 'comment_add' and 'comment_approve' in SVN revision 8671.
Logged
Pages: 1 [2]   Go Up
 

Page created in 0.082 seconds with 21 queries.