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

Convert callback 'bulk_user_actions' to hook

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • Hide

      Test 1

      1. Login as administrator and go to Site administration>Users>Bulk user actions
      2. Select some users and perform some bulk actions on them (for example, "Display on page"), make sure they work
      3. Observe that all actions appear under the 'Actions' group including the 'Reset user authentication factors'
      4. Edit file admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php and add a string 'MFA' as a last argument to the $hook->get_action() call (By the below steps)
      5. Return to the bulk user actions page and observe that the action to reset factors is now under the MFA option group

      Apply this patch

      Subject: [PATCH] Test MDL-80566
      ---
      Index: admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php
      IDEA additional info:
      Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
      <+>UTF-8
      ===================================================================
      diff --git a/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php b/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php
      --- a/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php    (revision b82dbf002a21f310a3ffc0380b1277300e6b7d47)
      +++ b/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php    (date 1710740250906)
      @@ -35,7 +35,7 @@
                   $hook->add_action('tool_mfa_reset_factors', new \action_link(
                       new \moodle_url('/admin/tool/mfa/reset_factor.php'),
                       get_string('resetfactor', 'tool_mfa')
      -            ));
      +            ), 'MFA');
               }
           }
       } 

      Or open admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php, replace the content inside callback method with below

      if (has_capability('moodle/site:config', \context_system::instance())) {
          $hook->add_action('tool_mfa_reset_factors', new \action_link(
              new \moodle_url('/admin/tool/mfa/reset_factor.php'),
              get_string('resetfactor', 'tool_mfa')
          ), 'MFA');
      } 

      Test 2

      1. Install plugin https://github.com/marinaglancy/moodle-tool_bulkactiondemo
      2. Go to Site administration>Users>Bulk user actions
      3. Try to suspend and unsuspend users using bulk actions. On this page all requests are performed as page reload just like other bulk user actions
      4. Go to Site administration>Users>Browse user list
      5. Try to suspend and unsuspend users using bulk actions. On this page all requests are performed in AJAX and you never need to leave the page

       

       

      Show
      Test 1 Login as administrator and go to Site administration>Users>Bulk user actions Select some users and perform some bulk actions on them (for example, "Display on page"), make sure they work Observe that all actions appear under the 'Actions' group including the 'Reset user authentication factors' Edit file admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php and add a string 'MFA' as a last argument to the $hook->get_action() call (By the below steps) Return to the bulk user actions page and observe that the action to reset factors is now under the MFA option group Apply this patch Subject: [PATCH] Test MDL-80566 --- Index: admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php b/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php --- a/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php    (revision b82dbf002a21f310a3ffc0380b1277300e6b7d47) +++ b/admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php    (date 1710740250906) @@ -35,7 +35,7 @@              $hook->add_action('tool_mfa_reset_factors', new \action_link(                  new \moodle_url('/admin/tool/mfa/reset_factor.php'),                  get_string('resetfactor', 'tool_mfa') -            )); +            ), 'MFA');          }      }  } Or open admin/tool/mfa/classes/local/hooks/extend_bulk_user_actions.php, replace the content inside callback method with below if (has_capability( 'moodle/site:config' , \context_system::instance())) { $hook->add_action( 'tool_mfa_reset_factors' , new \action_link( new \moodle_url( '/admin/tool/mfa/reset_factor.php' ), get_string( 'resetfactor' , 'tool_mfa' ) ), 'MFA' ); } Test 2 Install plugin https://github.com/marinaglancy/moodle-tool_bulkactiondemo Go to Site administration>Users>Bulk user actions Try to suspend and unsuspend users using bulk actions. On this page all requests are performed as page reload just like other bulk user actions Go to Site administration>Users>Browse user list Try to suspend and unsuspend users using bulk actions. On this page all requests are performed in AJAX and you never need to leave the page    
    • WP Sprint 2024-I1.2 (Clones), WP Sprint 2024-I1.3 (Atlantic)

      Related to MDL-80548 . Now we make bulk actions available in the user list as well, it is a good moment to migrate the 'bulk_user_actions' to a hook.

      We can also improve it by:

      • allowing plugins to organise the actions in the option groups in the select
      • add documentation how to implement JS (for example JS confirmation, submitting as AJAX requests and refreshing the table without refreshing the page).
      • allow plugins to remove or override actions added by core or other plugins

      The last one is beneficial for workplace since we make some modifications to the "Bulk user actions" related to the multi-tenancy

        1. after_patch.png
          after_patch.png
          23 kB
        2. ajax_actions_screencast.mp4
          1.53 MB
        3. before_patch.png
          before_patch.png
          18 kB
        4. MDL-80566-test 1.png
          MDL-80566-test 1.png
          430 kB
        5. MDL-80566-test 2.png
          MDL-80566-test 2.png
          967 kB
        6. with_categories.png
          with_categories.png
          24 kB

            marina Marina Glancy
            marina Marina Glancy
            Carlos Castillo Carlos Castillo
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 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 - 1 day, 3 hours, 40 minutes
                1d 3h 40m

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