本文整理汇总了PHP中block_instance函数的典型用法代码示例。如果您正苦于以下问题:PHP block_instance函数的具体用法?PHP block_instance怎么用?PHP block_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了block_instance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cron
public function cron()
{
global $DB;
$this->run_profiler();
// Get the instances of the block
$instances = $DB->get_records('block_instances', array('blockname' => 'itutor_profiler'));
foreach ($instances as $instance) {
$block = block_instance('itutor_profiler', $instance);
$courses = $DB->get_records('course', array());
foreach ($courses as $course) {
$this->run_alerter($course);
}
}
}
示例2: decode_content_links_caller
/**
* This function makes all the necessary calls to {@link restore_decode_content_links_worker()}
* function in order to decode contents of this block from the backup
* format to destination site/course in order to mantain inter-activities
* working in the backup/restore process.
*
* This is called from {@link restore_decode_content_links()} function in the restore process.
*
* NOTE: There is no block instance when this method is called.
*
* @param object $restore Standard restore object
* @return boolean
**/
function decode_content_links_caller($restore)
{
global $CFG;
if ($restored_blocks = get_records_select("backup_ids", "table_name = 'block_instance' AND backup_code = {$restore->backup_unique_code} AND new_id > 0", "", "new_id")) {
$restored_blocks = implode(',', array_keys($restored_blocks));
$sql = "SELECT bi.*\n FROM {$CFG->prefix}block_instance bi\n JOIN {$CFG->prefix}block b ON b.id = bi.blockid\n WHERE b.name = 'incrementalclient' AND bi.id IN ({$restored_blocks})";
if ($instances = get_records_sql($sql)) {
foreach ($instances as $instance) {
$blockobject = block_instance('incrementalclient', $instance);
$blockobject->instance_config_commit($blockobject->pinned);
}
}
}
return true;
}
示例3: decode_content_links_caller
/**
* This function makes all the necessary calls to {@link restore_decode_content_links_worker()}
* function in order to decode contents of this block from the backup
* format to destination site/course in order to mantain inter-activities
* working in the backup/restore process.
*
* This is called from {@link restore_decode_content_links()} function in the restore process.
*
* NOTE: There is no block instance when this method is called.
*
* @param object $restore Standard restore object
* @return boolean
**/
function decode_content_links_caller($restore)
{
global $CFG, $DB;
if ($restored_blocks = $DB->get_records_select("backup_ids", "table_name = 'block_instance' AND backup_code = ? AND new_id > 0", array($restore->backup_unique_code), "", "new_id")) {
$restored_blocks = implode(',', array_keys($restored_blocks));
$sql = "SELECT bi.*\n FROM {block_instance} bi\n JOIN {block} b ON b.id = bi.blockid\n WHERE b.name = 'html' AND bi.id IN ({$restored_blocks})";
if ($instances = $DB->get_records_sql($sql)) {
foreach ($instances as $instance) {
$blockobject = block_instance('html', $instance);
$blockobject->config->text = restore_decode_absolute_links($blockobject->config->text);
$blockobject->config->text = restore_decode_content_links_worker($blockobject->config->text, $restore);
$blockobject->instance_config_commit($blockobject->pinned);
}
}
}
return true;
}
示例4: my_copy_page
function my_copy_page($userid, $private = MY_PAGE_PRIVATE, $pagetype = 'my-index')
{
global $DB;
if ($customised = $DB->get_record('my_pages', array('userid' => $userid, 'private' => $private))) {
return $customised;
// We're done!
}
// Get the system default page
if (!($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => $private)))) {
return false;
// error
}
// Clone the basic system page record
$page = clone $systempage;
unset($page->id);
$page->userid = $userid;
$page->id = $DB->insert_record('my_pages', $page);
// Clone ALL the associated blocks as well
$systemcontext = context_system::instance();
$usercontext = context_user::instance($userid);
$blockinstances = $DB->get_records('block_instances', array('parentcontextid' => $systemcontext->id, 'pagetypepattern' => $pagetype, 'subpagepattern' => $systempage->id));
foreach ($blockinstances as $instance) {
$originalid = $instance->id;
unset($instance->id);
$instance->parentcontextid = $usercontext->id;
$instance->subpagepattern = $page->id;
$instance->id = $DB->insert_record('block_instances', $instance);
$blockcontext = context_block::instance($instance->id);
// Just creates the context record
$block = block_instance($instance->blockname, $instance);
if (!$block->instance_copy($originalid)) {
debugging("Unable to copy block-specific data for original block instance: {$originalid}\n to new block instance: {$instance->id}", DEBUG_DEVELOPER);
}
}
// FIXME: block position overrides should be merged in with block instance
//$blockpositions = $DB->get_records('block_positions', array('subpage' => $page->name));
//foreach($blockpositions as $positions) {
// $positions->subpage = $page->name;
// $DB->insert_record('block_positions', $tc);
//}
return $page;
}
示例5: specific_definition
protected function specific_definition($mform)
{
global $CFG, $DB, $COURSE;
$options = array();
$options[1] = get_string('yes', 'block_map');
$options[0] = get_string('no', 'block_map');
// Fields for editing HTML block title and contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$mform->addElement('text', 'config_title', get_string('settings:titlemap', 'block_map'));
$mform->setType('config_title', PARAM_TEXT);
$mform->setDefault('config_title', get_string('pluginname', 'block_map'));
$mform->addElement('select', 'config_sitemode', get_string('settings:sitemode', 'block_map'), $options);
$mform->setDefault('config_sitemode', $CFG->map_sitemode);
$mform->addElement('select', 'config_activate', get_string('settings:activate', 'block_map'), $options);
$mform->setDefault('config_activate', $CFG->map_activate);
$mform->addElement('select', 'config_editmarks', get_string('settings:editmarks', 'block_map'), $options);
$mform->setDefault('config_editmarks', $CFG->map_editmarks);
$mform->addElement('select', 'config_loadmarkdin', get_string('settings:loadmarkdin', 'block_map'), $options);
$mform->setDefault('config_loadmarkdin', $CFG->map_loadmarkdin);
$mform->addElement('select', 'config_publickmap', get_string('settings:publickmap', 'block_map'), $options);
$mform->setDefault('config_publickmap', $CFG->map_publickmap);
$mform->addElement('text', 'config_latitude', get_string('settings:latitude', 'block_map'));
$mform->setType('config_latitude', PARAM_TEXT);
$mform->setDefault('config_latitude', $CFG->map_latitude);
$mform->addElement('text', 'config_longitude', get_string('settings:longitude', 'block_map'));
$mform->setType('config_longitude', PARAM_TEXT);
$mform->setDefault('config_longitude', $CFG->map_longitude);
$mform->addElement('hidden', 'config_coursename', $COURSE->fullname);
$mform->addElement('hidden', 'config_courseid', $COURSE->id);
$data = $DB->get_records("block_instances", array("blockname" => "map"));
$datares = array();
$cm = array();
$datares[0] = get_string("settings:shareown", "block_map");
foreach ($data as $data_) {
$cm = block_instance('map', $data_);
$cm->config = unserialize(base64_decode($cm->instance->configdata));
$datares[$cm->config->courseid] = $cm->config->coursename;
}
$mform->addElement('select', 'config_shareid', get_string('settings:share', 'block_map'), $datares);
//$mform->setDefault('config_shareid', '');
}
示例6: content_unlock_get_block_conditions_text
function content_unlock_get_block_conditions_text($unlock_system)
{
global $DB;
$conditions_text = array();
$unlock_system_block_conditions = $DB->get_records('content_unlock_condition', array('unlocksystemid' => $unlock_system->id));
foreach ($unlock_system_block_conditions as $unlock_system_block_condition) {
if ($unlock_system_block_condition->type == 0) {
$block_info = null;
if (isset($unlock_system_block_condition->prpointsystemid)) {
$block_instance_id = $DB->get_field('points_system', 'blockinstanceid', array('id' => $unlock_system_block_condition->prpointsystemid));
$block_info = $DB->get_record('block_instances', array('id' => $block_instance_id));
$points_system_name = $DB->get_field('points_system', 'name', array('id' => $unlock_system_block_condition->prpointsystemid));
} else {
$block_info = $DB->get_record('block_instances', array('id' => $unlock_system_block_condition->prblockid));
}
$instance = block_instance('game_points', $block_info);
$conditions_text[] = get_string('block_conditions_reach', 'block_game_content_unlock') . ' ' . $unlock_system_block_condition->prpoints . ' ' . get_string('block_conditions_points', 'block_game_content_unlock') . ' (' . ($unlock_system_block_condition->prgrupal ? get_string('block_conditions_grupal', 'block_game_content_unlock') : get_string('block_conditions_individual', 'block_game_content_unlock')) . ') ' . get_string('block_conditions_on', 'block_game_content_unlock') . ' ' . (isset($unlock_system_block_condition->prblockid) ? get_string('block_conditions_block', 'block_game_content_unlock') . ' ' . $instance->title : get_string('block_conditions_pointsystem', 'block_game_content_unlock') . ' ' . (empty($points_system_name) ? $unlock_system_block_condition->prpointsystemid : $points_system_name . ' (' . $unlock_system_block_condition->prpointsystemid . ')') . ' (' . get_string('block_conditions_block', 'block_game_content_unlock') . ' ' . $instance->title . ')');
} else {
if ($unlock_system_block_condition->type == 1) {
$condition_unlock_system = $DB->get_record('content_unlock_system', array('id' => $unlock_system_block_condition->urunlocksystemid));
$course = $DB->get_record('course', array('id' => $this->page->course->id));
$info = get_fast_modinfo($course);
$cm = $info->get_cm($condition_unlock_system->coursemoduleid);
$block_info = $DB->get_record('block_instances', array('id' => $condition_unlock_system->blockinstanceid));
$instance = block_instance('game_content_unlock', $block_info);
$conditions_text[] = ($unlock_system_block_condition->urmust ? get_string('block_conditions_have', 'block_game_content_unlock') : get_string('block_conditions_havenot', 'block_game_content_unlock')) . ' ' . ($condition_unlock_system->coursemodulevisibility ? get_string('block_conditions_unlocked', 'block_game_content_unlock') : get_string('block_conditions_locked', 'block_game_content_unlock')) . ' ' . get_string('block_conditions_resource', 'block_game_content_unlock') . ' ' . $cm->name . ' (' . get_string('block_conditions_block', 'block_game_content_unlock') . ' ' . $instance->title . ')';
} else {
$condition_achievement = $DB->get_record('achievements', array('id' => $unlock_system_block_condition->arachievementid));
$block_info = $DB->get_record('block_instances', array('id' => $condition_achievement->blockinstanceid));
$instance = block_instance('game_achievements', $block_info);
$conditions_text[] = get_string('block_conditions_reach', 'block_game_content_unlock') . ' ' . get_string('block_conditions_achievement', 'block_game_content_unlock') . ' ' . (isset($condition_achievement->name) ? $condition_achievement->name . ' (' . $condition_achievement->id . ')' : $condition_achievement->id) . ' (' . get_string('block_conditions_block', 'block_game_content_unlock') . ' ' . $instance->title . ')';
}
}
}
return implode(' ' . ($unlock_system->connective == AND_CONNECTIVE ? get_string('block_conditions_and', 'block_game_content_unlock') : get_string('block_conditions_or', 'block_game_content_unlock')) . ' ', $conditions_text);
}
示例7: backup_encode_absolute_links
function backup_encode_absolute_links($content)
{
global $CFG, $preferences;
/// MDL-14072: Prevent NULLs, empties and numbers to be processed by the
/// heavy interlinking. Just a few cpu cycles saved.
if ($content === NULL) {
return NULL;
} else {
if ($content === '') {
return '';
} else {
if (is_numeric($content)) {
return $content;
}
}
}
//Use one static variable to cache all the require_once calls that,
//under PHP5 seems to increase load too much, and we are requiring
//them here thousands of times (one per content). MDL-8700.
//Once fixed by PHP, we'll delete this hack
static $includedfiles;
if (!isset($includedfiles)) {
$includedfiles = array();
}
//Check if we support unicode modifiers in regular expressions. Cache it.
static $unicoderegexp;
if (!isset($unicoderegexp)) {
$unicoderegexp = @preg_match('/\\pL/u', 'a');
// This will fail silenty, returning false,
}
// if regexp libraries don't support unicode
//Check if preferences is ok. If it isn't set, we are
//in a scheduled_backup to we are able to get a copy
//from CFG->backup_preferences
if (!isset($preferences)) {
$mypreferences = $CFG->backup_preferences;
} else {
//We are in manual backups so global preferences must exist!!
$mypreferences = $preferences;
}
//First, we check for every call to file.php inside the course
$search = array($CFG->wwwroot . '/file.php/' . $mypreferences->backup_course, $CFG->wwwroot . '/file.php?file=/' . $mypreferences->backup_course, $CFG->wwwroot . '/file.php?file=%2f' . $mypreferences->backup_course, $CFG->wwwroot . '/file.php?file=%2F' . $mypreferences->backup_course);
$replace = array('$@FILEPHP@$', '$@FILEPHP@$', '$@FILEPHP@$', '$@FILEPHP@$');
$result = str_replace($search, $replace, $content);
// Now we look for any '$@FILEPHP@$' URLs, replacing:
// - slashes and %2F by $@SLASH@$
// - &forcedownload=1 &forcedownload=1 and ?forcedownload=1 by $@FORCEDOWNLOAD@$
// This way, backup contents will be neutral and independent of slasharguments configuration. MDL-18799
// Based in $unicoderegexp, decide the regular expression to use
if ($unicoderegexp) {
//We can use unicode modifiers
$search = '/(\\$@FILEPHP@\\$)((?:(?:\\/|%2f|%2F))(?:(?:\\([-;:@#&=\\pL0-9\\$~_.+!*\',]*?\\))|[-;:@#&=\\pL0-9\\$~_.+!*\',]|%[a-fA-F0-9]{2}|\\/)*)?(\\?(?:(?:(?:\\([-;:@#&=\\pL0-9\\$~_.+!*\',]*?\\))|[-;:@#&=?\\pL0-9\\$~_.+!*\',]|%[a-fA-F0-9]{2}|\\/)*))?(?<![,.;])/u';
} else {
//We cannot ue unicode modifiers
$search = '/(\\$@FILEPHP@\\$)((?:(?:\\/|%2f|%2F))(?:(?:\\([-;:@#&=a-zA-Z0-9\\$~_.+!*\',]*?\\))|[-;:@#&=a-zA-Z0-9\\$~_.+!*\',]|%[a-fA-F0-9]{2}|\\/)*)?(\\?(?:(?:(?:\\([-;:@#&=a-zA-Z0-9\\$~_.+!*\',]*?\\))|[-;:@#&=?a-zA-Z0-9\\$~_.+!*\',]|%[a-fA-F0-9]{2}|\\/)*))?(?<![,.;])/';
}
$result = preg_replace_callback($search, 'backup_process_filephp_uses', $result);
foreach ($mypreferences->mods as $name => $info) {
/// We only include the corresponding backuplib.php if it hasn't been included before
/// This will save some load under PHP5. MDL-8700.
/// Once fixed by PHP, we'll delete this hack
if (!in_array($name, $includedfiles)) {
include_once "{$CFG->dirroot}/mod/{$name}/backuplib.php";
$includedfiles[] = $name;
}
//Check if the xxxx_encode_content_links exists
$function_name = $name . "_encode_content_links";
if (function_exists($function_name)) {
$result = $function_name($result, $mypreferences);
}
}
// For the current course format call its encode_content_links method (if it exists)
static $format_function_name;
if (!isset($format_function_name)) {
$format_function_name = false;
if ($format = get_field('course', 'format', 'id', $mypreferences->backup_course)) {
if (file_exists("{$CFG->dirroot}/course/format/{$format}/backuplib.php")) {
include_once "{$CFG->dirroot}/course/format/{$format}/backuplib.php";
$function_name = $format . '_encode_format_content_links';
if (function_exists($function_name)) {
$format_function_name = $function_name;
}
}
}
}
// If the above worked - then we have a function to call
if ($format_function_name) {
$result = $format_function_name($result, $mypreferences);
}
// For each block, call its encode_content_links method.
// This encodes forexample links to blocks/something/viewphp?id=666
// that are stored in other activities.
static $blockobjects = null;
if (!isset($blockobjects)) {
$blockobjects = array();
if ($blocks = get_records('block', 'visible', 1)) {
foreach ($blocks as $block) {
if ($blockobject = block_instance($block->name)) {
$blockobjects[] = $blockobject;
}
//.........这里部分代码省略.........
示例8: definition
//.........这里部分代码省略.........
$iconmarkup = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(), 'class' => 'activityicon', 'alt' => ''));
$stractivityname = html_writer::tag('strong', $iconmarkup . $cm->name);
$mform->addElement('static', 'modname' . $cm->id, $stractivityname);
$isdateadded = false;
// Call get_settings method for the acitivity/module.
// Get instance of the mod's date exractor class.
$mod = report_editdates_mod_date_extractor::make($cm->modname, $course);
if ($mod && ($cmdatesettings = $mod->get_settings($cm))) {
// Added activity name on the form.
foreach ($cmdatesettings as $cmdatetype => $cmdatesetting) {
$elname = 'date_mod_' . $cm->id . '_' . $cmdatetype;
$mform->addElement($cmdatesetting->type, $elname, $cmdatesetting->label, array('optional' => $cmdatesetting->isoptional, 'step' => $cmdatesetting->getstep));
$mform->setDefault($elname, $cmdatesetting->currentvalue);
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
$elementadded++;
$isdateadded = true;
}
}
if ($coursehasavailability && $cm->availability) {
// If there are retricted access date settings.
if (strpos($cm->availability, '"type":"date"') !== false) {
$editsettingurl = new moodle_url('/course/modedit.php', array('update' => $cm->id));
$editsettingurltext = html_writer::tag('a', get_string('editrestrictedaccess', 'report_editdates'), array('href' => $editsettingurl->out(false), 'target' => '_blank'));
$mform->addElement('static', '', get_string('hasrestrictedaccess', 'report_editdates', $cm->name), $editsettingurltext);
}
}
// Completion tracking.
if ($coursehascompletion && $cm->completion) {
$elname = 'date_mod_' . $cm->id . '_completionexpected';
$mform->addElement('date_selector', $elname, get_string('completionexpected', 'completion'), array('optional' => true));
$mform->addHelpButton($elname, 'completionexpected', 'completion');
$mform->setDefault($elname, $cm->completionexpected);
if ($ismodreadonly) {
$mform->hardFreeze($elname);
}
$elementadded++;
$isdateadded = true;
}
if ($isdateadded) {
$ismodadded = true;
$addactionbuttons = true;
} else {
$mform->removeElement('modname' . $cm->id);
}
}
// End of modules loop.
if (!$ismodadded && $mform->elementExists($sectionname)) {
$mform->removeElement($sectionname);
}
}
}
// End of sections loop.
// Fetching all the blocks added directly under the course.
// That is, parentcontextid = coursecontextid.
$courseblocks = $DB->get_records('block_instances', array('parentcontextid' => $coursecontext->id));
// Check capability of current user.
$canmanagesiteblocks = has_capability('moodle/site:manageblocks', $coursecontext);
$anyblockadded = false;
if ($courseblocks) {
// Header for blocks.
$mform->addElement('header', 'blockdatesection');
// Iterate though blocks array.
foreach ($courseblocks as $blockid => $block) {
$blockdatextrator = report_editdates_block_date_extractor::make($block->blockname, $course);
if ($blockdatextrator) {
// Create the block instance.
$blockobj = block_instance($block->blockname, $block, $PAGE);
// If get_settings returns a valid array.
if ($blockdatesettings = $blockdatextrator->get_settings($blockobj)) {
$anyblockadded = true;
$addactionbuttons = true;
// Adding block's Title on page.
$mform->addElement('static', 'blocktitle', $blockobj->title);
foreach ($blockdatesettings as $blockdatetype => $blockdatesetting) {
$elname = 'date_block_' . $block->id . '_' . $blockdatetype;
// Add element.
$mform->addElement($blockdatesetting->type, $elname, $blockdatesetting->label, array('optional' => $blockdatesetting->isoptional, 'step' => $blockdatesetting->getstep));
$mform->setDefault($elname, $blockdatesetting->currentvalue);
if (!$canmanagesiteblocks || !$blockobj->user_can_edit()) {
$mform->hardFreeze($elname);
}
$elementadded++;
}
}
}
}
}
if (!$anyblockadded && $mform->elementExists('blockdatesection')) {
$mform->removeElement('blockdatesection');
}
// Adding submit/cancel buttons @ the end of the form.
if ($addactionbuttons && $elementadded > 0) {
$this->add_action_buttons();
} else {
// Remove top action button.
$mform->removeElement('buttonar');
}
}
示例9: restore_create_block_instances
function restore_create_block_instances($restore, $xml_file)
{
global $CFG;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
$info = restore_read_xml_blocks($restore, $xml_file);
}
if (empty($info->instances)) {
return $status;
}
// First of all, iterate over the blocks to see which distinct pages we have
// in our hands and arrange the blocks accordingly.
$pageinstances = array();
foreach ($info->instances as $instance) {
//pagetype and pageid black magic, we have to handle the case of blocks for the
//course, blocks from other pages in that course etc etc etc.
if ($instance->pagetype == PAGE_COURSE_VIEW) {
// This one's easy...
$instance->pageid = $restore->course_id;
} else {
if (!empty($CFG->showblocksonmodpages)) {
$parts = explode('-', $instance->pagetype);
if ($parts[0] == 'mod') {
if (!$restore->mods[$parts[1]]->restore) {
continue;
}
$getid = backup_getid($restore->backup_unique_code, $parts[1], $instance->pageid);
if (empty($getid->new_id)) {
// Failed, perhaps the module was not included in the restore MDL-13554
continue;
}
$instance->pageid = $getid->new_id;
} else {
// Not invented here ;-)
continue;
}
} else {
// do not restore activity blocks if disabled
continue;
}
}
if (!isset($pageinstances[$instance->pagetype])) {
$pageinstances[$instance->pagetype] = array();
}
if (!isset($pageinstances[$instance->pagetype][$instance->pageid])) {
$pageinstances[$instance->pagetype][$instance->pageid] = array();
}
$pageinstances[$instance->pagetype][$instance->pageid][] = $instance;
}
$blocks = get_records_select('block', 'visible = 1', '', 'name, id, multiple');
// For each type of page we have restored
foreach ($pageinstances as $thistypeinstances) {
// For each page id of that type
foreach ($thistypeinstances as $thisidinstances) {
$addedblocks = array();
$maxweights = array();
// For each block instance in that page
foreach ($thisidinstances as $instance) {
if (!isset($blocks[$instance->name])) {
//We are trying to restore a block we don't have...
continue;
}
//If we have already added this block once and multiples aren't allowed, disregard it
if (!$blocks[$instance->name]->multiple && isset($addedblocks[$instance->name])) {
continue;
}
//If its the first block we add to a new position, start weight counter equal to 0.
if (empty($maxweights[$instance->position])) {
$maxweights[$instance->position] = 0;
}
//If the instance weight is greater than the weight counter (we skipped some earlier
//blocks most probably), bring it back in line.
if ($instance->weight > $maxweights[$instance->position]) {
$instance->weight = $maxweights[$instance->position];
}
//Add this instance
$instance->blockid = $blocks[$instance->name]->id;
// This will only be set if we come from 1.7 and above backups
// Also, must do this before insert (insert_record unsets id)
if (!empty($instance->id)) {
$oldid = $instance->id;
} else {
$oldid = 0;
}
if ($instance->id = insert_record('block_instance', $instance)) {
// Create block instance
if (!($blockobj = block_instance($instance->name, $instance))) {
$status = false;
break;
}
// Run the block restore if needed
if ($blockobj->backuprestore_instancedata_used()) {
// Get restore information
$data = backup_getid($restore->backup_unique_code, 'block_instance', $oldid);
$data->new_id = $instance->id;
//.........这里部分代码省略.........
示例10: defined
/*
* ---------------------------------------------------------------------------------------------------------------------
*
* This file is part of the Course Menu block for Moodle
*
* The Course Menu block for Moodle software package is Copyright � 2008 onwards NetSapiensis AB and is provided under
* the terms of the GNU GENERAL PUBLIC LICENSE Version 3 (GPL). This program 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.
*
* This program 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. This program 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 this program.
* If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------------------------------------------------------
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
require_once 'lib/settingslib.php';
$block = block_instance('course_menu');
$settings->add(new admin_setting_configtext('block_course_menu_trimlength', get_string('trimlength', 'block_course_menu'), '', block_course_menu::DEFAULT_TRIM_LENGTH, PARAM_INT, 11));
$settings->add(new admin_setting_configtext('block_course_menu_sitetitle', get_string('namesitelevel', 'block_course_menu'), get_string('namesiteleveldescription', 'block_course_menu'), block_course_menu::DEFAULT_SITE_LEVEL_TITLE));
$settings->add(new admin_setting_configcolourpicker('block_course_menu_docked_background', get_string('dockedbg', 'block_course_menu'), get_string('dockedbgdesc', 'block_course_menu'), block_course_menu::DEFAULT_DOCKED_BG));
$settings->add(new block_cm_admin_setting_confightml('global_config', '', '', '', $block));
}
示例11: cron
/**
* runs the survey at the specified time interval
* @param bool $manual
* @uses $CFG
* @uses $DB
*/
function cron($manual = false)
{
global $CFG, $DB;
$now = time();
$sql = "SELECT * FROM {block_instances}\n WHERE blockname = 'enrolsurvey' ";
// ***TBD***
$block_instances = $DB->get_records_sql($sql);
if (!empty($block_instances)) {
foreach ($block_instances as $survey) {
$block = block_instance('enrolsurvey', $survey);
if (!empty($block->config) && !empty($block->config->cron_time)) {
if (!isset($block->config->last_cron)) {
$block->config->last_cron = 0;
}
if ($block->config->last_cron + $block->config->cron_time <= $now) {
$block->config->last_cron = $now;
$DB->delete_records('block_enrolsurvey_taken', array('blockinstanceid' => $survey->id));
$block->instance_config_save($block->config);
}
}
}
}
return true;
}
示例12: foreach
collatorlib::asort($blocknames);
foreach ($blocknames as $blockid => $strblockname) {
$block = $blocks[$blockid];
$blockname = $block->name;
if (!file_exists("{$CFG->dirroot}/blocks/{$blockname}/block_{$blockname}.php")) {
$blockobject = false;
$strblockname = '<span class="notifyproblem">' . $strblockname . ' (' . get_string('missingfromdisk') . ')</span>';
$plugin = new stdClass();
$plugin->version = $block->version;
} else {
$plugin = new stdClass();
$plugin->version = '???';
if (file_exists("{$CFG->dirroot}/blocks/{$blockname}/version.php")) {
include "{$CFG->dirroot}/blocks/{$blockname}/version.php";
}
if (!($blockobject = block_instance($block->name))) {
$incompatible[] = $block;
continue;
}
}
$delete = '<a href="blocks.php?delete=' . $blockid . '&sesskey=' . sesskey() . '">' . $strdelete . '</a>';
$settings = '';
// By default, no configuration
if ($blockobject and $blockobject->has_config()) {
$blocksettings = admin_get_root()->locate('blocksetting' . $block->name);
if ($blocksettings instanceof admin_externalpage) {
$settings = '<a href="' . $blocksettings->url . '">' . get_string('settings') . '</a>';
} else {
if ($blocksettings instanceof admin_settingpage) {
$settings = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=blocksetting' . $block->name . '">' . $strsettings . '</a>';
} else {
示例13: create_block_instances
/**
* Create a set of new block instance from a record array
*
* @param array $birecords An array of block instance records
* @return array An array of instantiated block_instance objects
*/
protected function create_block_instances($birecords)
{
$results = array();
foreach ($birecords as $record) {
if ($blockobject = block_instance($record->blockname, $record, $this->page)) {
$results[] = $blockobject;
}
}
return $results;
}
示例14: get_plugin_name
/**
* Returns the language string for the given plugin.
*
* @param string $plugin the plugin code name
* @param string $type the type of plugin (mod, block, filter)
* @return string The plugin language string
*/
function get_plugin_name($plugin, $type = 'mod')
{
$plugin_name = '';
switch ($type) {
case 'mod':
$plugin_name = get_string('modulename', $plugin);
break;
case 'blocks':
$plugin_name = get_string('blockname', "block_{$plugin}");
if (empty($plugin_name) || $plugin_name == '[[blockname]]') {
if (($block = block_instance($plugin)) !== false) {
$plugin_name = $block->get_title();
} else {
$plugin_name = "[[{$plugin}]]";
}
}
break;
case 'filter':
$plugin_name = trim(get_string('filtername', $plugin));
if (empty($plugin_name) or $plugin_name == '[[filtername]]') {
$textlib = textlib_get_instance();
$plugin_name = $textlib->strtotitle($plugin);
}
break;
default:
$plugin_name = $plugin;
break;
}
return $plugin_name;
}
示例15: get_plugin_name
/**
* Returns the language string for the given plugin.
*
* @param string $plugin the plugin code name
* @param string $type the type of plugin (mod, block, filter)
* @return string The plugin language string
*/
function get_plugin_name($plugin, $type = 'mod')
{
$plugin_name = '';
switch ($type) {
case 'mod':
$plugin_name = get_string('modulename', $plugin);
break;
case 'blocks':
$plugin_name = get_string('pluginname', "block_{$plugin}");
if (empty($plugin_name) || $plugin_name == '[[pluginname]]') {
if (($block = block_instance($plugin)) !== false) {
$plugin_name = $block->get_title();
} else {
$plugin_name = "[[{$plugin}]]";
}
}
break;
case 'filter':
$plugin_name = filter_get_name('filter/' . $plugin);
break;
default:
$plugin_name = $plugin;
break;
}
return $plugin_name;
}