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

Plugins should be able to define new bulk user actions

    XMLWordPrintable

Details

    • MOODLE_24_STABLE, MOODLE_39_STABLE
    • MOODLE_39_STABLE
    • MDL-38511-bulk-actions
    • 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  

    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

              brendanheywood Brendan Heywood
              nicus Lorenzo Nicora
              Peter Burnett Peter Burnett
              Adrian Greeve Adrian Greeve
              Janelle Barcega Janelle Barcega
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                15/Jun/20

                Time Tracking

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