get_plan_template.json.php 1.01 KB
Newer Older
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
<?php
/**
 *
 * @package    mahara
 * @subpackage artefact-plans
 * @author     Alexander Del Ponte
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */

use artefact\plans\tools\PlansTools;

define('INTERNAL', 1);
define('JSON', 1);

try {
    require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
    require(dirname(dirname(__FILE__)) . '/tools/PlansTools.php');
    safe_require('artefact', 'plans');

    if (!PluginArtefactPlans::is_active()) {
        throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('Plans', 'artefact.plans')));
    }

    $planId = param_integer('planid');
    $userPlanTemplate = new ArtefactTypePlan($planId);

    $result = PlansTools::getArrayOfUserPlanTemplateForForm($userPlanTemplate);
}
catch (Exception $e) {
    json_reply(true, $e->getMessage());
    die;
}

json_reply(false, (object) $result);