MDL-15488
[moodle.git] / repository / ws.php
CommitLineData
0eb58cf4 1<?php
2require_once('../config.php');
3require_once('lib.php');
4$id = optional_param('id', PARAM_INT);
5$action = optional_param('action', '', PARAM_RAW);
6if(!$repository = $DB->get_record('repository', array('id'=>$id))) {
7 echo json_encode('wrong');
8 die;
9}
10
11if(is_file($CFG->dirroot.'/repository/'.$repository->repositorytype.'/repository.class.php')) {
12 require_once($CFG->dirroot.'/repository/'.$repository->repositorytype.'/repository.class.php');
13 $classname = 'repository_' . $repository->repositorytype;
14 $repo = new $classname($id, SITEID, array('ajax'=>true));
15} else {
16 print_error('invalidplugin', 'repository');
17 echo json_encode('invalidplugin');
18 die;
19}
20
21if($action == 'list') {
22 echo json_encode($repo->get_listing());
23} else {
24 echo json_encode($repo->print_login());
25}
26
27?>