Robustness - avoid possible divide by zero problem MDL-7425

This commit is contained in:
moodler
2007-08-30 05:59:31 +00:00
parent 2712b7f2dc
commit 73083f1705
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -328,7 +328,11 @@
// be moved up and down beyond the paging border
if ($totalcount > $perpage) {
$atfirstpage = ($page == 0);
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));
if ($perpage > 0) {
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));
} else {
$atlastpage = true;
}
} else {
$atfirstpage = true;
$atlastpage = true;
+5 -1
View File
@@ -5334,7 +5334,11 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page
$pagenum = $page - 1;
$output .= '&nbsp;(<a href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('previous') .'</a>)&nbsp;';
}
$lastpage = ceil($totalcount / $perpage);
if ($perpage > 0) {
$lastpage = ceil($totalcount / $perpage);
} else {
$lastpage = 1;
}
if ($page > 15) {
$startpage = $page - 10;
$output .= '&nbsp;<a href="'. $baseurl . $pagevar .'=0">1</a>&nbsp;...';