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

User web service functions do not trigger user events.

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.1.2, 2.2, 2.3
    • 2.1.4, 2.2.1
    • Web Services
    • None
    • MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • 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.

    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

      Attachments

        Activity

          People

            jerome Jérôme Mouneyrac
            jerome Jérôme Mouneyrac
            Rossiani Wijaya Rossiani Wijaya
            Sam Hemelryk Sam Hemelryk
            Rajesh Taneja Rajesh Taneja
            Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9/Jan/12