Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/course/editsection.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 require_once("../config.php");
00027 require_once("lib.php");
00028 require_once($CFG->libdir.'/filelib.php');
00029 require_once('editsection_form.php');
00030 
00031 $id = required_param('id',PARAM_INT);    // Week/topic ID
00032 
00033 $PAGE->set_url('/course/editsection.php', array('id'=>$id));
00034 
00035 $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
00036 $course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
00037 
00038 require_login($course);
00039 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00040 require_capability('moodle/course:update', $context);
00041 
00042 $editoroptions = array('context'=>$context ,'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
00043 $section = file_prepare_standard_editor($section, 'summary', $editoroptions, $context, 'course', 'section', $section->id);
00044 $section->usedefaultname = (is_null($section->name));
00045 $mform = new editsection_form(null, array('course'=>$course, 'editoroptions'=>$editoroptions));
00046 $mform->set_data($section); // set current value
00047 
00049 if ($mform->is_cancelled()){
00050     redirect($CFG->wwwroot.'/course/view.php?id='.$course->id);
00051 
00052 } else if ($data = $mform->get_data()) {
00053     if (empty($data->usedefaultname)) {
00054         $section->name = $data->name;
00055     } else {
00056         $section->name = null;
00057     }
00058     $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'section', $section->id);
00059     $section->summary = $data->summary;
00060     $section->summaryformat = $data->summaryformat;
00061     $DB->update_record('course_sections', $section);
00062     add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
00063     $PAGE->navigation->clear_cache();
00064     redirect("view.php?id=$course->id");
00065 }
00066 
00067 $sectionname  = get_section_name($course, $section);
00068 $stredit      = get_string('edita', '', " $sectionname");
00069 $strsummaryof = get_string('summaryof', '', " $sectionname");
00070 
00071 $PAGE->set_title($stredit);
00072 $PAGE->set_heading($course->fullname);
00073 $PAGE->navbar->add($stredit);
00074 echo $OUTPUT->header();
00075 
00076 echo $OUTPUT->heading($strsummaryof);
00077 
00078 $mform->display();
00079 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations