-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.php
58 lines (49 loc) · 1.89 KB
/
delete.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
<?php
/**
*
* @package mahara
* @subpackage artefact-learning
* @author Gregor Anzelj
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2013-2022 Gregor Anzelj <[email protected]>
*
*/
define('INTERNAL', true);
define('MENUITEM', 'create/learning');
require_once(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
safe_require('artefact','learning');
define('TITLE', get_string('deletelearning','artefact.learning'));
$id = param_integer('id');
$todelete = new ArtefactTypeLearning($id);
if (!$USER->can_edit_artefact($todelete)) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$deleteform = array(
'name' => 'deletelearningform',
'plugintype' => 'artefact',
'pluginname' => 'learning',
'renderer' => 'div',
'elements' => array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('deletelearning','artefact.learning'), get_string('cancel')),
'goto' => get_config('wwwroot') . '/artefact/learning/index.php',
),
)
);
$form = pieform($deleteform);
$smarty = smarty();
setpageicon($smarty, 'icon-graduation-cap');
$smarty->assign('form', $form);
$smarty->assign('PAGEHEADING', get_string('deletelearning','artefact.learning'));
$smarty->assign('subheading', get_string('deletethislearning','artefact.learning',$todelete->get('title')));
$smarty->assign('message', get_string('deletelearningconfirm','artefact.learning'));
$smarty->display('artefact:learning:delete.tpl');
// calls this function first so that we can get the artefact and call delete on it
function deletelearningform_submit(Pieform $form, $values) {
global $SESSION, $todelete;
$todelete->delete();
$SESSION->add_ok_msg(get_string('learningdeletedsuccessfully', 'artefact.learning'));
redirect('/artefact/learning/index.php');
}