当前位置: 首页>>代码示例>>PHP>>正文


PHP blocks_repopulate_page函数代码示例

本文整理汇总了PHP中blocks_repopulate_page函数的典型用法代码示例。如果您正苦于以下问题:PHP blocks_repopulate_page函数的具体用法?PHP blocks_repopulate_page怎么用?PHP blocks_repopulate_page使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了blocks_repopulate_page函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fastcreatecourse_ex

function fastcreatecourse_ex($hcategory, $course, $header, $validate)
{
    if (!is_array($course) || !is_array($header) || !is_array($validate)) {
        return -2;
    }
    global $CFG;
    // declaring as static prevents object pointers being continually created and destroyed, saving time in theory
    static $courseid;
    static $mysqlresource1;
    static $mysqlresource2;
    static $mysqlresource3;
    static $mysqlresource4;
    static $dcomma;
    // Creating SQL for composite fields
    static $dtopics;
    static $dtopicno;
    static $dtopicname;
    static $dteachers;
    static $dteacherno;
    static $dteacherdata;
    // Dynamically Create Query Based on number of headings excluding Teacher[1,2,...] and Topic[1,2,...]
    // Added for increased functionality with newer versions of moodle
    // Author: Ashley Gooding & Cole Spicer
    static $tempstring;
    $query = 'INSERT INTO `' . $CFG->prefix . 'course` (`category`,';
    foreach ($header as $i => $col) {
        $col = strtolower($col);
        if (preg_match(TOPIC_FIELD, $col) || preg_match(TEACHER_FIELD, $col) || $col == 'category' || $col == 'template') {
            continue;
        }
        $query = $query . '`' . $col . '`,';
    }
    $query = $query . '`modinfo`) VALUES (' . $hcategory . ',';
    foreach ($header as $i => $col) {
        $col = strtolower($col);
        if (preg_match(TOPIC_FIELD, $col) || preg_match(TEACHER_FIELD, $col) || $col == 'category' || $col == 'template') {
            continue;
        }
        if ($col == 'expirythreshold') {
            $course[$col] = $course[$col] * 86400;
        }
        $temparray = explode(',', $validate[$col][1]);
        if ($validate[$col][0] == 1 || $validate[$col][0] == 4 && !checkisint($temparray[0])) {
            //String or Domain with strings
            $query = $query . '' . mystr($course[$col]) . ', ';
        } else {
            $query = $query . '' . $course[$col] . ', ';
        }
    }
    $query = $query . ' \'\');';
    // End Dynamic Query
    if (!($mysqlresource2 = mysql_query($query))) {
        return -2;
    }
    $courseid = mysql_insert_id();
    if (isset($course['template']) && $course['template'] != '') {
        if (!($mysqlresource6 = mysql_query('SELECT `id` FROM `' . $CFG->prefix . 'course` WHERE `shortname`=\'' . $course['template'] . '\';'))) {
            return -7;
        }
        if (!mysql_num_rows($mysqlresource6)) {
            return -7;
        }
        $row = mysql_fetch_row($mysqlresource6);
        $id = $row[0];
        if (!($mysqlresource7 = mysql_query(' INSERT INTO `' . $CFG->prefix . 'block_instance` ( `blockid` , `pageid` , `pagetype` , `position` , `weight` , `visible` , `configdata` ) SELECT `blockid` , ' . $courseid . ', `pagetype` , `position` , `weight` , `visible` , `configdata` FROM `' . $CFG->prefix . 'block_instance` WHERE `pageid` = ' . $id . ';'))) {
            return -8;
        }
    } else {
        $page = page_create_object(PAGE_COURSE_VIEW, $courseid);
        blocks_repopulate_page($page);
        // Setup blocks
    }
    $dtopics = '';
    // String concatenation for topic INSERT
    $dcomma = false;
    // Should we add a comma before the next item?
    if (isset($course['topics'])) {
        // Any topic headings specified ?
        foreach ($course['topics'] as $dtopicno => $dtopicname) {
            if ($dtopicno <= $course['numsections']) {
                // Avoid overflowing topic headings
                if ($dcomma == true) {
                    $dtopics .= ',';
                } else {
                    $dcomma = true;
                }
                $dtopics .= '(' . $courseid . ',' . mystr($dtopicno) . ',' . mystr($dtopicname) . ',\'\',\'1\')';
            }
        }
    }
    if (!isset($course['topics'][0])) {
        // Ensure at least default topic section exists
        if ($dcomma == true) {
            $dtopics .= ',';
        } else {
            $dcomma = true;
        }
        $dtopics .= '(\'' . $courseid . '\',\'0\',\'\',\'\',\'1\');';
    } else {
        $dtopics .= ';';
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:uploadcourse.php

示例2: upgrade_blocks_plugins


//.........这里部分代码省略.........
                        notify('Upgrading block ' . $block->name . ' from ' . $currblock->version . ' to ' . $block->version . ' FAILED!');
                    }
                    echo '<hr />';
                } else {
                    upgrade_log_start();
                    error('Version mismatch: block ' . $block->name . ' can\'t downgrade ' . $currblock->version . ' -> ' . $block->version . '!');
                }
            }
        } else {
            // block not installed yet, so install it
            // If it allows multiples, start with it enabled
            if ($blockobj->instance_allow_multiple()) {
                $block->multiple = 1;
            }
            // Set the block cron on install
            $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
            // [pj] Normally this would be inline in the if, but we need to
            //      check for NULL (necessary for 4.0.5 <= PHP < 4.2.0)
            $conflictblock = array_search($blocktitle, $blocktitles);
            if ($conflictblock !== false && $conflictblock !== NULL) {
                // Duplicate block titles are not allowed, they confuse people
                // AND PHP's associative arrays ;)
                error('<strong>Naming conflict</strong>: block <strong>' . $block->name . '</strong> has the same title with an existing block, <strong>' . $conflictblock . '</strong>!');
            }
            if (empty($updated_blocks)) {
                $strblocksetup = get_string('blocksetup');
                print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
            }
            $updated_blocks = true;
            upgrade_log_start();
            print_heading($block->name);
            $db->debug = true;
            @set_time_limit(0);
            // To allow slow databases to complete the long SQL
            /// Both old .sql files and new install.xml are supported
            /// but we priorize install.xml (XMLDB) if present
            $status = false;
            if (file_exists($fullblock . '/db/install.xml')) {
                $status = install_from_xmldb_file($fullblock . '/db/install.xml');
                //New method
            } else {
                if (file_exists($fullblock . '/db/' . $CFG->dbtype . '.sql')) {
                    $status = modify_database($fullblock . '/db/' . $CFG->dbtype . '.sql');
                    //Old method
                } else {
                    $status = true;
                }
            }
            $db->debug = false;
            if ($status) {
                if ($block->id = insert_record('block', $block)) {
                    $blockobj->after_install();
                    $component = 'block/' . $block->name;
                    if (!update_capabilities($component)) {
                        notify('Could not set up ' . $block->name . ' capabilities!');
                    }
                    events_update_definition($component);
                    notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
                    echo '<hr />';
                } else {
                    error($block->name . ' block could not be added to the block list!');
                }
            } else {
                error('Block ' . $block->name . ' tables could NOT be set up successfully!');
            }
        }
        $blocktitles[$block->name] = $blocktitle;
    }
    if (!empty($notices)) {
        upgrade_log_start();
        foreach ($notices as $notice) {
            notify($notice);
        }
    }
    // Finally, if we are in the first_install of BLOCKS (this means that we are
    // upgrading from Moodle < 1.3), put blocks in all existing courses.
    if ($first_install) {
        upgrade_log_start();
        //Iterate over each course
        if ($courses = get_records('course')) {
            foreach ($courses as $course) {
                $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                blocks_repopulate_page($page);
            }
        }
    }
    if (!empty($CFG->siteblocksadded)) {
        /// This is a once-off hack to make a proper upgrade
        upgrade_log_start();
        $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
        blocks_repopulate_page($page);
        delete_records('config', 'name', 'siteblocksadded');
    }
    upgrade_log_finish();
    if (!empty($updated_blocks)) {
        print_continue($continueto);
        print_footer('none');
        die;
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:blocklib.php

示例3: restore_create_blocks

function restore_create_blocks($restore, $backup_block_format, $blockinfo, $xml_file)
{
    global $CFG;
    $status = true;
    blocks_delete_all_on_page(PAGE_COURSE_VIEW, $restore->course_id);
    if (empty($backup_block_format)) {
        // This is a backup from Moodle < 1.5
        if (empty($blockinfo)) {
            // Looks like it's from Moodle < 1.3. Let's give the course default blocks...
            $newpage = page_create_object(PAGE_COURSE_VIEW, $restore->course_id);
            blocks_repopulate_page($newpage);
        } else {
            // We just have a blockinfo field, this is a legacy 1.4 or 1.3 backup
            $blockrecords = get_records_select('block', '', '', 'name, id');
            $temp_blocks_l = array();
            $temp_blocks_r = array();
            @(list($temp_blocks_l, $temp_blocks_r) = explode(':', $blockinfo));
            $temp_blocks = array(BLOCK_POS_LEFT => explode(',', $temp_blocks_l), BLOCK_POS_RIGHT => explode(',', $temp_blocks_r));
            foreach ($temp_blocks as $blockposition => $blocks) {
                $blockweight = 0;
                foreach ($blocks as $blockname) {
                    if (!isset($blockrecords[$blockname])) {
                        // We don't know anything about this block!
                        continue;
                    }
                    $blockinstance = new stdClass();
                    // Remove any - prefix before doing the name-to-id mapping
                    if (substr($blockname, 0, 1) == '-') {
                        $blockname = substr($blockname, 1);
                        $blockinstance->visible = 0;
                    } else {
                        $blockinstance->visible = 1;
                    }
                    $blockinstance->blockid = $blockrecords[$blockname]->id;
                    $blockinstance->pageid = $restore->course_id;
                    $blockinstance->pagetype = PAGE_COURSE_VIEW;
                    $blockinstance->position = $blockposition;
                    $blockinstance->weight = $blockweight;
                    if (!($status = insert_record('block_instance', $blockinstance))) {
                        $status = false;
                    }
                    ++$blockweight;
                }
            }
        }
    } else {
        if ($backup_block_format == 'instances') {
            $status = restore_create_block_instances($restore, $xml_file);
        }
    }
    return $status;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:52,代码来源:restorelib.php

示例4: create_course

 function create_course($course_ext, $skip_fix_course_sortorder = 0)
 {
     global $CFG;
     // override defaults with template course
     if (!empty($CFG->enrol_ldap_template)) {
         $course = get_record("course", 'shortname', $CFG->enrol_ldap_template);
         unset($course->id);
         // so we are clear to reinsert the record
         unset($course->sortorder);
     } else {
         // set defaults
         $course = new object();
         $course->student = get_string('defaultcoursestudent');
         $course->students = get_string('defaultcoursestudents');
         $course->teacher = get_string('defaultcourseteacher');
         $course->teachers = get_string('defaultcourseteachers');
         $course->format = 'topics';
     }
     // override with required ext data
     $course->idnumber = $course_ext[$CFG->enrol_ldap_course_idnumber][0];
     $course->fullname = $course_ext[$CFG->enrol_ldap_course_fullname][0];
     $course->shortname = $course_ext[$CFG->enrol_ldap_course_shortname][0];
     if (empty($course->idnumber) || empty($course->fullname) || empty($course->shortname)) {
         // we are in trouble!
         error_log("Cannot create course: missing required data from the LDAP record!");
         error_log(var_export($course, true));
         return false;
     }
     $course->summary = empty($CFG->enrol_ldap_course_summary) || empty($course_ext[$CFG->enrol_ldap_course_summary][0]) ? '' : $course_ext[$CFG->enrol_ldap_course_summary][0];
     if (!empty($CFG->enrol_ldap_category)) {
         // optional ... but ensure it is set!
         $course->category = $CFG->enrol_ldap_category;
     }
     if ($course->category == 0) {
         // must be avoided as it'll break moodle
         $course->category = 1;
         // the misc 'catch-all' category
     }
     // define the sortorder (yuck)
     $sort = get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course WHERE category=' . $course->category);
     $sort = $sort->max;
     $sort++;
     $course->sortorder = $sort;
     // override with local data
     $course->startdate = time();
     $course->timecreated = time();
     $course->visible = 1;
     $course = addslashes_recursive($course);
     // store it and log
     if ($newcourseid = insert_record("course", $course)) {
         // Set up new course
         $section = new object();
         $section->course = $newcourseid;
         // Create a default section.
         $section->section = 0;
         $section->id = insert_record("course_sections", $section);
         $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
         blocks_repopulate_page($page);
         // Return value no
         if (!$skip_fix_course_sortorder) {
             fix_course_sortorder();
         }
         add_to_log($newcourseid, "course", "new", "view.php?id={$newcourseid}", "enrol/ldap auto-creation");
     } else {
         error_log("Could not create new course from LDAP from DN:" . $course_ext['dn']);
         notify("Serious Error! Could not create the new course!");
         return false;
     }
     return $newcourseid;
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:70,代码来源:enrol.php

示例5: create_course

 function create_course($course, $skip_fix_course_sortorder = 0)
 {
     global $CFG;
     // define a template
     if (!empty($CFG->enrol_db_template)) {
         $template = get_record("course", 'shortname', $CFG->enrol_db_template);
         $template = (array) $template;
     } else {
         $site = get_site();
         $template = array('startdate' => time() + 3600 * 24, 'summary' => get_string("defaultcoursesummary"), 'format' => "weeks", 'password' => "", 'guest' => 0, 'numsections' => 10, 'idnumber' => '', 'cost' => '', 'newsitems' => 5, 'showgrades' => 1, 'groupmode' => 0, 'groupmodeforce' => 0, 'student' => $site->student, 'students' => $site->students, 'teacher' => $site->teacher, 'teachers' => $site->teachers);
     }
     // overlay template
     foreach (array_keys($template) as $key) {
         if (empty($course->{$key})) {
             $course->{$key} = $template[$key];
         }
     }
     $course->category = 1;
     // the misc 'catch-all' category
     if (!empty($CFG->enrol_db_category)) {
         //category = 0 or undef will break moodle
         $course->category = $CFG->enrol_db_category;
     }
     // define the sortorder
     $sort = get_field_sql('SELECT COALESCE(MAX(sortorder)+1, 100) AS max ' . ' FROM ' . $CFG->prefix . 'course ' . ' WHERE category=' . $course->category);
     $course->sortorder = $sort;
     // override with local data
     $course->startdate = time() + 3600 * 24;
     $course->timecreated = time();
     $course->visible = 1;
     // clear out id just in case
     unset($course->id);
     // truncate a few key fields
     $course->idnumber = substr($course->idnumber, 0, 100);
     $course->shortname = substr($course->shortname, 0, 100);
     // store it and log
     if ($newcourseid = insert_record("course", addslashes_object($course))) {
         // Set up new course
         $section = NULL;
         $section->course = $newcourseid;
         // Create a default section.
         $section->section = 0;
         $section->id = insert_record("course_sections", $section);
         $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
         blocks_repopulate_page($page);
         // Return value no
         if (!$skip_fix_course_sortorder) {
             fix_course_sortorder();
         }
         add_to_log($newcourseid, "course", "new", "view.php?id={$newcourseid}", "enrol/database auto-creation");
     } else {
         trigger_error("Could not create new course {$extcourse} from  from database");
         notify("Serious Error! Could not create the new course!");
         return false;
     }
     return $newcourseid;
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:57,代码来源:enrol.php

示例6: create_course

/**
 * Create a course and either return a $course object or false
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 */
function create_course($data)
{
    global $CFG, $USER;
    // preprocess allowed mods
    $allowedmods = empty($data->allowedmods) ? array() : $data->allowedmods;
    unset($data->allowedmods);
    if ($CFG->restrictmodulesfor == 'all') {
        $data->restrictmodules = 1;
        // if the user is not an admin, get the default allowed modules because
        // there are no modules passed by the form
        if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
            if (!$allowedmods && $CFG->defaultallowedmodules) {
                $allowedmods = explode(',', $CFG->defaultallowedmodules);
            }
        }
    } else {
        $data->restrictmodules = 0;
    }
    $data->timecreated = time();
    // place at beginning of category
    fix_course_sortorder();
    $data->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category={$data->category}");
    if (empty($data->sortorder)) {
        $data->sortorder = 100;
    }
    if ($newcourseid = insert_record('course', $data)) {
        // Set up new course
        $course = get_record('course', 'id', $newcourseid);
        // Setup the blocks
        $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
        blocks_repopulate_page($page);
        // Return value not checked because you can always edit later
        update_restricted_mods($course, $allowedmods);
        $section = new object();
        $section->course = $course->id;
        // Create a default section.
        $section->section = 0;
        $section->id = insert_record('course_sections', $section);
        fix_course_sortorder();
        add_to_log(SITEID, 'course', 'new', 'view.php?id=' . $course->id, $data->fullname . ' (ID ' . $course->id . ')');
        // Save any custom role names.
        save_local_role_names($course->id, $data);
        // Trigger events
        events_trigger('course_created', $course);
        return $course;
    }
    return false;
    // error
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:54,代码来源:lib.php

示例7: process_group_tag


//.........这里部分代码省略.........
         
                // Second, look in the course alias table to see if the code should be translated to something else
                 if($aliases = get_field('enrol_coursealias', 'toids', 'fromid', $group->coursecode)){
                     $this->log_line("Found alias of course code: Translated $group->coursecode to $aliases");
                     // Alias is allowed to be a comma-separated list, so let's split it
                     $group->coursecode = explode(',', $aliases);
                 }
                */
         // For compatibility with the (currently inactive) course aliasing, we need this to be an array
         $group->coursecode = array($group->coursecode);
         // Third, check if the course(s) exist
         foreach ($group->coursecode as $coursecode) {
             $coursecode = trim($coursecode);
             if (!get_field('course', 'id', 'idnumber', $coursecode)) {
                 if (!$CFG->enrol_createnewcourses) {
                     $this->log_line("Course {$coursecode} not found in Moodle's course idnumbers.");
                 } else {
                     // Create the (hidden) course(s) if not found
                     $course = new object();
                     $course->fullname = $group->description;
                     $course->shortname = $coursecode;
                     $course->idnumber = $coursecode;
                     $course->format = 'topics';
                     $course->visible = 0;
                     // Insert default names for teachers/students, from the current language
                     $site = get_site();
                     if (current_language() == $CFG->lang) {
                         $course->teacher = $site->teacher;
                         $course->teachers = $site->teachers;
                         $course->student = $site->student;
                         $course->students = $site->students;
                     } else {
                         $course->teacher = get_string("defaultcourseteacher");
                         $course->teachers = get_string("defaultcourseteachers");
                         $course->student = get_string("defaultcoursestudent");
                         $course->students = get_string("defaultcoursestudents");
                     }
                     // Handle course categorisation (taken from the group.org.orgunit field if present)
                     if (strlen($group->category) > 0) {
                         // If the category is defined and exists in Moodle, we want to store it in that one
                         if ($catid = get_field('course_categories', 'id', 'name', addslashes($group->category))) {
                             $course->category = $catid;
                         } elseif ($CFG->enrol_createnewcategories) {
                             // Else if we're allowed to create new categories, let's create this one
                             $newcat->name = $group->category;
                             $newcat->visible = 0;
                             if ($catid = insert_record('course_categories', $newcat)) {
                                 $course->category = $catid;
                                 $this->log_line("Created new (hidden) category, #{$catid}: {$newcat->name}");
                             } else {
                                 $this->log_line('Failed to create new category: ' . $newcat->name);
                             }
                         } else {
                             // If not found and not allowed to create, stick with default
                             $this->log_line('Category ' . $group->category . ' not found in Moodle database, so using default category instead.');
                             $course->category = 1;
                         }
                     } else {
                         $course->category = 1;
                     }
                     $course->timecreated = time();
                     $course->startdate = time();
                     $course->numsections = 1;
                     // Choose a sort order that puts us at the start of the list!
                     $sortinfo = get_record_sql('SELECT MIN(sortorder) AS min,
                        MAX(sortorder) AS max
                         FROM ' . $CFG->prefix . 'course WHERE category<>0');
                     if (is_object($sortinfo)) {
                         // no courses?
                         $max = $sortinfo->max;
                         $min = $sortinfo->min;
                         unset($sortinfo);
                         $course->sortorder = $min - 1;
                     } else {
                         $course->sortorder = 1000;
                     }
                     if ($course->id = insert_record('course', addslashes_object($course))) {
                         // Setup the blocks
                         $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                         blocks_repopulate_page($page);
                         // Return value not checked because you can always edit later
                         $section = new object();
                         $section->course = $course->id;
                         // Create a default section.
                         $section->section = 0;
                         $section->id = insert_record("course_sections", $section);
                         add_to_log(SITEID, "course", "new", "view.php?id={$course->id}", "{$course->fullname} (ID {$course->id})");
                         $this->log_line("Created course {$coursecode} in Moodle (Moodle ID is {$course->id})");
                     } else {
                         $this->log_line('Failed to create course ' . $coursecode . ' in Moodle');
                     }
                 }
             } elseif ($recstatus == 3 && ($courseid = get_field('course', 'id', 'idnumber', $coursecode))) {
                 // If course does exist, but recstatus==3 (delete), then set the course as hidden
                 set_field('course', 'visible', '0', 'id', $courseid);
             }
         }
         // End of foreach(coursecode)
     }
 }
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:enrol.php

示例8: create_course

function create_course($data)
{
    global $CFG, $USER;
    // preprocess allowed mods
    $allowedmods = empty($data->allowedmods) ? array() : $data->allowedmods;
    unset($data->allowedmods);
    if ($CFG->restrictmodulesfor == 'all') {
        $data->restrictmodules = 1;
    } else {
        $data->restrictmodules = 0;
    }
    $data->timecreated = time();
    // place at beginning of category
    fix_course_sortorder();
    $data->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category={$data->category}");
    if (empty($data->sortorder)) {
        $data->sortorder = 100;
    }
    if ($newcourseid = insert_record('course', $data)) {
        // Set up new course
        $course = get_record('course', 'id', $newcourseid);
        // Setup the blocks
        $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
        blocks_repopulate_page($page);
        // Return value not checked because you can always edit later
        update_restricted_mods($course, $allowedmods);
        $section = new object();
        $section->course = $course->id;
        // Create a default section.
        $section->section = 0;
        $section->id = insert_record('course_sections', $section);
        fix_course_sortorder();
        add_to_log(SITEID, 'course', 'new', 'view.php?id=' . $course->id, $data->fullname . ' (ID ' . $course->id . ')');
        //trigger events
        events_trigger('course_created', $course);
        return $course;
    }
    return false;
    // error
}
开发者ID:r007,项目名称:PMoodle,代码行数:40,代码来源:lib.php

示例9: importCourses

 public function importCourses($xml, $catID, $catName)
 {
     //DOM parsing and validating
     $dom = new DOMDocument();
     $dom->loadXML($xml);
     if (!@$dom->schemaValidate($this->courses_schema)) {
         throw new MoodlePluginException("ERROR, not valid XML data...", 2);
     }
     //Check if category exists
     if (!record_exists($this->categories_table, "id", $catID, "name", $catName)) {
         throw new MoodlePluginException("ERROR, category not found...", 1);
     }
     $this->error[$this->courses_table] = array();
     //Create new courses
     $count = 0;
     $courses = $dom->getElementsByTagName("course");
     foreach ($courses as $course) {
         $newcourse = null;
         while ($child = $course->firstChild) {
             $course->removeChild($child);
             switch ($key = $child->nodeName) {
                 case "id":
                     //ID must be assigned later
                     break;
                 case "category":
                     $newcourse->{$key} = $catID;
                     break;
                 default:
                     $newcourse->{$key} = $child->textContent;
                     break;
             }
         }
         //Try to give an ID to the new course and then insert it in database
         if ($newcourseid = insert_record($this->courses_table, $newcourse)) {
             $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
             blocks_repopulate_page($page);
             // Set up new course
             $section = NULL;
             $section->course = $newcourseid;
             // Create a default section.
             $section->section = 0;
             $section->id = insert_record($this->course_sections_table, $section);
             $count++;
         } else {
             array_push($this->error[$this->courses_table], $newcourse->shortname);
         }
     }
     return $count;
 }
开发者ID:BackupTheBerlios,项目名称:moodlews-svn,代码行数:49,代码来源:moodleplugin.php

示例10: rebuild_course

/**
 * @see /course/lib.php - create_course
 * - empty course contents, and clear backups
 * - doesn't create new course records
 * - doesn't change sort order
 * - doesn't update restricted modules
 */
function rebuild_course($cid)
{
    global $CFG;
    require_once $CFG->dirroot . '/backup/lib.php';
    require_once $CFG->libdir . '/pagelib.php';
    empty_course_contents($cid);
    delete_dir_contents($CFG->dataroot . '/' . $cid, 'backupdata');
    $course = get_record('course', 'id', $cid);
    // Setup the blocks
    $page = page_create_object(PAGE_COURSE_VIEW, $cid);
    blocks_repopulate_page($page);
    // Return value not checked because you can always edit later
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:20,代码来源:sharelib.php


注:本文中的blocks_repopulate_page函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。