Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38511

Plugins should be able to define new bulk user actions

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1) First confirm all the existing 7 bulk actions to confirm they still work, eg

      1. /admin/user/user_bulk.php
      2. Add some users
      3. Send 'Send a message' as the action
      4. Add test message

      You only need to confirm that you've correctly gotten to the actual bulk action page, the actions themselves have not changed.

       

      2) Now test adding a new custom action in a plugin

      /admin/tool/policy/lib.php

      function tool_policy_bulk_user_actions() {
          return [
              'tool_policy_reset_policy' => new action_link(
                  new moodle_url('/admin/tool/policy/do_something.php'),
                  'Reset policy'),
          ];
      }
      

       3) Purge caches

      php admin/cli/purge_caches.php

      4) Now reload the bulk actions page and check that there is an additional action ("With selected users...") of "Reset policy":

      /admin/user/user_bulk.php

      5) Select it. You should go to the url which doesn't exist but that's expected.

      /admin/tool/policy/do_something.php

       

      Show
      1) First confirm all the existing 7 bulk actions to confirm they still work, eg /admin/user/user_bulk.php Add some users Send 'Send a message' as the action Add test message You only need to confirm that you've correctly gotten to the actual bulk action page, the actions themselves have not changed.   2) Now test adding a new custom action in a plugin /admin/tool/policy/lib.php function tool_policy_bulk_user_actions() { return [ 'tool_policy_reset_policy' => new action_link( new moodle_url( '/admin/tool/policy/do_something.php' ), 'Reset policy' ), ]; }  3) Purge caches php admin/cli/purge_caches.php 4) Now reload the bulk actions page and check that there is an additional action ("With selected users...") of "Reset policy": /admin/user/user_bulk.php 5) Select it. You should go to the url which doesn't exist but that's expected. /admin/tool/policy/do_something.php  
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull Master Branch:
      MDL-38511-bulk-actions

      Description

      Bulk user actions page should be reworked to allow developers writing custom bulk actions, without modifying core code.

      AFAIK, to add a new custom bulk action you need to change this 2 core files, were actions are hardwired:

      • user_bulk.php: for dispatching to the correct user_bulk_*.php page)
      • user_bulk_forms.php: for defining dropdown list of actions and checking capabilities

      There is no way to work around it using "local" plugins.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brendanheywood Brendan Heywood
              Reporter:
              nicus Lorenzo Nicora
              Peer reviewer:
              Peter Burnett
              Integrator:
              Adrian Greeve
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jun/20

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h