Hello!

I need to be able to receive an email when some role users upload files using webfm, how can I create a trigger to do it?

Can someone please enlight me?

Comments

mat.’s picture

subscribed

drupaledmonk’s picture

I was wondering if there was a trigger when a user downloads a file. Can anyone help on how to create a custom trigger? At least a place as to where to start.

cgmonroe’s picture

There are no upload or download triggers in the current code. If you want to patch it to support this, here's some functions to start looking at:

Upload triggers:

Look at webfm_version_upload function and the various options it handles. E.g. do you want to trigger on new files or replacement files, etc.

Download triggers:

Look at the webfm_send_file() function.

Some general programming docs for webfm are located at:

http://drupal.org/node/730368

drupaledmonk’s picture

Thanks a lot cgmonroe for the docs,resources.

drupaledmonk’s picture

I wanted to send a email when a user downloads a file, So I implemented hook_mail() in webfm.module to achieve this. The code is very crude and just achieves what I want.
http://api.drupal.org/api/function/drupal_mail/6

function webfm_mail($key, &$message) {

	switch($key) {
	case 'notice':
	$message['subject'] = t('Notification from !site regarding file Download');
	$message['body'][] = t(&$message );
	break;
	}

In the function
webfm_send_file($fid, $download = false, $bypass_invoke = false)

$send_mail_to="to_address";
drupal_mail('webfm', 'notice', $send_mail_to);

else if you just want to send freaking email then in the
webfm_send_file($fid, $download = false, $bypass_invoke = false)

$username = $user->name;
$filename=$f->fpath;
$message = array(
  'to' => 'to_address',
  'subject' => t('File Download Notification'),
  'body' => t('Hi, A new file has been downloaded by <b>'.$username.'</b>'.'<br/>Filename:'.$filename),
  'headers' => array('From' => 'from_address'),
);
drupal_mail_send($message);
ceejs’s picture

It would be nice if it worked with the 'Action e-mail role' module.

Matilda’s picture

Is there a way to declare webfm-uploads as a content type - webfmUpload for example?

guymelef’s picture

I need to be able to receive an email when some role users upload files using webfm, how can I create a trigger to do it?

Anyone who has a solution or suggestion to this issue?