mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-49470 mod_lesson: Triggering just 1 event
This commit is contained in:
parent
33d65f705b
commit
b7bfbfee2c
3 changed files with 82 additions and 58 deletions
|
@ -126,45 +126,7 @@ switch ($action) {
|
|||
case 'moveit':
|
||||
$after = (int)required_param('after', PARAM_INT); // target page
|
||||
|
||||
$pages = $lesson->load_all_pages();
|
||||
|
||||
if (!array_key_exists($pageid, $pages) || ($after!=0 && !array_key_exists($after, $pages))) {
|
||||
print_error('cannotfindpages', 'lesson', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
|
||||
}
|
||||
$pagetomove = clone($pages[$pageid]);
|
||||
unset($pages[$pageid]);
|
||||
|
||||
$pageids = array();
|
||||
if ($after === 0) {
|
||||
$pageids['p0'] = $pageid;
|
||||
}
|
||||
foreach ($pages as $page) {
|
||||
$pageids[] = $page->id;
|
||||
if ($page->id == $after) {
|
||||
$pageids[] = $pageid;
|
||||
}
|
||||
}
|
||||
|
||||
$pageidsref = $pageids;
|
||||
reset($pageidsref);
|
||||
$prev = 0;
|
||||
$next = next($pageidsref);
|
||||
foreach ($pageids as $pid) {
|
||||
if ($pid === $pageid) {
|
||||
$page = $pagetomove;
|
||||
} else {
|
||||
$page = $pages[$pid];
|
||||
}
|
||||
if ($page->prevpageid != $prev || $page->nextpageid != $next) {
|
||||
$page->move($next, $prev);
|
||||
}
|
||||
$prev = $page->id;
|
||||
$next = next($pageidsref);
|
||||
if (!$next) {
|
||||
$next = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$lesson->resort_pages($pageid, $after);
|
||||
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue