Support > cpg1.5 plugins

Plugin hook suggestions for cpg1.5.x

<< < (2/7) > >>

Joachim Müller:
Did as you suggested.

jayhunter:
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: ---    $uploaded_pic = $dest_dir . $picture_name;

--- End code ---

After that add:

--- Code: ---    // 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__);
    }

--- End code ---



For SWF upload in file upload.php

Find around line 1015:

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

--- End code ---

After that add:

--- Code: ---    // 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;
    }

--- End code ---

Works great for me ...

Cheers
Jayhunter

Αndré:

--- Quote from: jayhunter 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: ---    $uploaded_pic = $dest_dir . $picture_name;

--- End code ---

After that add:

--- Code: ---    // 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__);
    }

--- End code ---



For SWF upload in file upload.php

Find around line 1015:

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

--- End code ---

After that add:

--- Code: ---    // 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;
    }

--- End code ---

Works great for me ...

Cheers
Jayhunter

--- End quote ---

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

Instead of adding

--- Code: ---    // 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__);
    }
--- End code ---
we should add

--- Code: ---CPGPluginAPI::action('upload_html_pre_move');
--- End code ---


And instead of adding

--- Code: ---    // 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;
    }
--- End code ---
we should add

--- Code: ---CPGPluginAPI::action('upload_swf_pre_move');
--- End code ---


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

jayhunter:

--- Quote from: Αndré on September 27, 2010, 11:13:24 am ---Your hook suggestion is too specific imo.

--- End quote ---

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

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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version