Advanced search  

News:

cpg1.5.36 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.34 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

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

0 Members and 1 Guest are viewing this topic.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Plugin hook suggestions for cpg1.5.x
« on: July 31, 2009, 08:02:26 AM »

Although cpg1.5.x is in the feature freeze stage, which means that no more features can/will be added before the release, the dev team has decided that there will be an exception to this rule: plugin hooks can still be added.
We want to encourage plugin authors to request additional plugin hooks at this stage, with an alpha release being available to test things with.
So if you want to start porting a plugin written for cpg1.4.x to cpg1.5.x or if you have an idea for a new plugin for cpg1.5.x that you want to write, please go ahead and let us know in this thread what plugin hook you need.

@newbies/non-coders: this thread does not deal with plugin requests, so please do not ask for plugins to be written or ported for you here. This thread is for coders who already know what a plugin hook is. This thread only exists for coders to request additional plugin hooks.

If you actually want to request a new hook, just roughly explain what your plugin is suppossed to do and where exactly you want your hook to reside at (between line X and line Y in file Z). Please also state what the expected return value will be (if any).

Joachim

P.S. All unrelated replies to this thread will be deleted without further notice
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #1 on: August 18, 2009, 01:43:03 PM »

May I add this plugin hook to include/mailer.inc.php?
Code: [Select]
   $sender_email = CPGPluginAPI::filter('cpg_mail_sender_email', $sender_email);
Explanation: I use a free hoster for my CPG. I figured out, that emails from the sender 'xyz@googlemail.com' will not be sent but a message is displayed, that the email has been sent successfully. If I change the sender address to '@gmail.com' everything works fine.

Maybe there are some limitations on other free hosters and someone else can use this hook.


Edit:
I just remembered, that it's also not possible to sent emails with more than one recipient on my webhost. So I'd need another hook to sent multiple emails with only 1 recipient or to sent emails sent to 'admin' only to 'gallery_admin_email'.


Additional plugin hooks can't hurt, right? 8)
« Last Edit: August 18, 2009, 02:19:06 PM by eenemeenemuu »
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1493
  • aka 'i-imagine'
    • Home Page
Re: Plugin hook suggestions for cpg1.5.x
« Reply #2 on: August 18, 2009, 03:17:52 PM »

Plugin hook requests. Pages with user (guest level) input. Purpose - spam control, adding captcha or other methods to user's form submissions.

This is for three pages now not protected by captcha: Ecard + Report to Moderator + Login.
Example used here is ecard. I am not sure if I have the right line numbers or if the concept/request
is being communicated properly. In any case I didn't want to write a long post and will be happy to reply if needed.

Ecard example hook 1 validate submission - somewhere between lines 149 - 156 and similar to:
Code: [Select]
$error = CPGPluginAPI::filter('captcha_ecard_validate', $error);
 
Ecard example 2 display a captcha or alternative - at or below line 425 and similar to:
Code: [Select]
$subecard_print = CPGPluginAPI::filter('ecard_submit_print',$subecard_print);
The same concepts also for Report and Login: A hook to show a captcha on the form at or near the Submit button and a hook prior to where the submission is processed and data is written to db, etc..

This is not a direct request for the exact same Captcha hooks to be placed into Ecard, Report and Login as the ones now being used. However if that would be more compatible/consistent with the overall way 1.5 is to run then please consider it as a suggestion only.

Logged
"My life has become an array of LEDs"

i-imagine.net - Artists Gallery <> My  Photo Gallery

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #3 on: September 02, 2009, 02:44:18 PM »

May I add this plugin hook to include/mailer.inc.php?
Added plugin hooks 'cpg_mail_to_email' & 'cpg_mail_sender_email' in r6545.
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1493
  • aka 'i-imagine'
    • Home Page
Re: Plugin hook suggestions for cpg1.5.x
« Reply #4 on: March 26, 2010, 09:19:51 PM »

Please, if it is possible and not too much trouble, could this hook be added?

File: index.php

Location: Directly below this: (around line 1122)
Code: [Select]
$elements = explode('/', $CONFIG['main_page_layout']);
Similar to:
Code: [Select]
$elements = CPGPluginAPI::filter('alt_page_layout', $elements);
Purpose: Plugin to allow differences in page layout (from home page) when visitor clicks on "Album list"

I hope that it is not too late for requests here. At the moment I have a rough working version of a plugin using that hook. It seems to function OK without interference elsewhere.

Thanks!
Logged
"My life has become an array of LEDs"

i-imagine.net - Artists Gallery <> My  Photo Gallery

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Plugin hook suggestions for cpg1.5.x
« Reply #5 on: March 26, 2010, 11:30:02 PM »

Did as you suggested.
Logged

jayhunter

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Re: Plugin hook suggestions for cpg1.5.x
« Reply #6 on: September 26, 2010, 03:46:30 PM »

