Example #1
0
                 }
             } else {
                 $subtext = get_string('subscribe', 'forum');
             }
             print_heading_block($newsforum->name);
             echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
         } else {
             print_heading_block($newsforum->name);
         }
         forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
     }
     break;
 case FRONTPAGECOURSELIST:
     if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
         print_heading_block(get_string('mycourses'));
         print_my_moodle();
     } else {
         if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) {
             // admin should not see list of courses when there are too many of them
             print_heading_block(get_string('availablecourses'));
             print_courses(0);
         }
     }
     break;
 case FRONTPAGECATEGORYNAMES:
     print_heading_block(get_string('categories'));
     print_box_start('generalbox categorybox');
     print_whole_category_list(NULL, NULL, NULL, -1, false);
     print_box_end();
     print_course_search('', false, 'short');
     break;
/**
 * Called from {@link page_print_position()} and it is
 * supposed to print the front page settings in the
 * center column for the site course and only for
 * the default page (EG: the landing page).
 *
 * @return boolean
 **/
function page_frontpage_settings()
{
    global $CFG, $SESSION, $SITE, $PAGE, $COURSE;
    // Cheap check first - course ID
    if ($COURSE->id != SITEID) {
        return false;
    }
    // More expensive check - make sure we are viewing default page
    $default = page_get_default_page();
    $current = $PAGE->get_formatpage();
    if (empty($default->id) or empty($current->id) or $default->id != $current->id) {
        return false;
    }
    $editing = $PAGE->user_is_editing();
    /// START COPY/PASTE FROM INDEX.PHP
    print_container_start();
    /// Print Section
    if ($SITE->numsections > 0) {
        if (!($section = get_record('course_sections', 'course', $SITE->id, 'section', 1))) {
            delete_records('course_sections', 'course', $SITE->id, 'section', 1);
            // Just in case
            $section->course = $SITE->id;
            $section->section = 1;
            $section->summary = '';
            $section->sequence = '';
            $section->visible = 1;
            $section->id = insert_record('course_sections', $section);
        }
        if (!empty($section->sequence) or !empty($section->summary) or $editing) {
            print_box_start('generalbox sitetopic');
            /// If currently moving a file then show the current clipboard
            if (ismoving($SITE->id)) {
                $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
                echo '<p><font size="2">';
                echo "{$stractivityclipboard}&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true&amp;sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)';
                echo '</font></p>';
            }
            $options = NULL;
            $options->noclean = true;
            echo format_text($section->summary, FORMAT_HTML, $options);
            if ($editing) {
                $streditsummary = get_string('editsummary');
                echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />";
            }
            get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
            print_section($SITE, $section, $mods, $modnamesused, true);
            if ($editing) {
                print_section_add_menus($SITE, $section->section, $modnames);
            }
            print_box_end();
        }
    }
    if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
        $frontpagelayout = $CFG->frontpageloggedin;
    } else {
        $frontpagelayout = $CFG->frontpage;
    }
    foreach (explode(',', $frontpagelayout) as $v) {
        switch ($v) {
            /// Display the main part of the front page.
            case FRONTPAGENEWS:
                if ($SITE->newsitems) {
                    // Print forums only when needed
                    require_once $CFG->dirroot . '/mod/forum/lib.php';
                    if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
                        error('Could not find or create a main news forum for the site');
                    }
                    if (!empty($USER->id)) {
                        $SESSION->fromdiscussion = $CFG->wwwroot;
                        if (forum_is_subscribed($USER->id, $newsforum)) {
                            $subtext = get_string('unsubscribe', 'forum');
                        } else {
                            $subtext = get_string('subscribe', 'forum');
                        }
                        print_heading_block($newsforum->name);
                        echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
                    } else {
                        print_heading_block($newsforum->name);
                    }
                    forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
                }
                break;
            case FRONTPAGECOURSELIST:
                if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
                    print_heading_block(get_string('mycourses'));
                    print_my_moodle();
                } else {
                    if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) {
                        // admin should not see list of courses when there are too many of them
                        print_heading_block(get_string('availablecourses'));
                        print_courses(0);
                    }
                }
                break;
            case FRONTPAGECATEGORYNAMES:
                print_heading_block(get_string('categories'));
                print_box_start('generalbox categorybox');
                print_whole_category_list(NULL, NULL, NULL, -1, false);
                print_box_end();
                print_course_search('', false, 'short');
                break;
            case FRONTPAGECATEGORYCOMBO:
                print_heading_block(get_string('categories'));
                print_box_start('generalbox categorybox');
                print_whole_category_list(NULL, NULL, NULL, -1, true);
                print_box_end();
                print_course_search('', false, 'short');
                break;
            case FRONTPAGETOPICONLY:
                // Do nothing!!  :-)
                break;
        }
        // echo '<br />';  REMOVED FOR THE FORMAT
    }
    print_container_end();
    /// END COPY/PASTE FROM INDEX.PHP
    return true;
}