forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ajax: MDL-17084 provide a way for JavaScript to update user preferences.
- Loading branch information
tjhunt
committed
Oct 31, 2008
1 parent
bc0b96f
commit bd1884f
Showing
5 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php // $Id$ | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// NOTICE OF COPYRIGHT // | ||
// // | ||
// Moodle - Modular Object-Oriented Dynamic Learning Environment // | ||
// http://moodle.org // | ||
// // | ||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // | ||
// // | ||
// This program is free software; you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation; either version 2 of the License, or // | ||
// (at your option) any later version. // | ||
// // | ||
// This program is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details: // | ||
// // | ||
// http://www.gnu.org/copyleft/gpl.html // | ||
// // | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Code to update a user preference in response to an ajax call. You should not | ||
* send requests to this script directly. Instead use the set_user_preference | ||
* function in javascript_static.js. | ||
* | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License | ||
* @package moodlecore | ||
*/ | ||
|
||
require_once(dirname(__FILE__) . '/../../config.php'); | ||
|
||
// Check access. | ||
if (!isloggedin()) {; | ||
print_error('mustbeloggedin'); | ||
} | ||
if (!confirm_sesskey()) { | ||
print_error('invalidsesskey'); | ||
} | ||
|
||
// Get the name of the preference to update, and check it is allowed. | ||
$name = required_param('pref', PARAM_RAW); | ||
if (!isset($USER->ajax_updatable_user_prefs[$name])) { | ||
print_error('notallowedtoupdateprefremotely'); | ||
} | ||
|
||
// Get and the value. | ||
$value = required_param('value', $USER->ajax_updatable_user_prefs[$name]); | ||
|
||
// Update | ||
if (!set_user_preference($name, $value)) { | ||
print_error('errorsettinguserpref'); | ||
} | ||
|
||
echo 'OK'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters