diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php index 59f3a0d..e37d498 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php @@ -8,8 +8,10 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Component\Annotation\PluginID; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\system\Plugin\views\field\BulkFormBase; use Drupal\user\Plugin\Core\Entity\User as UserEntity; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a user operations bulk form element. @@ -19,12 +21,38 @@ class UserBulkForm extends BulkFormBase { /** + * The module handler + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * {@inheritdoc} + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, ModuleHandlerInterface $module_handler) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static($configuration, $plugin_id, $plugin_definition, $container->get('module_handler')); + } + + /** * {@inheritdoc} */ protected function getBulkOptions() { return array_map(function($operation) { return $operation['label']; - }, \Drupal::moduleHandler()->invokeAll('user_operations')); + }, $this->moduleHandler->invokeAll('user_operations')); } /** @@ -70,7 +98,7 @@ public function views_form_submit(&$form, &$form_state) { } } - $operations = \Drupal::moduleHandler()->invokeAll('user_operations', array($form_state['values']['action'])); + $operations = $this->moduleHandler->invokeAll('user_operations', array($form_state['values']['action'])); $operation = $operations[$form_state['values']['action']]; // Filter out unchecked accounts. if ($function = $operation['callback']) { @@ -87,7 +115,9 @@ public function views_form_submit(&$form, &$form_state) { $form_state['redirect'] = $operation['redirect']; } else { - drupal_set_message(format_plural(count($accounts), 'One account was blocked.', '@count accounts were blocked.')); + drupal_set_message(format_plural(count($accounts), '%action was applied to one account.', '%action was applied to @count accounts.', array( + '%action' => $operation['apply_label'], + ))); } } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php index ebd627d..73d6e99 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php @@ -74,14 +74,17 @@ function testUserAdmin() { $edit['user_bulk_form[1]'] = TRUE; $this->drupalPost('admin/people', $edit, t('Apply')); $account = user_load($user_c->uid, TRUE); + $this->assertRaw(t('%action was applied to one account.', array('%action' => t('Blocked')))); $this->assertEqual($account->status, 0, 'User C blocked'); + // Test unblocking of a user from /admin/people page and sending of activation mail $editunblock = array(); $editunblock['action'] = 'unblock'; $editunblock['user_bulk_form[1]'] = TRUE; $this->drupalPost('admin/people', $editunblock, t('Apply')); $account = user_load($user_c->uid, TRUE); + $this->assertRaw(t('%action was applied to one account.', array('%action' => t('Unblocked')))); $this->assertEqual($account->status, 1, 'User C unblocked'); $this->assertMail("to", $account->mail, "Activation mail sent to user C"); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 4d65c0a..b2c9b7e 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -968,11 +968,12 @@ function user_menu() { 'type' => MENU_LOCAL_ACTION, ); $items['admin/people/cancel'] = array( - 'title' => 'Add user', + 'title' => 'Cancel user', 'page callback' => 'drupal_get_form', 'page arguments' => array('user_multiple_cancel_confirm'), 'access arguments' => array('administer users'), 'file' => 'user.admin.inc', + 'type' => MENU_CALLBACK, ); // Administration pages. @@ -1994,14 +1995,17 @@ function user_user_operations($selected_operation = FALSE) { $operations = array( 'unblock' => array( 'label' => t('Unblock the selected users'), + 'apply_label' => t('Unblocked'), 'callback' => 'user_user_operations_unblock', ), 'block' => array( 'label' => t('Block the selected users'), + 'apply_label' => t('Blocked'), 'callback' => 'user_user_operations_block', ), 'cancel' => array( 'label' => t('Cancel the selected user accounts'), + 'apply_label' => t('Canceled'), 'callback' => 'user_user_operations_cancel', 'redirect' => 'admin/people/cancel', ), @@ -2046,6 +2050,7 @@ function user_user_operations($selected_operation = FALSE) { $operations[$selected_operation] = array( 'callback' => 'user_multiple_role_edit', 'callback arguments' => array($operation, $rid), + 'apply_label' => ($operation == 'add_role') ? t('Role @role added', array('@role' => $rid)) : t('Role @role removed', array('@role' => $rid)), ); } else { @@ -2136,7 +2141,7 @@ function user_multiple_role_edit($accounts, $operation, $rid) { function user_multiple_cancel_confirm($form, &$form_state) { global $user; // Retrieve the accounts to be canceled from the temp store. - $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($user->uid); + $accounts = (array) Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($user->uid); $form['accounts'] = array('#prefix' => '', '#tree' => TRUE); foreach ($accounts as $account) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php index 5768aa9..c9f25d7 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php @@ -10,6 +10,7 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Core\Plugin\Discovery\CacheDecorator; +use Drupal\Core\Plugin\Factory\ContainerFactory; use Drupal\views\Plugin\Discovery\ViewsHandlerDiscovery; /** @@ -30,7 +31,7 @@ public function __construct($type, \Traversable $namespaces) { $this->discovery = new ViewsHandlerDiscovery($type, $namespaces); $this->discovery = new CacheDecorator($this->discovery, "views:$type", 'views_info'); - $this->factory = new DefaultFactory($this->discovery); + $this->factory = new ContainerFactory($this); } }