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

New Web Service core_user_update_picture

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token in the mobile app service for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Upload an image to be used as your new profile image via curl (replace the filedata and token)

        curl -i -F filedata=@/Users/juanleyvadelgado/Documents/jleyva.jpeg "http://localhost/m/stable_master/webservice/upload.php?token=ffbe3a3002f235bf9d01fd9369e10b66&filearea=draft"

      4. The itemid returned by the previous function will be the draftitemid for the next request:
      5. Next, you can do a CURL REST call simulating a WS client with the user to replace your image
        • You need to replace the wstoken, draftitemid (itemid of the previous request) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=458584267&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      6. Log out from Moodle, log in again and check that your see your now profile image
      7. Now, delete the image:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=0&delete=1&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      8. Log out and log in again to check that you see the Moodle default image
      9. You can optionally check that the WS don't work if you are trying to edit a mnet user, or a user using an authentication method that does not allow profile editing. There is also a global setting for disabling user profile images, you can enable that to check that the WS fails
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token in the mobile app service for one user: Click on Site administration ► Plugins ► Web services ► Manage tokens Upload an image to be used as your new profile image via curl (replace the filedata and token) curl -i -F filedata=@/Users/juanleyvadelgado/Documents/jleyva.jpeg "http://localhost/m/stable_master/webservice/upload.php?token=ffbe3a3002f235bf9d01fd9369e10b66&filearea=draft" The itemid returned by the previous function will be the draftitemid for the next request: Next, you can do a CURL REST call simulating a WS client with the user to replace your image You need to replace the wstoken, draftitemid (itemid of the previous request) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=458584267&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Log out from Moodle, log in again and check that your see your now profile image Now, delete the image: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=0&delete=1&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Log out and log in again to check that you see the Moodle default image You can optionally check that the WS don't work if you are trying to edit a mnet user, or a user using an authentication method that does not allow profile editing. There is also a global setting for disabling user profile images, you can enable that to check that the WS fails
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-56070-master

      Description

      Updates or deletes the user picture

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Dani Palou
              Integrator:
              David Monllaó
              Tester:
              David Monllaó
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                5/Dec/16