-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdelete.php
63 lines (50 loc) · 1.9 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
59
60
61
62
63
<?php
/**
* Delete institution code.
* @copyright 2013 Bruno Sampaio
*/
require_once('../../config.php');
require_once('lib.php');
require_login();
$strinstitution = get_string('institution', 'local_institutions');
$strinstitutions = get_string('institutions', 'local_institutions');
$stradministration = get_string("administration");
$strdelete = get_string("delete");
$title = get_string('delete-institution', 'local_institutions');
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$id = required_param('id', PARAM_INT); // institution id
$PAGE->set_url('/local/institutions/delete.php', array('id' => $id));
$PAGE->set_context(context_system::instance());
$site = get_site();
if(!local_institutions_table_exists()) { //Table not exists
redirect(new moodle_url($CFG->wwwroot.'/local/institutions/error.php'));
}
else {
$PAGE->set_title("$site->shortname: $title");
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php/'));
$PAGE->navbar->add($strinstitutions, new moodle_url('/local/institutions/index.php'));
$PAGE->navbar->add($strdelete);
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
if (!$institution = $DB->get_record(INSTITUTIONS_TABLE, array("id"=>$id))) {
echo local_institutions_print_id_error();
}
else if (!local_institutions_can_edit() || !has_capability('moodle/site:config', $sitecontext)) {
echo local_institutions_print_permissions_error();
}
else {
if(local_institutions_delete($id)) {
echo html_writer::start_tag('div', array('class' => 'notifysuccess'));
echo get_string('success-delete', 'local_institutions');
echo html_writer::end_tag('div');
}
else {
echo html_writer::start_tag('div', array('class' => 'notifyproblem'));
echo get_string('error-delete', 'local_institutions');
echo html_writer::end_tag('div');
}
}
echo $OUTPUT->continue_button("index.php");
echo $OUTPUT->footer();
}