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

Plugins should be able to define new bulk user actions

XMLWordPrintable

    • 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  

      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.

        1. Screenshot_1.png
          138 kB
          Janelle Barcega
        2. Screenshot_2.png
          174 kB
          Janelle Barcega

            brendanheywood Brendan Heywood
            nicus Lorenzo Nicora (Inactive)
            Peter Burnett Peter Burnett
            Adrian Greeve Adrian Greeve
            Janelle Barcega Janelle Barcega
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.