Improved category and course list display on front page- see bug Bug #5965 - Frontpage Category List also showing courses; new Combo List(categories + courses), fixed categories list and separate settings for not logged in / logged in users; merged from MOODLE_16_STABLE

This commit is contained in:
skodak 2006-07-19 12:10:07 +00:00
parent fa145ae1af
commit 6f24e48e1f
6 changed files with 76 additions and 25 deletions

View file

@ -33,26 +33,46 @@
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<?php
$coursecount = (count_records('course') <= FRONTPAGECOURSELIMIT);
$options = array(FRONTPAGENEWS => get_string("frontpagenews"),
FRONTPAGECOURSELIST => get_string("frontpagecourselist"),
FRONTPAGECATEGORYNAMES => get_string("frontpagecategorynames"),
FRONTPAGECATEGORYCOMBO => get_string("frontpagecategorycombo"),
);
$values = array(get_string('hide'), get_string('order1', 'admin'), get_string('order2', 'admin'));
$values = array(get_string('hide'), get_string('order1', 'admin'), get_string('order2', 'admin'), get_string('order3', 'admin'), get_string('order4', 'admin'));
$seq = array_flip(explode(',',$form->frontpage));
foreach ($seq as $k => $s) {
$seq[$k]++;
}
if (count_records("course") > 200) {
unset($options[FRONTPAGECOURSELIST]);
if (isset($seq[FRONTPAGECOURSELIST])) {
$form->frontpage = 2;
}
} else {
$values[] = get_string('order3', 'admin');
if (!$coursecount and isset($seq[FRONTPAGECOURSELIST])) {
unset($seq[FRONTPAGECOURSELIST]); //disable course list option when too many course present
}
foreach ($options as $key => $option) {
$disabled = (!$coursecount and ($key == FRONTPAGECOURSELIST));
echo "<td>$option<br />";
choose_from_menu ($values, "frontpage[$key]", isset($seq[$key])?$seq[$key]:0, '', '', 0, false, $disabled);
echo '</td>';
}
?>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td align="right"><?php print_string("frontpageformatloggedin") ?>:</td>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<?php
$seq = array_flip(explode(',',$form->frontpageloggedin));
foreach ($seq as $k => $s) {
$seq[$k]++;
}
foreach ($options as $key => $option) {
echo "<td>$option<br />";
choose_from_menu ($values, "frontpage[$key]", isset($seq[$key])?$seq[$key]:0, "");
choose_from_menu ($values, "frontpageloggedin[$key]", isset($seq[$key])?$seq[$key]:0, '');
echo '</td>';
}
?>

View file

@ -37,6 +37,13 @@
$form->numsections = 1; // Force the topic display for this format
}
$form->frontpageloggedin = array_flip($form->frontpageloggedin);
unset($form->frontpageloggedin[0]);
$form->frontpageloggedin = array_flip($form->frontpageloggedin);
asort($form->frontpageloggedin);
$form->frontpageloggedin = implode(',',array_flip($form->frontpageloggedin));
set_config("frontpageloggedin", $form->frontpageloggedin);
$form->timemodified = time();
if ($form->id) {
@ -98,12 +105,18 @@
if (isset($CFG->frontpage)) {
$form->frontpage = $CFG->frontpage;
} else {
$form->frontpage = FRONTPAGECOURSELIST; // Show course list by default
set_config("frontpage", $form->frontpage);
}
if (isset($CFG->frontpageloggedin)) {
$form->frontpageloggedin = $CFG->frontpageloggedin;
} else {
$form->frontpageloggedin = $form->frontpage;
set_config("frontpageloggedin", $form->frontpageloggedin);
}
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$strsitesettings = get_string("sitesettings");