Support > cpg1.5 plugins

Plugin hook suggestions for cpg1.5.x

<< < (3/7) > >>

jayhunter:

--- Quote from: Αndré 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 ;)

--- End quote ---

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: ---    $add_file_error = CPGPluginAPI::filter('add_file_start');
    if ($add_file_error) {
        return $add_file_error;
    }
--- End code ---
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

jayhunter:
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: ---            cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid = $pid");

--- End code ---
After that add:

--- Code: ---            // Plugin filter to be called after a file update is committed
            CPGPluginAPI::filter('after_edit_file', $pid);

--- End code ---

And in edit_one_pic.php find line 165

--- Code: ---    $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid='$pid' LIMIT 1";

    cpg_db_query($query);
--- End code ---
After that also add:

--- Code: ---    // Plugin filter to be called after a file update is committed
    CPGPluginAPI::filter('after_edit_file', $pid);

--- End code ---

Cheers
Jayhunter

Gallery @ http://htbackdrops.com

Αndré:
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).

jayhunter:
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

Αndré:
I'll add the discussed hooks (except add_file_start) soon, probably tomorrow.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version