more module updates

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 18:02:17 +02:00
parent 37fbabab56
commit 7c85261e56
100 changed files with 6518 additions and 913 deletions

View File

@@ -0,0 +1,77 @@
<?php
/**
* @file
* Implements actions for managing books (book.module).
*/
function views_bulk_operations_book_action_info() {
$actions = array();
if (module_exists('book')) {
$actions['views_bulk_operations_move_to_book_action'] = array(
'type' => 'node',
'label' => t('Move to book'),
'configurable' => TRUE,
'behavior' => array('changes_property'),
);
$actions['views_bulk_operations_remove_from_book_action'] = array(
'type' => 'node',
'label' => t('Remove from book'),
'configurable' => FALSE,
);
}
return $actions;
}
function views_bulk_operations_move_to_book_action_form($context) {
$form = array();
if (!isset($context['book'])) {
$context['book'] = '';
}
$options = array();
$books = book_get_books();
foreach ($books as $value) {
$options[$value['nid']] = $value['title'];
}
if (empty($options)) {
drupal_set_message(t('You have no books.'), 'error');
return array();
}
$form['book'] = array(
'#type' => 'select',
'#title' => t('Choose a parent book'),
'#options' => $options,
'#description' => t('Select the parent book page you wish to move the book page into'),
);
return $form;
}
function views_bulk_operations_move_to_book_action_submit($form, $form_state) {
return array('book' => $form_state['values']['book']);
}
function views_bulk_operations_move_to_book_action($node, $context = array()) {
if (isset($context['book'])) {
$book_node = node_load($context['book']);
$mlid = db_select('menu_links' , 'ml')
->condition('ml.link_path' , 'node/' . $node->nid)
->fields('ml' , array('mlid'))
->execute()
->fetchField();
$node->book['mlid'] = $mlid;
$node->book['bid'] = $book_node->nid;
$node->book['plid'] = $book_node->book['mlid'];
$node->book['module'] = 'book';
}
}
/**
* Adds the action 'Remove node from a parent book'
*/
function views_bulk_operations_remove_from_book_action($node, $context) {
$book = $node->book['mlid'];
book_node_delete($node);
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* @file
* VBO action to cancel user accounts.
*/
function views_bulk_operations_user_cancel_action_info() {
return array('views_bulk_operations_user_cancel_action' => array(
'type' => 'user',
'label' => t('Cancel user account'),
'configurable' => TRUE,
'behavior' => array('deletes_property'),
));
}
function views_bulk_operations_user_cancel_action_form($context) {
module_load_include('inc', 'user', 'user.pages');
$form['user_cancel_method'] = array(
'#type' => 'item',
'#title' => t('When cancelling these accounts'),
);
$form['user_cancel_method'] += user_cancel_methods();
// Remove method descriptions.
foreach (element_children($form['user_cancel_method']) as $element) {
unset($form['user_cancel_method'][$element]['#description']);
}
$admin_access = user_access('administer users');
$default_notify = variable_get('user_mail_status_canceled_notify', FALSE);
$form['user_cancel_notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify user when account is canceled.'),
'#default_value' => ($admin_access ? FALSE : $default_notify),
'#access' => $admin_access && $default_notify,
'#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
);
return $form;
}
function views_bulk_operations_user_cancel_action_submit($form, $form_state) {
return array(
'user_cancel_method' => $form_state['values']['user_cancel_method'],
'user_cancel_notify' => $form_state['values']['user_cancel_notify'],
);
}
function views_bulk_operations_user_cancel_action($account, $context) {
global $user;
// Prevent the user from cancelling itself.
if ($account->uid == $user->uid) {
return;
}
// Allow other modules to react on the cancellation.
if ($context['user_cancel_method'] != 'user_cancel_delete') {
module_invoke_all('user_cancel', array(), $account, $context['user_cancel_method']);
}
switch ($context['user_cancel_method']) {
case 'user_cancel_block':
case 'user_cancel_block_unpublish':
default:
// Send account blocked notification if option was checked.
if (!empty($context['user_cancel_notify'])) {
_user_mail_notify('status_blocked', $account);
}
user_save($account, array('status' => 0));
watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
break;
case 'user_cancel_reassign':
case 'user_cancel_delete':
// Send account canceled notification if option was checked.
if (!empty($context['user_cancel_notify'])) {
_user_mail_notify('status_canceled', $account);
}
user_delete($account->uid);
watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
break;
}
}