Hey,

I needed a hook to do an md5 dupe check on uploads. These get triggered right before the file is moved to it's final location.

For HTML upload in file db_input.php
Find line 619:
Code: [Select]
    $uploaded_pic = $dest_dir . $picture_name;

After that add:
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_html_pre_move');
    if ($upload_plugin_error) {
        cpg_die(ERROR, $upload_plugin_error, __FILE__, __LINE__);
    }



For SWF upload in file upload.php

Find around line 1015:
Code: [Select]
    // prevent moving the edit directory...
    if (is_dir($path_to_image)) {
        echo 'error|'.$lang_upload_php['failure'] . " - '$path_to_image'|0";
        exit;
    }

After that add:
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_swf_pre_move');
    if ($upload_plugin_error) {
        echo 'error|'.$upload_plugin_error.'|0';
        exit;
    }

Works great for me ...

Cheers
Jayhunter
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #7 on: September 27, 2010, 11:13:24 AM »

Hey,

I needed a hook to do an md5 dupe check on uploads. These get triggered right before the file is moved to it's final location.

For HTML upload in file db_input.php
Find line 619:
Code: [Select]
    $uploaded_pic = $dest_dir . $picture_name;

After that add:
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_html_pre_move');
    if ($upload_plugin_error) {
        cpg_die(ERROR, $upload_plugin_error, __FILE__, __LINE__);
    }



For SWF upload in file upload.php

Find around line 1015:
Code: [Select]
    // prevent moving the edit directory...
    if (is_dir($path_to_image)) {
        echo 'error|'.$lang_upload_php['failure'] . " - '$path_to_image'|0";
        exit;
    }

After that add:
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_swf_pre_move');
    if ($upload_plugin_error) {
        echo 'error|'.$upload_plugin_error.'|0';
        exit;
    }

Works great for me ...

Cheers
Jayhunter

Your hook suggestion is too specific imo. I suggest to add the following hooks.

Instead of adding
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_html_pre_move');
    if ($upload_plugin_error) {
        cpg_die(ERROR, $upload_plugin_error, __FILE__, __LINE__);
    }
we should add
Code: [Select]
CPGPluginAPI::action('upload_html_pre_move');

And instead of adding
Code: [Select]
    // Give plugins a chance to error check
    $upload_plugin_error = CPGPluginAPI::filter('upload_swf_pre_move');
    if ($upload_plugin_error) {
        echo 'error|'.$upload_plugin_error.'|0';
        exit;
    }
we should add
Code: [Select]
CPGPluginAPI::action('upload_swf_pre_move');

You can check for errors directly in your plugin code and let Coppermine die etc.
Logged

jayhunter

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Re: Plugin hook suggestions for cpg1.5.x
« Reply #8 on: September 27, 2010, 05:48:17 PM »

Your hook suggestion is too specific imo.

You're right. Your suggestions are way cleaner. Wasn't thinking right. ;)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #9 on: September 27, 2010, 06:15:47 PM »

Will add that hooks probably tomorrow after reviewing the code. Maybe there's also another (better) solution ;)
Logged

jayhunter

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Re: Plugin hook suggestions for cpg1.5.x
« Reply #10 on: September 27, 2010, 07:56:01 PM »

Will add that hooks probably tomorrow after reviewing the code. Maybe there's also another (better) solution ;)

Yeah. Actually, the upload handling in total is a bit unclean imho. Kind of massed up to have the SWF upload and HTML form output in one file but the HTML upload processing in another. A clean separation into an upstream upload plugin/method handler and the different proccesing methods would be nice.

Back to topic.

In picmgnt.inc.php line 36 or so
Code: [Select]
    $add_file_error = CPGPluginAPI::filter('add_file_start');
    if ($add_file_error) {
        return $add_file_error;
    }
might do the trick. But as i see it there is not much to work with at that point. For my purpose i'd need $work_image (or similar) to be global or to be passed with the filter.

An action hook wouldn't do me any good here, as I don't want to have to deal with further error handling (like unlinking files that have already been moved) only because my dupe check machted something. Also the different upload methodes need different output to die properly.

Well, maybe you come up with the ultimate idea. :)

Thanks very much.

Jayhunter
Logged

jayhunter

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Re: Plugin hook suggestions for cpg1.5.x
« Reply #11 on: October 02, 2010, 03:36:29 AM »

Hey there. Me again. :)

First I wanted to ask: Any news on the upload_pre_move or add_file_start hooks?

Secondly I got a new hook suggestion. I use it in conjunction with add_file_data_success and after_delete_file to keep a keyword cache up-to-date. Would love to see this one added.

In editpics.php find line 367
Code: [Select]
            cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid = $pid");
After that add:
Code: [Select]
            // Plugin filter to be called after a file update is committed
            CPGPluginAPI::filter('after_edit_file', $pid);

