Issue Details (XML | Word | Printable)

Key: MDL-17084
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Tim Hunt
Votes: 0
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-16583

Allow JavaScript to set user preferences

Created: 31/Oct/08 04:29 PM   Updated: 31/Oct/08 05:25 PM
Return to search
Component/s: AJAX
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: Tim Hunt
Security Level: None
Resolved date: 31/Oct/08
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 31/Oct/08 04:30 PM
I will also write a JavaScript function set_user_preference(name, value) in javascript_static.js.

tjhunt committed 5 files to 'Moodle CVS' - 31/Oct/08 05:25 PM
ajax: MDL-17084 provide a way for JavaScript to update user preferences.
MODIFY lib/moodlelib.php   Rev. 1.1121    (+18 -3 lines)
MODIFY lib/weblib.php   Rev. 1.1161    (+4 -3 lines)
MODIFY lang/en_utf8/error.php   Rev. 1.138    (+3 -1 lines)
MODIFY lib/javascript-static.js   Rev. 1.47    (+35 -0 lines)
ADD lib/ajax/setuserpref.php   Rev. 1.1    (+0 -0 lines)
Tim Hunt added a comment - 31/Oct/08 05:25 PM
Petr, I would be grateful if, when you have a moment, you could give this a security review. Thanks.

Tim Hunt made changes - 31/Oct/08 05:25 PM
Field Original Value New Value
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Mitsuhiro Yoshida committed 3 files to 'Lang CVS' - 02/Nov/08 02:27 AM
MDL-17084 Translated new strings for error messages.
MDL-16341 Translated a new string for flickr plugin.
MODIFY ja_utf8/portfolio_flickr.php   Rev. 1.3    (+1 -0 lines)
MODIFY ja_utf8/error.php   Rev. 1.101    (+2 -0 lines)
MODIFY ja_utf8/README   Rev. 1.856    (+1 -1 lines)
martignoni committed 1 file to 'Lang CVS' - 16/Nov/08 07:16 PM
MDL-17084, strings translated
MODIFY fr_utf8/error.php   Rev. 1.143    (+3 -1 lines)