This patch is allowing developers to get file id from own plugin.
[attachment=0]
Here are changes in methods Plugin_class.php (not included in patch)
Code:
/*
* This function is run after a new file is added
*/
function onAfterAdd($fileId) {}
/*
* This function is run before the edit file form is finished being rendered
*/
function onBeforeEditFile($fileId) {}
/*
* This function is run after the user saves and change to a file
*/
function onAfterEditFile($fileId) {}
I think I need to edit add.php and edit.php as well.
Something like this:
add.php
Code:
callPluginMethod('onAfterAdd',$fileId);
This will ensure the current $fileid is passed to the onAfterAdd method automatically.
Does that make sense?
Affected files are (see in patch):
add.php
edit.php
functions.php
As you can see, callPluginMethod('onAfterAdd'); was changed to callPluginMethod('onAfterAdd', $fileId); (and for onBeforeEdit and onAfterEdit).
Changes in Plugin_class.php are optional (for documentation)
Patch.diff:
Code:
diff -urB opendocman-unstable-daily-orig/add.php opendocman-unstable-daily/add.php
--- opendocman-unstable-daily-orig/add.php 2011-05-27 08:01:13.000000000 +0200
+++ opendocman-unstable-daily/add.php 2011-05-27 22:00:59.949135276 +0200
@@ -634,7 +634,7 @@
$message = urlencode(msg('message_document_added'));
// Call the plugin API
- callPluginMethod('onAfterAdd');
+ callPluginMethod('onAfterAdd', $fileId);
header('Location: out.php?last_message=' . $message);
}
diff -urB opendocman-unstable-daily-orig/edit.php opendocman-unstable-daily/edit.php
--- opendocman-unstable-daily-orig/edit.php 2011-05-27 08:01:13.000000000 +0200
+++ opendocman-unstable-daily/edit.php 2011-05-27 22:18:05.584915775 +0200
@@ -474,7 +474,7 @@
</td>
<?php
// Call Plugin API
- callPluginMethod('onBeforeEditFile');
+ callPluginMethod('onBeforeEditFile', $data_id);
?>
</tr>
</table>
@@ -576,7 +576,7 @@
$message = urlencode('Document successfully updated');
// Call the plugin API
- callPluginMethod('onAfterEditFile');
+ callPluginMethod('onAfterEditFile', $_REQUEST['id']);
header('Location: out.php?last_message=' . $message);
}
diff -urB opendocman-unstable-daily-orig/functions.php opendocman-unstable-daily/functions.php
--- opendocman-unstable-daily-orig/functions.php 2011-05-27 08:01:13.000000000 +0200
+++ opendocman-unstable-daily/functions.php 2011-05-27 22:00:40.918758424 +0200
@@ -788,7 +788,7 @@
* @param string $method The name of the plugin method being envoked.
* @return null
*/
- function callPluginMethod($method)
+ function callPluginMethod($method, $data=null)
{
foreach ($GLOBALS['plugin']->pluginslist as $value)
{
@@ -797,6 +797,6 @@
echo 'Sorry, your plugin ' . $value . ' is not setup properly';
}
$plugin_obj = new $value;
- $plugin_obj->$method();
+ $plugin_obj->$method($data);
}
}
Great, the changes I am committing are basically the same changes that you have here but with some minor differences in variable naming.
I just committed the changes to the SVN trunk. Please let me know if everything works for you.
Great, it works
Sounds like you have a typo. Try grabbing v1.2.6.4, it contains a more permanent attempt at solving the mime issue.