And in edit_one_pic.php find line 165
Code: [Select]
    $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid='$pid' LIMIT 1";

    cpg_db_query($query);
After that also add:
Code: [Select]
    // Plugin filter to be called after a file update is committed
    CPGPluginAPI::filter('after_edit_file', $pid);

Cheers
Jayhunter

Gallery @ http://htbackdrops.com
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #12 on: October 13, 2010, 04:12:49 PM »

Hello jayhunter. I finally found some time to have a look at this topic again.

Regarding your dupe check:
- Hook 'upload_html_pre_move': if your plugin uses cpg_die(); everything should be okay. The file resides in the temp directory and will be deleted automatically  I think.
- Hook 'upload_swf_pre_move': I currently don't know if Coppermine has a garbage collection for the edit folder, but I think it hasn't. So you'll have to unlink that file within your plugin before you return your error message.
- Hook 'add_file_start': I also think that hook isn't the best solution for your purpose because of the different output to die properly.


Regarding your keyword cache:
- Hooks 'after_edit_file': as you don't want to filter anything but you just want to perform something (without modifying the passed values) I suggest to use an action hook. It's been a while I had a look at the plugin API, but I afaik the only difference between filter and action hooks is the name (= they work the same way, can return something or do anything else).
Logged

jayhunter

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Re: Plugin hook suggestions for cpg1.5.x
« Reply #13 on: October 13, 2010, 06:09:54 PM »

Hey André.

Thanks for your response.

I actually already use simple action hooks for 'upload_swf_pre_move' and 'upload_html_pre_move'.
And I don't perform any file unlinking. upload.php and db_input.php don't do it either at that point. That would just have been necessary with the 'add_file_start' hook as the files already would have been moved to their final location here.

An action for 'after_edit_file' is okay for me too. I used filter here .. well, because I copied it from 'before_delete_file' or 'after_delete_file', which should be action hooks, too. Atleast by your definition. :)

Cheers
Jayhunter
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #14 on: October 13, 2010, 06:49:31 PM »

I'll add the discussed hooks (except add_file_start) soon, probably tomorrow.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #15 on: October 14, 2010, 11:48:53 AM »

Added hooks in r7968.
Logged

programista

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Plugin hook suggestions for cpg1.5.x
« Reply #16 on: December 11, 2010, 05:37:35 PM »

I think that there should be a hook for displaying additional content in some special case pages or pages that show up in response to post, like information message after registering but when only admin can activate account - it would simplify making additional register futures like account activation only after payment.

Short example - user registers, only admin can activate account, user gets a message of this, the line 632 in register.php i responsible for this:

Code: [Select]
msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');
Now i would like to not change anything in register.php but i would like to display some additional markup with payment options to activate account, instead of only showing a msg_box, it should also give access to registered user data in case i would like to generate payment markup from that data.

In simple scenario this would work with an iframe that generates output based on user name or email sent as query string to that iframe script and showing the return html instead of that message.
As for now i need to change the register.php code, because there are no other way.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15210
Re: Plugin hook suggestions for cpg1.5.x
« Reply #17 on: December 11, 2010, 06:26:29 PM »

What's your actual hook suggestion? We already have some hooks for the registration process (register_form_create, register_form_submit,    register_user_activation) and you can always use the page_html hook to modify every page.
Logged

1aB

  • Contributor
  • Coppermine novice
  • ***
  • Country: de
  • Offline Offline
  • Posts: 29
    • Home Page
Re: Plugin hook suggestions for cpg1.5.x
« Reply #18 on: January 28, 2011, 12:56:34 AM »

It would be cool if the appearance of the album information in the "alblist" (index.php, function list_albums) could be customized by a plugin, to e.g. add a small button (social_sharing plugin)

Not sure if the hook should be best inside function list_albums (then probably just before calling theme_display_album_list)
- in the hook the plugin would have to go through all the $alb_list allbum datastructure at once, and could add to all albums' titles or descriptions or whatever it finds in the data structure.

or in function theme_display_album_list (then probably just before calling template_eval($album_cell, $params) )
- the plugin could adjust the $params and would be called individually for each album in a hook like this
- would it be a disadvantage for a plugin to use a hook which is "themed" and might not be called by all possible themes?
Logged

paperlife

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Plugin hook suggestions for cpg1.5.x
« Reply #19 on: May 10, 2012, 10:33:33 PM »

unsure if this is a revival, or will even be viewed, but i searched, and have ideas...but don't know code **yet))

upon upload, have uploader remember last location of last image (this is useful in single item upload) as many pics are 3 or more levels deep, and there seems to be a time limit on selection

remove time limit on selecting images to upload

Logged
Pages: [1] 2   Go Up
 

Page created in 0.094 seconds with 20 queries.