Save a db call by using SITE

This commit is contained in:
moodler 2005-02-12 15:07:25 +00:00
parent 2356cd43fe
commit 78ba4d0697

View File

@ -20,7 +20,7 @@
$blockaction = optional_param('blockaction'); $blockaction = optional_param('blockaction');
if (! $site = get_site()) { if (empty($SITE)) {
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php'); redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
} }
@ -42,7 +42,7 @@
} }
$loginstring = "<font size=\"2\"><a href=\"$wwwroot/login/index.php\">".get_string('login').'</a></font>'; $loginstring = "<font size=\"2\"><a href=\"$wwwroot/login/index.php\">".get_string('login').'</a></font>';
} else { } else {
$loginstring = '<font size="1">'. user_login_string($site) .'</font>'; $loginstring = '<font size="1">'. user_login_string($SITE) .'</font>';
add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID); add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
} }
@ -68,8 +68,8 @@
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH); $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH); $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
print_header(strip_tags($site->fullname), $site->fullname, 'home', '', print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home', '',
'<meta name="description" content="'. s(strip_tags($site->summary)) .'" />', '<meta name="description" content="'. s(strip_tags($SITE->summary)) .'" />',
true, '', $loginstring . '<br />' . $langmenu); true, '', $loginstring . '<br />' . $langmenu);
?> ?>
@ -89,11 +89,11 @@
/// Print Section /// Print Section
if ($site->numsections > 0) { if ($SITE->numsections > 0) {
print_simple_box_start('center', '100%', '', 5, 'sitetopic'); print_simple_box_start('center', '100%', '', 5, 'sitetopic');
/// If currently moving a file then show the current clipboard /// If currently moving a file then show the current clipboard
if (ismoving($site->id)) { if (ismoving($SITE->id)) {
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname))); $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
echo '<p><font size="2">'; echo '<p><font size="2">';
echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true\">". get_string('cancel') .'</a>)'; echo "$stractivityclipboard&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true\">". get_string('cancel') .'</a>)';
@ -101,9 +101,9 @@
} }
if (!$section = get_record('course_sections', 'course', $site->id, 'section', 1)) { if (!$section = get_record('course_sections', 'course', $SITE->id, 'section', 1)) {
delete_records('course_sections', 'course', $site->id, 'section', 1); // Just in case delete_records('course_sections', 'course', $SITE->id, 'section', 1); // Just in case
$section->course = $site->id; $section->course = $SITE->id;
$section->section = 1; $section->section = 1;
$section->summary = ''; $section->summary = '';
$section->visible = 1; $section->visible = 1;
@ -119,11 +119,11 @@
" height=\"11\" width=\"11\" border=\"0\" alt=\"$streditsummary\" /></a><br /><br />"; " height=\"11\" width=\"11\" border=\"0\" alt=\"$streditsummary\" /></a><br /><br />";
} }
get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused); get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_section($site, $section, $mods, $modnamesused, true); print_section($SITE, $section, $mods, $modnamesused, true);
if ($editing) { if ($editing) {
print_section_add_menus($site, $section->section, $modnames); print_section_add_menus($SITE, $section->section, $modnames);
} }
print_simple_box_end(); print_simple_box_end();
print_spacer(10); print_spacer(10);
@ -131,7 +131,7 @@
switch ($CFG->frontpage) { /// Display the main part of the front page. switch ($CFG->frontpage) { /// Display the main part of the front page.
case FRONTPAGENEWS: case FRONTPAGENEWS:
if (! $newsforum = forum_get_course_forum($site->id, 'news')) { if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
error('Could not find or create a main news forum for the site'); error('Could not find or create a main news forum for the site');
} }
@ -151,10 +151,10 @@
$headertext = $newsforum->name; $headertext = $newsforum->name;
} }
if ($site->newsitems) { //print forums only when needed if ($SITE->newsitems) { //print forums only when needed
print_heading_block($headertext); print_heading_block($headertext);
print_spacer(8,1); print_spacer(8,1);
forum_print_latest_discussions($newsforum->id, $site->newsitems); forum_print_latest_discussions($newsforum->id, $SITE->newsitems);
} }
break; break;
@ -193,7 +193,7 @@
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing || isadmin()) { if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing || isadmin()) {
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">'; echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
if (isadmin()) { if (isadmin()) {
echo '<div align="center">'.update_course_icon($site->id).'</div>'; echo '<div align="center">'.update_course_icon($SITE->id).'</div>';
echo '<br />'; echo '<br />';
} }
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]); blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);