Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-16583 Clean up JavaScript usage in HEAD
  3. MDL-17084

Allow JavaScript to set user preferences

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 2.0
    • JavaScript
    • None
    • MOODLE_20_STABLE
    • MOODLE_20_STABLE

    Description

      Sometimes JavaScript will need to set user preferences, for example to remember whether the user likes certain things collapsed or expanded. To this end, I propose a new script:

      .../lib/ajax/setuserpref.php?sesskey=XXXX&pref=[prefname]&value=[value]

      To avoid security problems, this scrip will only process an update if you have previously called a PHP function

      user_preference_allow_ajax_update($name, PARAM_XXX);

      This sets $USER->ajax_updatable_user_prefs[$name] = PARAM_XXX;

      and sesskey will only update user preferences where the appropriate key is set in the session, and it will clean the value as specified there before doing the update.

      Attachments

        Issue Links

          Activity

            People

              timhunt Tim Hunt
              timhunt Tim Hunt
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                24/Nov/10