Commit 00b36525 authored by YaronMiro's avatar YaronMiro Committed by RoySegall

Adding VBO support to send multiple messages

parent 790f3db4
......@@ -5,3 +5,7 @@ package = Message
dependencies[] = message_ui
dependencies[] = message_notify
dependencies[] = views_bulk_operations
; Views.
files[] = views/handlers/message_notify_ui_notify_button.inc
......@@ -45,6 +45,16 @@ function message_notify_ui_permission() {
);
}
/**
* Implements hook_views_api().
*/
function message_notify_ui_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'message_notify_ui') . '/views',
);
}
/**
* Send notification of a message.
*/
......@@ -127,3 +137,33 @@ function message_notify_ui_send_notification_submit($form, &$form_state) {
$form_state['redirect'] = 'message/' . $message->mid;
}
/**
* Implements hook_action_info().
*/
function message_notify_action_info() {
return array(
'message_notify_send_email_vbo' => array(
'type' => 'message',
'label' => t('Send as e-mail to the owner of the message'),
'behavior' => array('changes_property'),
'configurable' => FALSE,
'vbo_configurable' => FALSE,
'triggers' => array('any'),
),
);
}
/**
* VBO callback function.
*
* Sending email to each selected message.
*
* @param $message
* The message object.
* @param $context
* The context data array.
*/
function message_notify_send_email_vbo(&$message, $context) {
message_notify_send_message($message);
}
<?php
/**
* Notify button for a message instance.
*/
class message_notify_ui_notify_button extends views_handler_field_entity {
function render($values) {
$message = message_load($values->mid);
if (user_access('send message notify')) {
return l(t('Notify'), 'message/' . $message->mid . '/notify');
}
}
}
<?php
/**
* @file
* integration with the views module.
*/
/**
* Implements hook_views_data().
*/
function message_notify_ui_views_data() {
$data['message']['notify'] = array(
'title' => t('Notify message'),
'help' => t('Send the message using a notifier.'),
'field' => array(
'handler' => 'message_notify_ui_notify_button',
),
);
return $data;
}
/**
* Implements hook_views_default_views_alter().
*/
function message_notify_ui_views_default_views_alter(&$views) {
if (!in_array('message', array_keys($views))) {
return;
}
$handler =& $views['message']->display['default']->handler;
/* Field: Bulk operations: Message */
$field['views_bulk_operations']['id'] = 'views_bulk_operations';
$field['views_bulk_operations']['table'] = 'message';
$field['views_bulk_operations']['field'] = 'views_bulk_operations';
$field['views_bulk_operations']['vbo_settings']['display_type'] = '0';
$field['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1;
$field['views_bulk_operations']['vbo_settings']['force_single'] = 0;
$field['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
$field['views_bulk_operations']['vbo_operations'] = array(
'action::message_notify_send_email_vbo' => array(
'selected' => 1,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
),
);
/* Field: Message: View message */
$field['view']['id'] = 'view';
$field['view']['table'] = 'message';
$field['view']['field'] = 'view';
$field['view']['label'] = '';
$field['view']['exclude'] = TRUE;
$field['view']['element_label_colon'] = FALSE;
/* Field: Message: Notify message */
$field['notify']['id'] = 'notify';
$field['notify']['table'] = 'message';
$field['notify']['field'] = 'notify';
$field['notify']['label'] = '';
$field['notify']['exclude'] = TRUE;
$field['notify']['element_label_colon'] = FALSE;
$handler->display->display_options['fields'] = $field + $handler->display->display_options['fields'];
/* Field: Global: Custom text */
$text = '[notify] ';
// In case this value was set previously by another "views_default_views_alter".
if (isset($handler->display->display_options['fields']['nothing']['alter']['text'])) {
$handler->display->display_options['fields']['nothing']['alter']['text'] .= $text;
}
else {
$handler->display->display_options['fields']['nothing']['alter']['text'] = $text;
}
}
......@@ -43,30 +43,43 @@ function message_ui_views_default_views_alter(&$views) {
$handler =& $views['message']->display['default']->handler;
/* Field: Message: Edit message */
$handler->display->display_options['fields']['edit']['id'] = 'edit';
$handler->display->display_options['fields']['edit']['table'] = 'message';
$handler->display->display_options['fields']['edit']['field'] = 'edit';
$handler->display->display_options['fields']['edit']['label'] = '';
$handler->display->display_options['fields']['edit']['exclude'] = TRUE;
$handler->display->display_options['fields']['edit']['element_label_colon'] = FALSE;
$field['edit']['id'] = 'edit';
$field['edit']['table'] = 'message';
$field['edit']['field'] = 'edit';
$field['edit']['label'] = '';
$field['edit']['exclude'] = TRUE;
$field['edit']['element_label_colon'] = FALSE;
/* Field: Message: Delete message */
$handler->display->display_options['fields']['delete']['id'] = 'delete';
$handler->display->display_options['fields']['delete']['table'] = 'message';
$handler->display->display_options['fields']['delete']['field'] = 'delete';
$handler->display->display_options['fields']['delete']['label'] = '';
$handler->display->display_options['fields']['delete']['exclude'] = TRUE;
$handler->display->display_options['fields']['delete']['element_label_colon'] = FALSE;
$field['delete']['id'] = 'delete';
$field['delete']['table'] = 'message';
$field['delete']['field'] = 'delete';
$field['delete']['label'] = '';
$field['delete']['exclude'] = TRUE;
$field['delete']['element_label_colon'] = FALSE;
/* Field: Message: View message */
$handler->display->display_options['fields']['view']['id'] = 'view';
$handler->display->display_options['fields']['view']['table'] = 'message';
$handler->display->display_options['fields']['view']['field'] = 'view';
$handler->display->display_options['fields']['view']['label'] = '';
$handler->display->display_options['fields']['view']['exclude'] = TRUE;
$handler->display->display_options['fields']['view']['element_label_colon'] = FALSE;
$field['view']['id'] = 'view';
$field['view']['table'] = 'message';
$field['view']['field'] = 'view';
$field['view']['label'] = '';
$field['view']['exclude'] = TRUE;
$field['view']['element_label_colon'] = FALSE;
$handler->display->display_options['fields'] = $field + $handler->display->display_options['fields'];
/* Field: Global: Custom text */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = 'Operation';
$handler->display->display_options['fields']['nothing']['alter']['text'] = '[view] [edit] [delete]';
$text = '[view] [edit] [delete] ';
// In case this value was set previously by another "views_default_views_alter".
if (isset($handler->display->display_options['fields']['nothing']['alter']['text'])) {
$handler->display->display_options['fields']['nothing']['alter']['text'] .= $text;
}
else {
$handler->display->display_options['fields']['nothing']['alter']['text'] = $text;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment