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


PHP blocks_get_record函数代码示例

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


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

示例1: print_error

}
if (!empty($unprotect) && confirm_sesskey()) {
    if (!($block = $DB->get_record('block', array('id' => $unprotect)))) {
        print_error('blockdoesnotexist', 'error');
    }
    if (in_array($block->name, $undeletableblocktypes)) {
        $undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
        set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
    }
    admin_get_root(true, false);
    // settings not required - only pages
}
if (!empty($delete) && confirm_sesskey()) {
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strmanageblocks);
    if (!($block = blocks_get_record($delete))) {
        print_error('blockdoesnotexist', 'error');
    }
    if (get_string_manager()->string_exists('pluginname', "block_{$block->name}")) {
        $strblockname = get_string('pluginname', "block_{$block->name}");
    } else {
        $strblockname = $block->name;
    }
    if (!$confirm) {
        echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete=' . $block->id . '&confirm=1', 'blocks.php');
        echo $OUTPUT->footer();
        exit;
    } else {
        uninstall_plugin('block', $block->name);
        $a = new stdClass();
        $a->block = $strblockname;
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:blocks.php

示例2: blocks_repopulate_page

function blocks_repopulate_page($page)
{
    global $CFG;
    $allblocks = blocks_get_record();
    if (empty($allblocks)) {
        error('Could not retrieve blocks from the database');
    }
    // Assemble the information to correlate block names to ids
    $idforname = array();
    foreach ($allblocks as $block) {
        $idforname[$block->name] = $block->id;
    }
    /// If the site override has been defined, it is the only valid one.
    if (!empty($CFG->defaultblocks_override)) {
        $blocknames = $CFG->defaultblocks_override;
    } else {
        $blocknames = $page->blocks_get_default();
    }
    $positions = $page->blocks_get_positions();
    $posblocks = explode(':', $blocknames);
    // Now one array holds the names of the positions, and the other one holds the blocks
    // that are going to go in each position. Luckily for us, both arrays are numerically
    // indexed and the indexes match, so we can work straight away... but CAREFULLY!
    // Ready to start creating block instances, but first drop any existing ones
    blocks_delete_all_on_page($page->get_type(), $page->get_id());
    // Here we slyly count $posblocks and NOT $positions. This can actually make a difference
    // if the textual representation has undefined slots in the end. So we only work with as many
    // positions were retrieved, not with all the page says it has available.
    $numpositions = count($posblocks);
    for ($i = 0; $i < $numpositions; ++$i) {
        $position = $positions[$i];
        $blocknames = explode(',', $posblocks[$i]);
        $weight = 0;
        foreach ($blocknames as $blockname) {
            $newinstance = new stdClass();
            $newinstance->blockid = $idforname[$blockname];
            $newinstance->pageid = $page->get_id();
            $newinstance->pagetype = $page->get_type();
            $newinstance->position = $position;
            $newinstance->weight = $weight;
            $newinstance->visible = 1;
            $newinstance->configdata = '';
            if (!empty($newinstance->blockid)) {
                // Only add block if it was recognized
                insert_record('block_instance', $newinstance);
                ++$weight;
            }
        }
    }
    return true;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:51,代码来源:blocklib.php

示例3: get_addable_blocks

 /**
  * The list of block types that may be added to this page.
  *
  * @return array block name => record from block table.
  */
 public function get_addable_blocks()
 {
     $this->check_is_loaded();
     if (!is_null($this->addableblocks)) {
         return $this->addableblocks;
     }
     // Lazy load.
     $this->addableblocks = array();
     $allblocks = blocks_get_record();
     if (empty($allblocks)) {
         return $this->addableblocks;
     }
     $unaddableblocks = self::get_undeletable_block_types();
     $pageformat = $this->page->pagetype;
     foreach ($allblocks as $block) {
         if (!($bi = block_instance($block->name))) {
             continue;
         }
         if ($block->visible && !in_array($block->name, $unaddableblocks) && ($bi->instance_allow_multiple() || !$this->is_block_present($block->name)) && blocks_name_allowed_in_format($block->name, $pageformat) && $bi->user_can_addto($this->page)) {
             $this->addableblocks[$block->name] = $block;
         }
     }
     return $this->addableblocks;
 }
开发者ID:Burick,项目名称:moodle,代码行数:29,代码来源:blocklib.php

示例4: remove_course_contents

/**
 * Clear a course out completely, deleting all content
 * but don't delete the course itself
 *
 * @uses $CFG
 * @param int $courseid The id of the course that is being deleted
 * @param bool $showfeedback Whether to display notifications of each action the function performs.
 * @return bool true if all the removals succeeded. false if there were any failures. If this
 *             method returns false, some of the removals will probably have succeeded, and others
 *             failed, but you have no way of knowing which.
 */
function remove_course_contents($courseid, $showfeedback = true)
{
    global $CFG;
    require_once $CFG->libdir . '/questionlib.php';
    require_once $CFG->libdir . '/gradelib.php';
    $result = true;
    if (!($course = get_record('course', 'id', $courseid))) {
        error('Course ID was incorrect (can\'t find it)');
    }
    $strdeleted = get_string('deleted');
    /// Clean up course formats (iterate through all formats in the even the course format was ever changed)
    $formats = get_list_of_plugins('course/format');
    foreach ($formats as $format) {
        $formatdelete = $format . '_course_format_delete_course';
        $formatlib = "{$CFG->dirroot}/course/format/{$format}/lib.php";
        if (file_exists($formatlib)) {
            include_once $formatlib;
            if (function_exists($formatdelete)) {
                if ($showfeedback) {
                    notify($strdeleted . ' ' . $format);
                }
                $formatdelete($course->id);
            }
        }
    }
    /// Delete every instance of every module
    if ($allmods = get_records('modules')) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $moddelete = $modname . '_delete_instance';
            // Delete everything connected to an instance
            $moddeletecourse = $modname . '_delete_course';
            // Delete other stray stuff (uncommon)
            $count = 0;
            if (file_exists($modfile)) {
                include_once $modfile;
                if (function_exists($moddelete)) {
                    if ($instances = get_records($modname, 'course', $course->id)) {
                        foreach ($instances as $instance) {
                            if ($cm = get_coursemodule_from_instance($modname, $instance->id, $course->id)) {
                                /// Delete activity context questions and question categories
                                question_delete_activity($cm, $showfeedback);
                            }
                            if ($moddelete($instance->id)) {
                                $count++;
                            } else {
                                notify('Could not delete ' . $modname . ' instance ' . $instance->id . ' (' . format_string($instance->name) . ')');
                                $result = false;
                            }
                            if ($cm) {
                                // delete cm and its context in correct order
                                delete_records('course_modules', 'id', $cm->id);
                                delete_context(CONTEXT_MODULE, $cm->id);
                            }
                        }
                    }
                } else {
                    notify('Function ' . $moddelete . '() doesn\'t exist!');
                    $result = false;
                }
                if (function_exists($moddeletecourse)) {
                    $moddeletecourse($course, $showfeedback);
                }
            }
            if ($showfeedback) {
                notify($strdeleted . ' ' . $count . ' x ' . $modname);
            }
        }
    } else {
        error('No modules are installed!');
    }
    /// Give local code a chance to delete its references to this course.
    require_once $CFG->libdir . '/locallib.php';
    notify_local_delete_course($courseid, $showfeedback);
    /// Delete course blocks
    if ($blocks = get_records_sql("SELECT *\n                                   FROM {$CFG->prefix}block_instance\n                                   WHERE pagetype = '" . PAGE_COURSE_VIEW . "'\n                                   AND pageid = {$course->id}")) {
        if (delete_records('block_instance', 'pagetype', PAGE_COURSE_VIEW, 'pageid', $course->id)) {
            if ($showfeedback) {
                notify($strdeleted . ' block_instance');
            }
            require_once $CFG->libdir . '/blocklib.php';
            foreach ($blocks as $block) {
                /// Delete any associated contexts for this block
                delete_context(CONTEXT_BLOCK, $block->id);
                // fix for MDL-7164
                // Get the block object and call instance_delete()
                if (!($record = blocks_get_record($block->blockid))) {
                    $result = false;
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:101,代码来源:moodlelib.php

示例5: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    if (!empty($CFG->showblocksonmodpages)) {
        // get course structure
        $course = get_record('course', 'id', $preferences->backup_course);
        $modinfo =& get_fast_modinfo($course);
        foreach ($preferences->mods as $module) {
            if (!$module->backup) {
                continue;
            }
            if (empty($modinfo->instances[$module->name])) {
                continue;
            }
            $pagetypes = page_import_types('mod/' . $module->name . '/');
            if (empty($pagetypes)) {
                continue;
            }
            foreach ($pagetypes as $pagetype) {
                foreach ($modinfo->instances[$module->name] as $cm) {
                    if (!empty($module->instances[$cm->instance]->backup)) {
                        $pages[] = page_create_object($pagetype, $cm->instance);
                    }
                }
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    foreach ($pages as $page) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    $blockname = $blocks[$instance->blockid]->name;
                    if (!($blockobj = block_instance($blockname, $instance))) {
                        // Invalid block
                        continue;
                    }
                    // encode absolute links in block config
                    $instance->configdata = $blockobj->get_backup_encoded_config();
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blockname));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    // Write instance data if needed
                    if ($blockobj->backuprestore_instancedata_used()) {
                        fwrite($bf, start_tag('INSTANCEDATA', 4, true));
                        $status = $blockobj->instance_backup($bf, $preferences);
                        fwrite($bf, end_tag('INSTANCEDATA', 4, true));
                    }
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:80,代码来源:backuplib.php

示例6: get_addable_blocks

 /**
  * The list of block types that may be added to this page.
  *
  * @return array block name => record from block table.
  */
 public function get_addable_blocks()
 {
     $this->check_is_loaded();
     if (!is_null($this->addableblocks)) {
         return $this->addableblocks;
     }
     // Lazy load.
     $this->addableblocks = array();
     $allblocks = blocks_get_record();
     if (empty($allblocks)) {
         return $this->addableblocks;
     }
     $pageformat = $this->page->pagetype;
     foreach ($allblocks as $block) {
         if ($block->visible && (block_method_result($block->name, 'instance_allow_multiple') || !$this->is_block_present($block->name)) && blocks_name_allowed_in_format($block->name, $pageformat) && block_method_result($block->name, 'user_can_addto', $this->page)) {
             $this->addableblocks[$block->name] = $block;
         }
     }
     return $this->addableblocks;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:25,代码来源:blocklib.php

示例7: array_for_blocks

function array_for_blocks($blocks)
{
    if (empty($blocks)) {
        return array();
    }
    $return_array = array();
    $block_types = blocks_get_record();
    foreach ($blocks as $block) {
        // Only use roles if they're enabled.
        $can_see_hidden_blocks = FALSE;
        if ($CFG->rolesactive) {
            $context = get_context_instance(CONTEXT_COURSE, $course->id);
            $can_see_hidden_blocks = (has_capability('moodle/site:manageblocks', $context) or $block->visible);
        } else {
            $can_see_hidden_blocks = isteacher($course->id, $USER->id, true);
        }
        $show_block = ($block->visible or $can_see_hidden_blocks);
        if ($show_block) {
            $this_block_type = $block_types[intval($block->blockid)];
            if ($this_block_type->name == "calendar_upcoming") {
                $block_array = array();
                $block_array["name"] = $this_block_type->name;
                $return_array[] = $block_array;
            } else {
                if ($this_block_type->name == "calendar_month") {
                    $block_array = array();
                    $block_array["name"] = $this_block_type->name;
                    $return_array[] = $block_array;
                }
            }
        }
    }
    return $return_array;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:34,代码来源:lib.php

示例8: page_block_delete

/**
 * This function removes blocks/modules from a page in the case of
 * blocks it also removes the entry from block_instance 
 *
 * @param object $pageitem a fully populated page_item object
 * @uses $CFG
 * @uses $COURSE
 */
function page_block_delete($pageitem)
{
    global $CFG, $COURSE;
    require_once $CFG->libdir . '/blocklib.php';
    // we leave module cleanup to the manage modules tab... blocks need some help though.
    if (!empty($pageitem->blockinstance)) {
        if ($blockinstance = get_record('block_instance', 'id', $pageitem->blockinstance)) {
            // see if this is the last reference to the blockinstance
            $count = count_records('format_page_items', 'blockinstance', $pageitem->blockinstance);
            if ($count == 1) {
                if ($block = blocks_get_record($blockinstance->blockid)) {
                    if ($block->name != 'course_menu') {
                        // At this point, the format has done all of its own checking,
                        // hand it off to block API
                        blocks_delete_instance($blockinstance);
                    }
                }
            }
        }
    }
    delete_records('format_page_items', 'id', $pageitem->id);
    execute_sql("UPDATE {$CFG->prefix}format_page_items\n                    SET sortorder = sortorder - 1\n                  WHERE pageid = {$pageitem->pageid}\n                    AND position = '{$pageitem->position}'\n                    AND sortorder > {$pageitem->sortorder}", false);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:lib.php

示例9: array_for_blocks

 //var_dump($context);
 //$block_instances = $DB->get_records('block_instances', array('pagetypepattern' => 'site-index'));
 //$block_instances = $DB->get_records('block_instances', array('pagetypepattern' => 'site-index'));
 /*
 $json_output["site_blocks"] = array_for_blocks($blocks);
 foreach ($blocks as $block) {
 	if($block->blockname == "site_main_menu") {
 		$json_output["main_menu_visible"] = $block;
 		break;
 	}
 }
 */
 //var_dump($DB->get_recordset_sql("SELECT id, blockname FROM $DB->prefix_block_instances WHERE pagetypepattern = 'site-index'"));
 //}
 //else {
 $block_types = blocks_get_record();
 $blocks = get_records_select('block_instance', "pageid = '1' AND pagetype = 'course-view'");
 $pinned_blocks = get_records_select('block_pinned', "pagetype = 'course-view'");
 foreach ($pinned_blocks as $pinned_block) {
     $blocks[] = $pinned_block;
 }
 $json_output["site_blocks"] = array_for_blocks($blocks);
 $site_menu_id = NULL;
 foreach ($block_types as $block_type) {
     if ($block_type->name == "site_main_menu") {
         $site_menu_id = $block_type->id;
     }
 }
 $main_menu_block = get_records_select('block_instance', "pageid = '1' AND pagetype = 'course-view' AND blockid = '" . $site_menu_id . "'", 'position, weight');
 $main_menu_block = $main_menu_block[1];
 if ($main_menu_block->visible) {
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:main.php

示例10: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    // Let's see if we have to backup blocks from modules
    $modulerecords = get_records_sql('SELECT name, id FROM ' . $CFG->prefix . 'modules');
    foreach ($preferences->mods as $module) {
        if (!$module->backup) {
            continue;
        }
        $cmods = get_records_select('course_modules', 'course = ' . $preferences->backup_course . ' AND module = ' . $modulerecords[$module->name]->id);
        if (empty($cmods)) {
            continue;
        }
        $pagetypes = page_import_types('mod/' . $module->name . '/');
        if (empty($pagetypes)) {
            continue;
        }
        foreach ($pagetypes as $pagetype) {
            foreach ($cmods as $cmod) {
                $pages[] = page_create_object($pagetype, $cmod->instance);
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    while ($page = array_pop($pages)) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blocks[$instance->blockid]->name));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:veritech,项目名称:pare-project,代码行数:63,代码来源:backuplib.php

示例11: admin_get_root

<?php

// $Id: block.php,v 1.16.6.1 2007/04/20 07:49:39 nicolasconnault Exp $
// block.php - allows admin to edit all local configuration variables for a block
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
$adminroot = admin_get_root();
admin_externalpage_setup('manageblocks', $adminroot);
require_once $CFG->libdir . '/blocklib.php';
$blockid = required_param('block', PARAM_INT);
if (($blockrecord = blocks_get_record($blockid)) === false) {
    error('This block does not exist');
}
$block = block_instance($blockrecord->name);
if ($block === false) {
    error('Problem in instantiating block object');
}
// Define the data we're going to silently include in the instance config form here,
// so we can strip them from the submitted data BEFORE handling it.
$hiddendata = array('block' => $blockid, 'sesskey' => $USER->sesskey);
/// If data submitted, then process and store.
if ($config = data_submitted()) {
    if (!confirm_sesskey()) {
        error(get_string('confirmsesskeybad', 'error'));
    }
    if (!$block->has_config()) {
        error('This block does not support global configuration');
    }
    $remove = array_keys($hiddendata);
    foreach ($remove as $item) {
        unset($config->{$item});
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:block.php

示例12: remove_course_contents

/**
 * Clear a course out completely, deleting all content
 * but don't delete the course itself
 *
 * @uses $CFG
 * @param int $courseid The id of the course that is being deleted
 * @param bool $showfeedback Whether to display notifications of each action the function performs.
 * @return bool true if all the removals succeeded. false if there were any failures. If this
 *             method returns false, some of the removals will probably have succeeded, and others
 *             failed, but you have no way of knowing which.
 */
function remove_course_contents($courseid, $showfeedback = true)
{
    global $CFG;
    $result = true;
    if (!($course = get_record('course', 'id', $courseid))) {
        error('Course ID was incorrect (can\'t find it)');
    }
    $strdeleted = get_string('deleted');
    /// First delete every instance of every module
    if ($allmods = get_records('modules')) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $moddelete = $modname . '_delete_instance';
            // Delete everything connected to an instance
            $moddeletecourse = $modname . '_delete_course';
            // Delete other stray stuff (uncommon)
            $count = 0;
            if (file_exists($modfile)) {
                include_once $modfile;
                if (function_exists($moddelete)) {
                    if ($instances = get_records($modname, 'course', $course->id)) {
                        foreach ($instances as $instance) {
                            if ($cm = get_coursemodule_from_instance($modname, $instance->id, $course->id)) {
                                delete_context(CONTEXT_MODULE, $cm->id);
                            }
                            if ($moddelete($instance->id)) {
                                $count++;
                            } else {
                                notify('Could not delete ' . $modname . ' instance ' . $instance->id . ' (' . format_string($instance->name) . ')');
                                $result = false;
                            }
                        }
                    }
                } else {
                    notify('Function ' . $moddelete . '() doesn\'t exist!');
                    $result = false;
                }
                if (function_exists($moddeletecourse)) {
                    $moddeletecourse($course, $showfeedback);
                }
            }
            if ($showfeedback) {
                notify($strdeleted . ' ' . $count . ' x ' . $modname);
            }
        }
    } else {
        error('No modules are installed!');
    }
    /// Give local code a chance to delete its references to this course.
    require_once 'locallib.php';
    notify_local_delete_course($courseid, $showfeedback);
    /// Delete course blocks
    if ($blocks = get_records_sql("SELECT *\n                                   FROM {$CFG->prefix}block_instance\n                                   WHERE pagetype = '" . PAGE_COURSE_VIEW . "'\n                                   AND pageid = {$course->id}")) {
        if (delete_records('block_instance', 'pagetype', PAGE_COURSE_VIEW, 'pageid', $course->id)) {
            if ($showfeedback) {
                notify($strdeleted . ' block_instance');
            }
            require_once $CFG->libdir . '/blocklib.php';
            foreach ($blocks as $block) {
                /// Delete any associated contexts for this block
                // Block instances are rarely created. Since the block instance is gone from the above delete
                // statement, calling delete_context() will generate a warning as get_context_instance could
                // no longer create the context as the block is already gone.
                if (record_exists('context', 'contextlevel', CONTEXT_BLOCK, 'instanceid', $block->id)) {
                    delete_context(CONTEXT_BLOCK, $block->id);
                }
                // fix for MDL-7164
                // Get the block object and call instance_delete()
                if (!($record = blocks_get_record($block->blockid))) {
                    $result = false;
                    continue;
                }
                if (!($obj = block_instance($record->name, $block))) {
                    $result = false;
                    continue;
                }
                // Return value ignored, in core mods this does not do anything, but just in case
                // third party blocks might have stuff to clean up
                // we execute this anyway
                $obj->instance_delete();
            }
        } else {
            $result = false;
        }
    }
    /// Delete any groups, removing members and grouping/course links first.
    //TODO: If groups or groupings are to be shared between courses, think again!
    if ($groupids = groups_get_groups($course->id)) {
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:moodlelib.php


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