frameworks.php 4.54 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
<?php
/**
 *
 * @package    mahara
 * @subpackage module-framework
 * @author     Catalyst IT Ltd.
 * @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.
 *
 */

define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configextensions/frameworks');
define('SECTION_PLUGINTYPE', 'module');
define('SECTION_PLUGINNAME', 'framework');
define('SECTION_PAGE', 'frameworks');

require(dirname(dirname(dirname(__FILE__))) . '/init.php');

define('TITLE', get_string('Framework', 'module.framework'));
safe_require('module', 'framework');
23
24
25
26
27
28
29
30
31
32
33
34
35
$upload = param_boolean('upload');

if ($upload) {
    define('SUBSECTIONHEADING', get_string('upload'));
    $form = upload_matrix_form();
    $smarty = smarty();
    setpageicon($smarty, 'icon-th');
    $smarty->assign('wwwroot', get_config('wwwroot'));
    $smarty->assign('form', $form);
    $smarty->display('module:framework:uploadframework.tpl');
    exit;
}

36
37
38
39
$frameworks = Framework::get_frameworks('any');
if ($frameworks) {
    foreach ($frameworks as $framework) {
        $fk = new Framework($framework->id);
40
41
42
43
44
45
46
47
48
49
50
51
        if ($fk->get('active')) {
            $framework->active = array(
                'title' => 'Enabled',
                'classes' => 'icon icon-lg icon-check text-success displayicon'
            );
        }
        else {
            $framework->active = array(
                'title' => 'Disabled',
                'classes' => 'icon icon-lg icon-times text-danger displayicon'
            );
        }
52
53
54
55
56
57
58
59
        $framework->collections = count($fk->get_collectionids());
        $framework->delete = false;
        if (empty($framework->collections)) {
            $framework->delete = pieform(
                array(
                    'name' => 'framework_delete_' . $framework->id,
                    'successcallback' => 'framework_delete_submit',
                    'renderer' => 'div',
60
                    'class' => 'form-inline pull-right framework',
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
                    'elements' => array(
                        'submit' => array(
                            'type'         => 'button',
                            'class'        => 'btn-default btn-sm',
                            'usebuttontag' => true,
                            'value'        => '<span class="icon icon-trash icon-lg text-danger" role="presentation" aria-hidden="true"></span><span class="sr-only">'. get_string('delete') . '</span>',
                            'confirm'      => get_string('confirmdeletemenuitem', 'admin'),
                        ),
                        'framework'  => array(
                            'type'         => 'hidden',
                            'value'        => $framework->id,
                        )
                    ),
                )
            );
        }
77
78
79
80
81
82
83
84
85
86
87
88
        $framework->config = pieform(
            array(
                'name' => 'framework_config_' . $framework->id,
                'successcallback' => 'framework_config_submit',
                'renderer' => 'div',
                'class' => 'form-inline pull-right framework',
                'elements' => array(
                    'submit' => array(
                        'type'         => 'button',
                        'class'        => 'btn-default btn-sm',
                        'usebuttontag' => true,
                        'value'        => '<span class="icon icon-cog icon-lg" role="presentation" aria-hidden="true"></span><span class="sr-only">'. get_string('delete') . '</span>',
89

90
91
92
93
94
95
96
97
                    ),
                    'framework'  => array(
                        'type'         => 'hidden',
                        'value'        => $framework->id,
                    )
                ),
            )
        );
98
99
    }
}
100
101
102
103
104

function framework_delete_submit(Pieform $form, $values) {
    global $SESSION;

    $framework = new Framework($values['framework']);
105
    if (!$framework->is_in_collections()) {
106
107
108
109
110
111
112
113
114
115
        $framework->delete();
        $SESSION->add_ok_msg(get_string('itemdeleted'));
    }
    else {
        $SESSION->add_error_msg(get_string('deletefailed', 'admin'));
    }

    redirect('/module/framework/frameworks.php');
}

116
117
118
119
function framework_config_submit(Pieform $form, $values) {
    redirect(get_config('wwwroot') . 'module/framework/frameworkmanager.php?id=' . $values['framework']);
}

120
121
122
123
124
$smarty = smarty();
setpageicon($smarty, 'icon-th');
$smarty->assign('frameworks', $frameworks);
$smarty->assign('wwwroot', get_config('wwwroot'));
$smarty->display('module:framework:frameworks.tpl');