'Prowl Push Notifications', 'name' => t('Prowl'), 'group' => 'prowl', // Class of send method 'type' => MESSAGING_TYPE_SEND, 'glue' => ' ', 'description' => t('Send notification using Prowl.'), 'render callback' => 'messaging_prowl_render', 'send callback' => 'messaging_prowl_send_msg', 'destination callback' => 'messaging_prowl_user_destination', ); return $info; } } /** * Message Render callback */ function messaging_prowl_render($message, $info) { // We need to apply filtering first or run through the render function $message = messaging_message_render($message, $info); // Now we do some clean up in the body that may contain new lines, replace them with spaces if ($message->body) { $message->body = messaging_text_clean($message->body, ' '); } return $message; } /** * Map user account to Prowl destination (Prowl API key) */ function messaging_prowl_user_destination($account, $message) { // Check for active prowl API key. Simply return it so that the send // callback has a destination array and access everything. if (ctype_alnum($account->prowl_api_key) && (strlen($account->prowl_api_key) == 40)) { watchdog('messaging', 'account: %a', array('%a' => print_r($account->prowl_api_key, True))); return $account->prowl_api_key; } } /** * Send Prowl notification * * This is just a wrapper for prowl_send_any_user_notification() * * @param $destination * Prowl API key */ function messaging_prowl_send_msg($destination, $message, $params = array()) { $text = messaging_text_build($message, ' '); watchdog('messaging', 'sending prowl notification'); return prowl_send_any_user_notification($destination, $text, 'Notification'); } /** * Implementation of hook_disable() */ function messaging_prowl_disable() { messaging_method_disable('prowl'); }