Esempio n. 1
0
            echo $controller->is_userdata_copyable($cmid);
            exit;
        case 'backup':
            $cmid = required_param('cmid', PARAM_INT);
            $userdata = required_param('userdata', PARAM_BOOL);
            $controller->backup($cmid, $userdata);
            exit;
        case 'movedir':
            $id = required_param('id', PARAM_INT);
            $to = required_param('to', PARAM_TEXT);
            $controller->movedir($id, $to);
            exit;
        case 'move':
            $id = required_param('id', PARAM_INT);
            $to = required_param('to', PARAM_INT);
            $controller->move($id, $to);
            exit;
        case 'delete':
            $id = required_param('id', PARAM_INT);
            $controller->delete($id);
            exit;
    }
    throw new sharing_cart\exception('invalidoperation');
} catch (Exception $ex) {
    header('HTTP/1.1 400 Bad Request');
    $json = array('message' => $ex->getMessage());
    if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
        $json += array('file' => substr($ex->getFile(), strlen($CFG->dirroot)), 'line' => $ex->getLine(), 'trace' => format_backtrace($ex->getTrace(), true));
    }
    echo json_encode($json);
}