'. t("This module allows users to associate a Prowl API key with their account.") .'
'; break; } return $output; } // function prowl_user_help /** * Implementation of hook_menu() */ function prowl_user_menu() { $items = array(); // autocomplete for users with prowl api key filled in $items['prowl/autocomplete_user'] = array( 'title' => 'Autocomplete Prowl Users', 'page callback' => 'prowl_user_autocomplete_user', 'access callback' => TRUE, 'access arguments' => array('Administer prowl notifications'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_action_info(). */ function prowl_user_action_info() { return array( 'prowl_user_actions_user_notification_action' => array( 'type' => 'system', 'description' => t('Send a tokenized prowl notification to a drupal user.'), 'configurable' => TRUE, 'hooks' => array( 'nodeapi' => array('view', 'insert', 'update', 'delete'), 'comment' => array('view', 'insert', 'update', 'delete'), 'user' => array('view', 'insert', 'update', 'delete', 'login'), 'taxonomy' => array('insert', 'update', 'delete'), ), ), ); } /** * Return a form definition so the Send notification to a drupal user action can be configured. * * @param $context * Default values (if we are editing an existing action instance). * @return * Form definition. */ function prowl_user_actions_user_notification_action_form($context) { if (!isset($context['event'])) { $context['event'] = ''; } if (!isset($context['message'])) { $context['message'] = ''; } if (!isset($context['priority'])) { $context['priority'] = 0; } if (!isset($context['user'])) { $context['user'] = ''; } if (!isset($context['send_test'])) { $context['send_test'] = False; } $form['user'] = array( '#type' => 'textfield', '#title' => t('User Name'), '#autocomplete_path' => 'prowl/autocomplete_user', '#default_value' => $context['user'], '#size' => '20', '#maxlength' => '60', '#description' => t('The Drupal username of the user to which to send the notification (only users with an API key set will autocomplete).'), ); $form['send_test'] = array( '#type' => 'checkbox', '#title' => t('Send a test notification when submitting this form.'), ); $form['event'] = array( '#type' => 'textfield', '#title' => t('Event'), '#default_value' => $context['event'], '#size' => '20', '#maxlength' => '1024', '#description' => t('The message event type.'), ); $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), '#default_value' => $context['message'], '#cols' => '80', '#rows' => '20', '#description' => t('The message that should be sent.'), ); $form['priority'] = array( '#type' => 'select', '#title' => t('Message priority level'), '#default_value' => $context['priority'], '#options' => array( -2 => t('Very low'), -1 => t('Low'), 0 => t('Moderate'), 1 => t('High'), 2 => t('Emergency'), ), '#description' => t('Set the priority level of this notification'), ); $form['help'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Placeholder tokens'), '#description' => t("The following placeholder tokens can be used in to generate the URL path. Some tokens may not be available, depending on the context in which the action is triggered."), ); $form['help']['tokens'] = array( '#value' => theme('token_help', 'all'), ); return $form; } /** * Submit handler for prowl_user_actions_user_notification_action_form() */ function prowl_user_actions_user_notification_action_submit($form, $form_state) { $form_values = $form_state['values']; // Process the HTML form to store configuration. The keyed array that // we return will be serialized to the database. $params = array( 'event' => $form_values['event'], 'message' => $form_values['message'], 'priority' => $form_values['priority'], 'user' => $form_values['user'], ); if ($form_values['send_test']) { if (prowl_send_user_notification_test($form_values['user'])) { drupal_set_message(t('Sent test notification to user: "%user"', array('%user' => $form_values['user'])), 'status'); } else { drupal_set_message(t('There was an error when attempting to send a notification to user: "%user"', array('%user' => $form_values['user'])), 'warning'); } } return $params; } function prowl_user($op, &$edit, &$account) { switch($op) { case 'register': $form['prowl_info'] = array( '#type' => 'fieldset', '#title' => t('Prowl settings'), '#weight' => -1, '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['prowl_info']['prowl_api_key'] = array( '#type' => 'textfield', '#title' => t('API key for your prowl account.'), '#size' => 40, '#maxlength' => 40, '#description' => t("Go to your prowl settings page to view/generate your API key."), '#required' => False, // '#prefix' => '