Pastoid

Handle Mail Test Plugin

The page you are looking at now is at this URL: http://pastoid.com/bmg

This paste was last updated on January 17, 2009 at 1:57 pm.

Pasted Coderaw

<?php
 
	class Handle_Mail_Test extends Plugin {
 
		public function info()
		{
			return array (
				'name' => 'Handle Mail Test',
				'url' => 'http://habariproject.org',
				'author' => 'Habari Community',
				'authorurl' => 'http://habariproject.org',
				'version' => 0.1,
				'description' => 'Handles Utils::mail() and displays a message.',
				'license' => 'Apache License 2.0',
			);
		}
 
		public function filter_plugin_config( $actions, $plugin_id )
		{
			if ( $plugin_id == $this->plugin_id() ) {
				$actions[] = _t( 'Test' );
			}
 
			return $actions;
		}
 
 
		public function action_plugin_ui( $plugin_id, $action )
		{
			if ( $plugin_id == $this->plugin_id() ) {
 
				if ( $action == _t( 'Test' ) ) {
 
					$result = Utils::mail( 'to@example.com', 'Test Email', 'This is a test email that should end up in the logs.' );
 
				}
 
			}
		}
 
		public function filter_send_mail ( $handled, $mail ) {
 
			// stop all messages. log them and trigger a session alert instead
			$log = EventLog::log( "New mail message '" . $mail['subject'] . "' sent to " . $mail['to'] . ": " . $mail['message'] );
 
			Session::notice( 'A new mail message, sent to ' . $mail['to'] . ', was handled. You can find it in the log with ID ' . $log->id );
 
			return true;
 
		}
 
	}
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 5
search.live.com 1
Is this paste spam?
<Hide