-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_migrationup.php
61 lines (53 loc) · 2.54 KB
/
block_migrationup.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
<?php
class block_migrationup extends block_base {
public function init() {
$this->title = get_string('migrationup', 'block_migrationup');
}
public function get_content() {
global $USER, $CFG, $DB, $OUTPUT, $COURSE;
if ($this->content !== null) {
return $this->content;
}
/*
* get current status of block
* request = no DB record
* migration progress = DB record but migrated=0
* completed = DB record and migrated=1
*
*/
$result = $DB->get_records('block_migrationup', array('newcourseid' => $COURSE->id));
$this->content = new stdClass;
if (!$result) {
// get necessary strings for buttons and urls
$strsubmit = get_string('submit', 'block_migrationup');
$strhelp = get_string('help', 'block_migrationup');
$strurl = get_string('url');
$this->content->text .= get_string('block_start1', 'block_migrationup');
$this->content->text .= $OUTPUT->help_icon('course', 'block_migrationup');
$this->content->text .= get_string('block_start2', 'block_migrationup');
$url = new moodle_url($CFG->wwwroot.'/blocks/migrationup/migration.php', array('blockid' => $this->instance->id, 'courseid' => $COURSE->id));
$this->content->text .= html_writer::link($url, get_string('block_link_form', 'block_migrationup'), array('class' => 'migrationlink'));
$this->content->footer .= $strhelp;
} else {
$migrated = $DB->get_records('block_migrationup', array('newcourseid' => $COURSE->id, 'migrated' => 1));
if(!$migrated) {
$strhelp = get_string('help', 'block_migrationup');
$strprogress = get_string('progress', 'block_migrationup');
$this->content->text .= $strprogress.'<br />'.$strhelp;
if (has_capability('block/migrationup:finishmigration', context_course::instance($COURSE->id))) {
$pageparam = array('courseid' => $COURSE->id, 'blockid' => $this->instance->id, 'migrated' => 'yes');
$rdyurl = new moodle_url('/blocks/migrationup/migration.php', $pageparam);
$rdypicurl = new moodle_url('/blocks/migrationup/pix/accept.png');
$this->content->text .= html_writer::link($rdyurl, html_writer::tag('img', '', array('src' => $rdypicurl, 'alt' => get_string('edit'))));
}
} else {
$strfinished = get_string('finished', 'block_migrationup');
$this->content->text .= $strfinished;
}
}
return $this->content;
}
function applicable_formats() {
return array('site' => true, 'course-view' => true, 'my' => false);
}
}