-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.php
79 lines (63 loc) · 2.59 KB
/
services.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* This provides web services for managing users for the login api.
*
* @package auth_apilogin
* @copyright 2015 Blake Kidney
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/*
Moodle already has webservices built in which we could use.
However, for our purposes, we will keep it simple.
https://docs.moodle.org/29/en/Using_web_services
https://docs.moodle.org/dev/Web_services
https://docs.moodle.org/dev/Web_services_API
https://docs.moodle.org/dev/Web_service_API_functions
*/
//------------------------------------------------------------------------
// MOODLE FRAMEWORK
//------------------------------------------------------------------------
//tell Moodle to use an optimized version
define('ABORT_AFTER_CONFIG', 1);
//include Moodle's configuration
require('../../config.php');
//load only the libraries we will need to run just the database
require_once($CFG->libdir.'/setuplib.php');
require_once($CFG->libdir.'/classes/text.php');
require_once($CFG->libdir.'/classes/string_manager.php');
require_once($CFG->libdir.'/classes/string_manager_install.php');
require_once($CFG->libdir.'/classes/string_manager_standard.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/dmllib.php');
require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/sessionlib.php');
require_once($CFG->dirroot.'/cache/lib.php');
//------------------------------------------------------------------------
// SETUP
//------------------------------------------------------------------------
//setup the database and connect
setup_DB();
//pull the configuration for the site
initialise_cfg();
//------------------------------------------------------------------------
// ERROR SETTINGS - FOR DEVELOPMENT
//------------------------------------------------------------------------
//*
$CFG->displaydebug = true;
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 0);
//*/
//------------------------------------------------------------------------
// LOAD API CLASS
//------------------------------------------------------------------------
require_once($CFG->dirroot.'/auth/apilogin/lib.php');
$api = new auth_apilogin_lib();
//------------------------------------------------------------------------
// VALIDATE REQUEST
//------------------------------------------------------------------------
$api->validateRequest($_POST);
//------------------------------------------------------------------------
// PROCESS REQUEST
//------------------------------------------------------------------------
call_user_func(array($api, $_POST['method']), $_POST);