Revert "MDL-35260 Course formats may have settings, be enabled, disabled and uninstalled"
authorDan Poltawski <dan@moodle.com>
Mon, 5 Nov 2012 07:19:58 +0000 (15:19 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 5 Nov 2012 07:20:22 +0000 (15:20 +0800)
14 files changed:
admin/courseformats.php [deleted file]
admin/settings/courses.php
admin/settings/plugins.php
course/edit_form.php
course/format/formatlegacy.php
course/format/lib.php
course/format/upgrade.txt
course/lib.php
lang/en/admin.php
lang/en/error.php
lang/en/moodle.php
lib/adminlib.php
lib/moodlelib.php
lib/pluginlib.php

diff --git a/admin/courseformats.php b/admin/courseformats.php
deleted file mode 100644 (file)
index a8377de..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Allows the admin to enable, disable and uninstall course formats
- *
- * @package    core_admin
- * @copyright  2012 Marina Glancy
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once('../config.php');
-require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
-
-$action  = required_param('action', PARAM_ALPHANUMEXT);
-$formatname   = required_param('format', PARAM_PLUGIN);
-$confirm = optional_param('confirm', 0, PARAM_BOOL);
-
-$syscontext = context_system::instance();
-$PAGE->set_url('/admin/courseformats.php');
-$PAGE->set_context($syscontext);
-
-require_login();
-require_capability('moodle/site:config', $syscontext);
-require_sesskey();
-
-$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
-
-$allplugins = plugin_manager::instance()->get_plugins();
-$formatplugins = $allplugins['format'];
-$sortorder = array_flip(array_keys($formatplugins));
-
-if (!isset($formatplugins[$formatname])) {
-    print_error('courseformatnotfound', 'error', $return, $formatname);
-}
-
-switch ($action) {
-    case 'disable':
-        if ($formatplugins[$formatname]->is_enabled()) {
-            if (get_config('moodlecourse', 'format') === $formatname) {
-                print_error('cannotdisableformat', 'error', $return);
-            }
-            set_config('disabled', 1, 'format_'. $formatname);
-        }
-        break;
-    case 'enable':
-        if (!$formatplugins[$formatname]->is_enabled()) {
-            unset_config('disabled', 'format_'. $formatname);
-        }
-        break;
-    case 'up':
-        if ($sortorder[$formatname]) {
-            $currentindex = $sortorder[$formatname];
-            $seq = array_keys($formatplugins);
-            $seq[$currentindex] = $seq[$currentindex-1];
-            $seq[$currentindex-1] = $formatname;
-            set_config('format_plugins_sortorder', implode(',', $seq));
-        }
-        break;
-    case 'down':
-        if ($sortorder[$formatname] < count($sortorder)-1) {
-            $currentindex = $sortorder[$formatname];
-            $seq = array_keys($formatplugins);
-            $seq[$currentindex] = $seq[$currentindex+1];
-            $seq[$currentindex+1] = $formatname;
-            set_config('format_plugins_sortorder', implode(',', $seq));
-        }
-        break;
-    case 'uninstall':
-        echo $OUTPUT->header();
-        echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
-
-        $coursecount = $DB->count_records('course', array('format' => $formatname));
-        if ($coursecount) {
-            // Check that default format is set. It will be used to convert courses
-            // using this format
-            $defaultformat = get_config('moodlecourse', 'format');
-            $defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
-            if (!$defaultformat) {
-                echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
-                echo $OUTPUT->footer();
-                exit;
-            }
-        }
-
-        $format = $formatplugins[$formatname];
-        $deleteurl = $format->get_uninstall_url();
-        if (!$deleteurl) {
-            // somebody was trying to cheat and type non-existing link
-            echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
-            echo $OUTPUT->footer();
-            exit;
-        }
-
-        if (!$confirm) {
-            if ($coursecount) {
-                $message = get_string('formatuninstallwithcourses', 'admin',
-                        (object)array('count' => $coursecount, 'format' => $format->displayname,
-                            'defaultformat' => $defaultformat->displayname));
-            } else {
-                $message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
-            }
-            $deleteurl->param('confirm', 1);
-            echo $OUTPUT->confirm($message, $deleteurl, $return);
-        } else {
-            $a = new stdClass();
-            $a->plugin = $format->displayname;
-            $a->directory = $format->rootdir;
-            uninstall_plugin('format', $formatname);
-            echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
-            echo $OUTPUT->continue_button($return);
-        }
-
-        echo $OUTPUT->footer();
-        exit;
-}
-redirect($return);
index b68a10a..363bfb1 100644 (file)
@@ -15,10 +15,9 @@ if ($hassiteconfig
 /// NOTE: these settings must be applied after all other settings because they depend on them
     ///main course settings
     $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
-    require_once($CFG->dirroot.'/course/lib.php');
-    $courseformats = get_sorted_course_formats(true);
+    $courseformats = get_plugin_list('format');
     $formcourseformats = array();
-    foreach ($courseformats as $courseformat) {
+    foreach ($courseformats as $courseformat => $courseformatdir) {
         $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
     }
     $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
index bae770a..29d0665 100644 (file)
@@ -20,15 +20,6 @@ if ($hassiteconfig) {
     // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
     $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
 
-    // course formats
-    $ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
-    $temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
-    $temp->add(new admin_setting_manageformats());
-    $ADMIN->add('formatsettings', $temp);
-    foreach ($allplugins['format'] as $format) {
-        $format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
-    }
-
     // blocks
     $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
     $ADMIN->add('blocksettings', new admin_page_manageblocks());
index 34dbe12..70b709a 100644 (file)
@@ -113,20 +113,11 @@ class course_edit_form extends moodleform {
             $mform->hardFreeze('summary_editor');
         }
 
-        $courseformats = get_sorted_course_formats(true);
+        $courseformats = get_plugin_list('format');
         $formcourseformats = array();
-        foreach ($courseformats as $courseformat) {
+        foreach ($courseformats as $courseformat => $formatdir) {
             $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
         }
-        if (isset($course->format)) {
-            $course->format = course_get_format($course)->get_format(); // replace with default if not found
-            if (!in_array($course->format, $courseformats)) {
-                // this format is disabled. Still display it in the dropdown
-                $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle',
-                        get_string('pluginname', 'format_'.$course->format));
-            }
-        }
-
         $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
         $mform->addHelpButton('format', 'format');
         $mform->setDefault('format', $courseconfig->format);
index 41ead83..e6141a3 100644 (file)
@@ -329,21 +329,9 @@ class format_legacy extends format_base {
         if ($oldcourse !== null) {
             $data = (array)$data;
             $oldcourse = (array)$oldcourse;
-            $options = $this->course_format_options();
-            foreach ($options as $key => $unused) {
-                if (!array_key_exists($key, $data)) {
-                    if (array_key_exists($key, $oldcourse)) {
-                        $data[$key] = $oldcourse[$key];
-                    } else if ($key === 'numsections') {
-                        // If previous format does not have the field 'numsections' and this one does,
-                        // and $data['numsections'] is not set fill it with the maximum section number from the DB
-                        $maxsection = $DB->get_field_sql('SELECT max(section) from {course_sections}
-                            WHERE course = ?', array($this->courseid));
-                        if ($maxsection) {
-                            // If there are no sections, or just default 0-section, 'numsections' will be set to default
-                            $data['numsections'] = $maxsection;
-                        }
-                    }
+            foreach ($this->course_format_options() as $key => $unused) {
+                if (array_key_exists($key, $oldcourse) && !array_key_exists($key, $data)) {
+                    $data[$key] = $oldcourse[$key];
                 }
             }
         }
index 7268400..d0ad3d7 100644 (file)
@@ -97,21 +97,13 @@ abstract class format_base {
         if ($format === 'site') {
             return $format;
         }
-        $plugins = get_sorted_course_formats();
-        if (in_array($format, $plugins)) {
+        $plugins = get_plugin_list('format'); // TODO MDL-35260 filter only enabled
+        if (isset($plugins[$format])) {
             return $format;
         }
         // Else return default format
-        $defaultformat = get_config('moodlecourse', 'format');
-        if (!in_array($defaultformat, $plugins)) {
-            // when default format is not set correctly, use the first available format
-            $defaultformat = reset($plugins);
-        }
-        static $warningprinted = array();
-        if (empty($warningprinted[$format])) {
-            debugging('Format plugin format_'.$format.' is not found. Using default format_'.$defaultformat, DEBUG_DEVELOPER);
-            $warningprinted[$format] = true;
-        }
+        $defaultformat = reset($plugins); // TODO MDL-35260 get default format from config
+        debugging('Format plugin format_'.$format.' is not found or is not enabled. Using default format_'.$defaultformat, DEBUG_DEVELOPER);
         return $defaultformat;
     }
 
index f14a891..6beb68b 100644 (file)
@@ -12,7 +12,6 @@ format.
   functions callback_XXXX_request_key() are no longer used (where XXXX is the course format name)
 * functions get_generic_section_name(), get_all_sections(), add_mod_to_section(), get_all_mods()
   are deprecated. See their phpdocs in lib/deprecatedlib.php on how to replace them
-* Course formats may now have their settings.php file as the most of other plugin types
 
 === 2.3 ===
 
index 3322482..5f5535b 100644 (file)
@@ -4511,35 +4511,6 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
     return true;
 }
 
-/**
- * Returns the sorted list of available course formats, filtered by enabled if necessary
- *
- * @param bool $enabledonly return only formats that are enabled
- * @return array array of sorted format names
- */
-function get_sorted_course_formats($enabledonly = false) {
-    global $CFG;
-    $formats = get_plugin_list('format');
-
-    $sortorderstr = '';
-    if (isset($CFG->format_plugins_sortorder)) {
-        $sortorderstr = $CFG->format_plugins_sortorder;
-    }
-    $order = explode(',', $sortorderstr);
-    $order = array_merge(array_intersect($order, array_keys($formats)),
-                    array_diff(array_keys($formats), $order));
-    if ($sortorderstr !== join(',', $order)) {
-        set_config('format_plugins_sortorder', join(',', $order));
-    }
-    $sortedformats = array();
-    foreach ($order as $formatname) {
-        if (!$enabledonly || !get_config('format_'.$formatname, 'disabled')) {
-            $sortedformats[] = $formatname;
-        }
-    }
-    return $sortedformats;
-}
-
 /**
  * The URL to use for the specified course (with section)
  *
index 10a2fd2..2498fef 100644 (file)
@@ -95,7 +95,6 @@ $string['calendarexportsalt'] = 'Calendar export salt';
 $string['calendarsettings'] = 'Calendar';
 $string['calendar_weekend'] = 'Weekend days';
 $string['cannotdeletemodfilter'] = 'You cannot uninstall the \'{$a->filter}\' because it is part of the \'{$a->module}\' module.';
-$string['cannotuninstall'] = '{$a} can not be uninstalled.';
 $string['cfgwwwrootslashwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. You have included a \'/\' character at the end. Please remove it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
 $string['cfgwwwrootwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. It does not match the URL you are using to access this page. Please correct it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
 $string['clamfailureonupload'] = 'On clam AV failure';
@@ -417,7 +416,6 @@ $string['debugstringids_desc'] = 'This option is designed to help translators. W
 $string['debugvalidators'] = 'Show validator links';
 $string['defaultcity'] = 'Default city';
 $string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
-$string['defaultformatnotset'] = 'Error determining default course format. Please check site settings.';
 $string['defaulthomepage'] = 'Default home page for users';
 $string['defaultrequestcategory'] = 'Default category for course requests';
 $string['defaultsettinginfo'] = 'Default: {$a}';
@@ -534,9 +532,6 @@ $string['forceloginforprofileimage'] = 'Force users to login to view user pictur
 $string['forceloginforprofileimage_help'] = 'If enabled, users must login in order to view user profile pictures and the default user picture will be used in all notification emails.';
 $string['forceloginforprofiles'] = 'Force users to login for profiles';
 $string['forcetimezone'] = 'Force default timezone';
-$string['formatuninstallwithcourses'] = 'There are {$a->count} courses using {$a->format}. Their format will be changed to {$a->defaultformat} (default format for this site). Some format-specific data may be lost. Are you sure you want to proceed?';
-$string['formatuninstallconfirm'] = '{$a} will be uninstalled. No courses currently use it. Continue?';
-$string['formatuninstalled'] = 'All data associated with the format plugin \'{$a->plugin}\' has been deleted from the database.  To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}';
 $string['frontpage'] = 'Front page';
 $string['frontpagebackup'] = 'Front page backup';
 $string['frontpagedefaultrole'] = 'Default frontpage role';
@@ -645,8 +640,6 @@ $string['longtimewarning'] = '<b>Please note that this process can take a long t
 $string['maintenancemode'] = 'In maintenance mode';
 $string['maintfileopenerror'] = 'Error opening maintenance files!';
 $string['maintinprogress'] = 'Maintenance is in progress...';
-$string['manageformats'] = 'Manage course formats';
-$string['manageformatsgotosettings'] = 'Default format can be changed in {$a}';
 $string['managelang'] = 'Manage';
 $string['managelicenses'] = 'Manage licences';
 $string['manageqbehaviours'] = 'Manage question behaviours';
index e3b9f80..b9e5707 100644 (file)
@@ -65,7 +65,6 @@ $string['cannotdeletefile'] = 'Cannot delete this file';
 $string['cannotdeleterole'] = 'It cannot be deleted, because {$a}';
 $string['cannotdeleterolewithid'] = 'Could not delete role with ID {$a}';
 $string['cannotdeletethisrole'] = 'You cannot delete this role because it is used by the system, or because it is the last role with administrator capabilities.';
-$string['cannotdisableformat'] = 'You can not disable the default format';
 $string['cannotdownloadcomponents'] = 'Cannot download components';
 $string['cannotdownloadlanguageupdatelist'] = 'Cannot download list of language updates from download.moodle.org';
 $string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
@@ -543,4 +542,4 @@ $string['wwwrootslash'] = 'Detected incorrect $CFG->wwwroot in config.php, it mu
 $string['xmldberror'] = 'XMLDB error!';
 $string['alreadyloggedin'] = 'You are already logged in as {$a}, you need to log out before logging in as different user.';
 $string['youcannotdeletecategory'] = 'You cannot delete category \'{$a}\' because you can neither delete the contents, nor move them elsewhere.';
-$string['protected_cc_not_supported'] = 'Protected cartridges not supported.';
\ No newline at end of file
+$string['protected_cc_not_supported'] = 'Protected cartridges not supported.';
index e5c1893..118b434 100644 (file)
@@ -297,7 +297,7 @@ $string['coursecompletions'] = 'Course completions';
 $string['coursecreators'] = 'Course creator';
 $string['coursecreatorsdescription'] = 'Course creators can create new courses.';
 $string['coursedisplay'] = 'Course layout';
-$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages.';
+$string['coursedisplay_help'] = 'This setting determines whether the whole course is displayed on one page or split over several pages. The setting has no affect on certain course formats, such as SCORM format.';
 $string['coursedisplay_single'] = 'Show all sections on one page';
 $string['coursedisplay_multi'] = 'Show one section per page';
 $string['coursedeleted'] = 'Deleted course {$a}';
@@ -1802,7 +1802,6 @@ $string['whattocallzip'] = 'What do you want to call the zip file?';
 $string['whattodo'] = 'What to do';
 $string['windowclosing'] = 'This window should close automatically. If not, please close it now.';
 $string['withchosenfiles'] = 'With chosen files';
-$string['withdisablednote'] = '{$a} (disabled)';
 $string['withoutuserdata'] = 'without user data';
 $string['withselectedusers'] = 'With selected users...';
 $string['withselectedusers_help'] = '* Send message - For sending a message to one or more participants
index 06a9c98..0bf5649 100644 (file)
@@ -266,16 +266,6 @@ function uninstall_plugin($type, $name) {
             // Delete block
             $DB->delete_records('block', array('id'=>$block->id));
         }
-    } else if ($type === 'format') {
-        if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $name) {
-            $courses = $DB->get_records('course', array('format' => $name), 'id');
-            $data = (object)array('id' => null, 'format' => $defaultformat);
-            foreach ($courses as $record) {
-                $data->id = $record->id;
-                update_course($data);
-            }
-        }
-        $DB->delete_records('course_format_options', array('format' => $name));
     }
 
     // perform clean-up task common for all the plugin/subplugin types
@@ -5898,147 +5888,6 @@ class admin_setting_managelicenses extends admin_setting {
     }
 }
 
-/**
- * Course formats manager. Allows to enable/disable formats and jump to settings
- */
-class admin_setting_manageformats extends admin_setting {
-
-    /**
-     * Calls parent::__construct with specific arguments
-     */
-    public function __construct() {
-        $this->nosave = true;
-        parent::__construct('formatsui', new lang_string('manageformats', 'core_admin'), '', '');
-    }
-
-    /**
-     * Always returns true
-     *
-     * @return true
-     */
-    public function get_setting() {
-        return true;
-    }
-
-    /**
-     * Always returns true
-     *
-     * @return true
-     */
-    public function get_defaultsetting() {
-        return true;
-    }
-
-    /**
-     * Always returns '' and doesn't write anything
-     *
-     * @param mixed $data string or array, must not be NULL
-     * @return string Always returns ''
-     */
-    public function write_setting($data) {
-        // do not write any setting
-        return '';
-    }
-
-    /**
-     * Search to find if Query is related to format plugin
-     *
-     * @param string $query The string to search for
-     * @return bool true for related false for not
-     */
-    public function is_related($query) {
-        if (parent::is_related($query)) {
-            return true;
-        }
-        $allplugins = plugin_manager::instance()->get_plugins();
-        $formats = $allplugins['format'];
-        foreach ($formats as $format) {
-            if (strpos($format->component, $query) !== false ||
-                    strpos(textlib::strtolower($format->displayname), $query) !== false) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Return XHTML to display control
-     *
-     * @param mixed $data Unused
-     * @param string $query
-     * @return string highlight
-     */
-    public function output_html($data, $query='') {
-        global $CFG, $OUTPUT;
-        $return = '';
-        $return = $OUTPUT->heading(new lang_string('courseformats'), 3, 'main');
-        $return .= $OUTPUT->box_start('generalbox formatsui');
-
-        $allplugins = plugin_manager::instance()->get_plugins();
-        $formats = $allplugins['format'];
-
-        // display strings
-        $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default', 'delete'));
-        $txt->updown = "$txt->up/$txt->down";
-
-        $table = new html_table();
-        $table->head  = array($txt->name, $txt->enable, $txt->updown, $txt->delete, $txt->settings);
-        $table->align = array('left', 'center', 'center', 'center', 'center');
-        $table->width = '90%';
-        $table->attributes['class'] = 'manageformattable generaltable';
-        $table->data  = array();
-
-        $cnt = 0;
-        $defaultformat = get_config('moodlecourse', 'format');
-        $spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'icon'));
-        foreach ($formats as $format) {
-            $url = new moodle_url('/admin/courseformats.php',
-                    array('sesskey' => sesskey(), 'format' => $format->name));
-            $isdefault = '';
-            if ($format->is_enabled()) {
-                $strformatname = html_writer::tag('span', $format->displayname);
-                if ($defaultformat === $format->name) {
-                    $hideshow = $txt->default;
-                } else {
-                    $hideshow = html_writer::link($url->out(false, array('action' => 'disable')),
-                            $OUTPUT->pix_icon('i/hide', $txt->disable, 'moodle', array('class' => 'icon')));
-                }
-            } else {
-                $strformatname = html_writer::tag('span', $format->displayname, array('class' => 'dimmed_text'));
-                $hideshow = html_writer::link($url->out(false, array('action' => 'enable')),
-                    $OUTPUT->pix_icon('i/show', $txt->enable, 'moodle', array('class' => 'icon')));
-            }
-            $updown = '';
-            if ($cnt) {
-                $updown .= html_writer::link($url->out(false, array('action' => 'up')),
-                    $OUTPUT->pix_icon('t/up', $txt->up, 'moodle')). '&nbsp;';
-            } else {
-                $updown .= $spacer;
-            }
-            if ($cnt < count($formats) - 1) {
-                $updown .= '&nbsp;'.html_writer::link($url->out(false, array('action' => 'down')),
-                    $OUTPUT->pix_icon('t/down', $txt->down, 'moodle'));
-            } else {
-                $updown .= $spacer;
-            }
-            $cnt++;
-            $settings = '';
-            if ($format->get_settings_url()) {
-                $settings = html_writer::link($format->get_settings_url(), $txt->settings);
-            }
-            $uninstall = '';
-            if ($defaultformat !== $format->name) {
-                $uninstall = html_writer::link($format->get_uninstall_url(), $txt->delete);
-            }
-            $table->data[] =array($strformatname, $hideshow, $updown, $uninstall, $settings);
-        }
-        $return .= html_writer::table($table);
-        $link = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'coursesettings')), new lang_string('coursesettings'));
-        $return .= html_writer::tag('p', get_string('manageformatsgotosettings', 'admin', $link));
-        $return .= $OUTPUT->box_end();
-        return highlight($query, $return);
-    }
-}
 
 /**
  * Special class for filter administration.
index 52b3118..4f8914f 100644 (file)
@@ -4572,8 +4572,7 @@ function delete_course($courseorid, $showfeedback = true) {
     // which should know about this updated property, as this event is meant to pass the full course record
     $course->timemodified = time();
 
-    $DB->delete_records("course", array("id" => $courseid));
-    $DB->delete_records("course_format_options", array("courseid" => $courseid));
+    $DB->delete_records("course", array("id"=>$courseid));
 
     //trigger events
     $course->context = $context; // you can not fetch context in the event because it was already deleted
index 1d4131e..cb35aca 100644 (file)
@@ -2841,61 +2841,3 @@ class plugininfo_webservice extends plugininfo_base {
                 array('sesskey' => sesskey(), 'action' => 'uninstall', 'webservice' => $this->name));
     }
 }
-
-/**
- * Class for course formats
- */
-class plugininfo_format extends plugininfo_base {
-
-    /**
-     * Gathers and returns the information about all plugins of the given type
-     *
-     * @param string $type the name of the plugintype, eg. mod, auth or workshopform
-     * @param string $typerootdir full path to the location of the plugin dir
-     * @param string $typeclass the name of the actually called class
-     * @return array of plugintype classes, indexed by the plugin name
-     */
-    public static function get_plugins($type, $typerootdir, $typeclass) {
-        global $CFG;
-        $formats = parent::get_plugins($type, $typerootdir, $typeclass);
-        require_once($CFG->dirroot.'/course/lib.php');
-        $order = get_sorted_course_formats();
-        $sortedformats = array();
-        foreach ($order as $formatname) {
-            $sortedformats[$formatname] = $formats[$formatname];
-        }
-        return $sortedformats;
-    }
-
-    public function get_settings_section_name() {
-        return 'formatsetting' . $this->name;
-    }
-
-    public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
-        global $CFG, $USER, $DB, $OUTPUT, $PAGE; // in case settings.php wants to refer to them
-        $ADMIN = $adminroot; // also may be used in settings.php
-        $section = $this->get_settings_section_name();
-
-        $settings = null;
-        if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
-            $settings = new admin_settingpage($section, $this->displayname,
-                    'moodle/site:config', $this->is_enabled() === false);
-            include($this->full_path('settings.php')); // this may also set $settings to null
-        }
-        if ($settings) {
-            $ADMIN->add($parentnodename, $settings);
-        }
-    }
-
-    public function is_enabled() {
-        return !get_config($this->component, 'disabled');
-    }
-
-    public function get_uninstall_url() {
-        if ($this->name !== get_config('moodlecourse', 'format') && $this->name !== 'site') {
-            return new moodle_url('/admin/courseformats.php',
-                    array('sesskey' => sesskey(), 'action' => 'uninstall', 'format' => $this->name));
-        }
-        return parent::get_uninstall_url();
-    }
-}