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

User web service functions do not trigger user events.

    Details

    • Type: Task
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1.2, 2.2, 2.3
    • Fix Version/s: 2.1.4, 2.2.1
    • Component/s: Web Services
    • Labels:
      None
    • Testing Instructions:
      Hide

      Create a local plugin with /local/YOURLOCALPLUGIN/db/events.php :

      $handlers = array (
          'user_created' => array (
               'handlerfile'      => '/local/YOURLOCALPLUGIN/lib.php',
               'handlerfunction'  => 'YOURLOCALPLUGIN_user_created',
               'schedule'         => 'instant'
           ),
          
          'user_updated' => array (
               'handlerfile'      => '/local/YOURLOCALPLUGIN/lib.php',
               'handlerfunction'  => 'YOURLOCALPLUGIN_user_updated',
               'schedule'         => 'instant'
           ),
          
      );

      in /local/YOURLOCALPLUGIN/lib.php:

      function YOURLOCALPLUGIN_user_created ($user) {
          error_log(print_r('An user has been created - wstemplate Tester plugin event handler', true));   
          error_log(print_r($user, true));
      }
       
      function YOURLOCALPLUGIN_user_updated ($user) {
          error_log(print_r('An user has been updated - wstemplate Tester plugin event handler', true));   
          error_log(print_r($user, true));
      }

      Then call the web service 'create users' and 'update users' functions with a ws client (https://github.com/moodlehq/sample-ws-clients)

      You should see the error logs meaning that the events have been correctly triggered.

      Show
      Create a local plugin with /local/YOURLOCALPLUGIN/db/events.php : $handlers = array ( 'user_created' => array ( 'handlerfile' => '/local/YOURLOCALPLUGIN/lib.php', 'handlerfunction' => 'YOURLOCALPLUGIN_user_created', 'schedule' => 'instant' ), 'user_updated' => array ( 'handlerfile' => '/local/YOURLOCALPLUGIN/lib.php', 'handlerfunction' => 'YOURLOCALPLUGIN_user_updated', 'schedule' => 'instant' ), ); in /local/YOURLOCALPLUGIN/lib.php: function YOURLOCALPLUGIN_user_created ($user) { error_log(print_r('An user has been created - wstemplate Tester plugin event handler', true)); error_log(print_r($user, true)); }   function YOURLOCALPLUGIN_user_updated ($user) { error_log(print_r('An user has been updated - wstemplate Tester plugin event handler', true)); error_log(print_r($user, true)); } Then call the web service 'create users' and 'update users' functions with a ws client ( https://github.com/moodlehq/sample-ws-clients ) You should see the error logs meaning that the events have been correctly triggered.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:

      Description

      browse the entire web service functions and check that they implement the trigger indicated in the documentation: http://docs.moodle.org/dev/Events_API#Events_which_exist

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Jan/12