本文整理汇总了PHP中block_method_result函数的典型用法代码示例。如果您正苦于以下问题:PHP block_method_result函数的具体用法?PHP block_method_result怎么用?PHP block_method_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了block_method_result函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display()
{
global $PAGE, $COURSE;
$editing = $PAGE->user_is_editing();
$pageblocks = page_blocks_setup();
/// Make sure we can see this page
if (!($this->page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $this->context) and $editing)) {
error(get_string('thispageisnotpublished', 'format_page'));
}
/// Finally, we can print the page
if ($editing) {
$PAGE->print_tabs('layout');
page_print_jump_menu();
page_print_add_mods_form($this->page, $COURSE);
$class = 'format-page editing';
} else {
$class = 'format-page';
}
echo '<table id="layout-table" class="' . $class . '" cellspacing="0" summary="' . get_string('layouttable') . '">';
/// Check if the page is locked, if so, print lock message, otherwise print three columns
if (page_is_locked($this->page)) {
echo '<tr><td colspan="3">';
page_print_lock_prerequisites($this->page);
echo '</tr></td>';
} else {
echo '<tr>';
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT)) {
page_print_position($pageblocks, BLOCK_POS_LEFT, $this->page->prefleftwidth);
}
page_print_position($pageblocks, BLOCK_POS_CENTER, '100%');
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
page_print_position($pageblocks, BLOCK_POS_RIGHT, $this->page->prefrightwidth);
}
echo '</tr>';
}
/// Silently attempts to call a function from the block_recent_history block
@block_method_result('recent_history', 'block_recent_history_record', $this->page);
/// Display navigation buttons
if ($this->page->showbuttons) {
$nav = page_get_next_previous_pages($this->page->id, $this->page->courseid);
$buttons = '';
if ($nav->prev and $this->page->showbuttons & BUTTON_PREV) {
$title = get_string('previous', 'format_page', page_get_name($nav->prev));
$buttons .= '<span class="prevpage"><a href="' . $PAGE->url_build('page', $nav->prev->id) . "\" title=\"{$title}\">{$title}</a></span>";
}
if ($nav->next and $this->page->showbuttons & BUTTON_NEXT) {
$title = get_string('next', 'format_page', page_get_name($nav->next));
$buttons .= '<span class="nextpage"><a href="' . $PAGE->url_build('page', $nav->next->id) . "\" title=\"{$title}\">{$title}</a></span>";
}
// Make sure we have something to print
if (!empty($buttons)) {
echo "\n<tr><td></td><td>{$buttons}</td><td></td></tr>\n";
}
}
echo '</table>';
}
示例2: get_capabilities
/**
* Returns array of relevant context capability records.
*
* @return array
*/
public function get_capabilities()
{
global $DB;
$sort = 'ORDER BY contextlevel,component,name';
// To group them sensibly for display
$params = array();
$bi = $DB->get_record('block_instances', array('id' => $this->_instanceid));
$extra = '';
$extracaps = block_method_result($bi->blockname, 'get_extra_capabilities');
if ($extracaps) {
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap');
$extra = "OR name {$extra}";
}
$sql = "SELECT *\n FROM {capabilities}\n WHERE (contextlevel = " . CONTEXT_BLOCK . "\n AND component = :component)\n {$extra}";
$params['component'] = 'block_' . $bi->blockname;
return $DB->get_records_sql($sql . ' ' . $sort, $params);
}
示例3: process_block
public function process_block($data) {
global $DB, $CFG;
$data = (object)$data; // Handy
$oldcontextid = $data->contextid;
$oldid = $data->id;
$positions = isset($data->block_positions['block_position']) ? $data->block_positions['block_position'] : array();
// Look for the parent contextid
if (!$data->parentcontextid = $this->get_mappingid('context', $data->parentcontextid)) {
throw new restore_step_exception('restore_block_missing_parent_ctx', $data->parentcontextid);
}
// TODO: it would be nice to use standard plugin supports instead of this instance_allow_multiple()
// If there is already one block of that type in the parent context
// and the block is not multiple, stop processing
// Use blockslib loader / method executor
if (!block_method_result($data->blockname, 'instance_allow_multiple')) {
if ($DB->record_exists_sql("SELECT bi.id
FROM {block_instances} bi
JOIN {block} b ON b.name = bi.blockname
WHERE bi.parentcontextid = ?
AND bi.blockname = ?", array($data->parentcontextid, $data->blockname))) {
return false;
}
}
// If there is already one block of that type in the parent context
// with the same showincontexts, pagetypepattern, subpagepattern, defaultregion and configdata
// stop processing
$params = array(
'blockname' => $data->blockname, 'parentcontextid' => $data->parentcontextid,
'showinsubcontexts' => $data->showinsubcontexts, 'pagetypepattern' => $data->pagetypepattern,
'subpagepattern' => $data->subpagepattern, 'defaultregion' => $data->defaultregion);
if ($birecs = $DB->get_records('block_instances', $params)) {
foreach($birecs as $birec) {
if ($birec->configdata == $data->configdata) {
return false;
}
}
}
// Set task old contextid, blockid and blockname once we know them
$this->task->set_old_contextid($oldcontextid);
$this->task->set_old_blockid($oldid);
$this->task->set_blockname($data->blockname);
// Let's look for anything within configdata neededing processing
// (nulls and uses of legacy file.php)
if ($attrstotransform = $this->task->get_configdata_encoded_attributes()) {
$configdata = (array)unserialize(base64_decode($data->configdata));
foreach ($configdata as $attribute => $value) {
if (in_array($attribute, $attrstotransform)) {
$configdata[$attribute] = $this->contentprocessor->process_cdata($value);
}
}
$data->configdata = base64_encode(serialize((object)$configdata));
}
// Create the block instance
$newitemid = $DB->insert_record('block_instances', $data);
// Save the mapping (with restorefiles support)
$this->set_mapping('block_instance', $oldid, $newitemid, true);
// Create the block context
$newcontextid = get_context_instance(CONTEXT_BLOCK, $newitemid)->id;
// Save the block contexts mapping and sent it to task
$this->set_mapping('context', $oldcontextid, $newcontextid);
$this->task->set_contextid($newcontextid);
$this->task->set_blockid($newitemid);
// Restore block fileareas if declared
$component = 'block_' . $this->task->get_blockname();
foreach ($this->task->get_fileareas() as $filearea) { // Simple match by contextid. No itemname needed
$this->add_related_files($component, $filearea, null);
}
// Process block positions, creating them or accumulating for final step
foreach($positions as $position) {
$position = (object)$position;
$position->blockinstanceid = $newitemid; // The instance is always the restored one
// If position is for one already mapped (known) contextid
// process it now, creating the position
if ($newpositionctxid = $this->get_mappingid('context', $position->contextid)) {
$position->contextid = $newpositionctxid;
// Create the block position
$DB->insert_record('block_positions', $position);
// The position belongs to an unknown context, send it to backup_ids
// to process them as part of the final steps of restore. We send the
// whole $position object there, hence use the low level method.
} else {
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'block_position', $position->id, 0, null, $position);
}
}
}
示例4: blocks_execute_action
//.........这里部分代码省略.........
}
$other = $pageblocks[$instance->position][$instanceindex + 1];
}
if (!empty($other)) {
--$other->weight;
if (!empty($pinned)) {
update_record('block_pinned', $other);
} else {
update_record('block_instance', $other);
}
}
++$instance->weight;
if (!empty($pinned)) {
update_record('block_pinned', $instance);
} else {
update_record('block_instance', $instance);
}
}
break;
case 'moveleft':
if (empty($instance)) {
error('Invalid block instance for ' . $blockaction);
}
// Where is the instance going to be moved?
$newpos = $page->blocks_move_position($instance, BLOCK_MOVE_LEFT);
$newweight = 0;
if (!empty($pinned) && !empty($pageblocks[$newpos])) {
$newweight = $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))]->weight + 1;
} else {
if (!empty($pageblocks[$newpos]) && !array_key_exists('pinned', $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))])) {
$newweight = $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))]->weight + 1;
}
}
blocks_execute_repositioning($instance, $newpos, $newweight, $pinned);
break;
case 'moveright':
if (empty($instance)) {
error('Invalid block instance for ' . $blockaction);
}
// Where is the instance going to be moved?
$newpos = $page->blocks_move_position($instance, BLOCK_MOVE_RIGHT);
$newweight = 0;
if (!empty($pinned) && !empty($pageblocks[$newpos])) {
$newweight = $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))]->weight + 1;
} else {
if (!empty($pageblocks[$newpos]) && !array_key_exists('pinned', $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))])) {
$newweight = $pageblocks[$newpos][max(array_keys($pageblocks[$newpos]))]->weight + 1;
}
}
blocks_execute_repositioning($instance, $newpos, $newweight, $pinned);
break;
case 'add':
// Add a new instance of this block, if allowed
$block = blocks_get_record($blockid);
if (empty($block) || !$block->visible) {
// Only allow adding if the block exists and is enabled
break;
}
if (!$block->multiple && blocks_find_block($blockid, $pageblocks) !== false) {
// If no multiples are allowed and we already have one, return now
break;
}
if (!block_method_result($block->name, 'user_can_addto', $page)) {
// If the block doesn't want to be added...
break;
}
$newpos = $page->blocks_default_position();
if (!empty($pinned)) {
$sql = 'SELECT 1, max(weight) + 1 AS nextfree FROM ' . $CFG->prefix . 'block_pinned WHERE ' . ' pagetype = \'' . $page->get_type() . '\' AND position = \'' . $newpos . '\'';
} else {
$sql = 'SELECT 1, max(weight) + 1 AS nextfree FROM ' . $CFG->prefix . 'block_instance WHERE pageid = ' . $page->get_id() . ' AND pagetype = \'' . $page->get_type() . '\' AND position = \'' . $newpos . '\'';
}
$weight = get_record_sql($sql);
$newinstance = new stdClass();
$newinstance->blockid = $blockid;
if (empty($pinned)) {
$newinstance->pageid = $page->get_id();
}
$newinstance->pagetype = $page->get_type();
$newinstance->position = $newpos;
$newinstance->weight = empty($weight->nextfree) ? 0 : $weight->nextfree;
$newinstance->visible = 1;
$newinstance->configdata = '';
if (!empty($pinned)) {
$newinstance->id = insert_record('block_pinned', $newinstance);
} else {
$newinstance->id = insert_record('block_instance', $newinstance);
}
// If the new instance was created, allow it to do additional setup
if ($newinstance && ($obj = block_instance($block->name, $newinstance))) {
// Return value ignored
$obj->instance_create();
}
break;
}
if ($redirect) {
// In order to prevent accidental duplicate actions, redirect to a page with a clean url
redirect($page->url_get_full());
}
}
示例5: block_method_result
* Copyright (C) 2009 Moodlerooms Inc.
*
* 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://opensource.org/licenses/gpl-3.0.html.
*
* @copyright Copyright (c) 2009 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @author Mark Nielsen
*/
/**
* Serves pages for the Google Data Block
*
* @author Mark Nielsen
* @version $Id$
* @package block_gdata
**/
require_once '../../config.php';
require_once $CFG->libdir . '/blocklib.php';
$PAGE->set_url($CFG->wwwroot . '/blocks/gdata/index.php');
block_method_result('gdata', 'view');
示例6: fetch_context_capabilities
/**
* Extracts the relevant capabilities given a contextid.
* All case based, example an instance of forum context.
* Will fetch all forum related capabilities, while course contexts
* Will fetch all capabilities
* @param object context
* @return array();
*
* capabilities
* `name` varchar(150) NOT NULL,
* `captype` varchar(50) NOT NULL,
* `contextlevel` int(10) NOT NULL,
* `component` varchar(100) NOT NULL,
*/
function fetch_context_capabilities($context)
{
global $DB, $CFG;
$sort = 'ORDER BY contextlevel,component,name';
// To group them sensibly for display
$params = array();
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
// all
$SQL = "SELECT *\n FROM {capabilities}";
break;
case CONTEXT_USER:
$extracaps = array('moodle/grade:viewall');
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
$SQL = "SELECT *\n FROM {capabilities}\n WHERE contextlevel = " . CONTEXT_USER . "\n OR name {$extra}";
break;
case CONTEXT_COURSECAT:
// course category context and bellow
$SQL = "SELECT *\n FROM {capabilities}\n WHERE contextlevel IN (" . CONTEXT_COURSECAT . "," . CONTEXT_COURSE . "," . CONTEXT_MODULE . "," . CONTEXT_BLOCK . ")";
break;
case CONTEXT_COURSE:
// course context and bellow
$SQL = "SELECT *\n FROM {capabilities}\n WHERE contextlevel IN (" . CONTEXT_COURSE . "," . CONTEXT_MODULE . "," . CONTEXT_BLOCK . ")";
break;
case CONTEXT_MODULE:
// mod caps
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
$module = $DB->get_record('modules', array('id' => $cm->module));
$modfile = "{$CFG->dirroot}/mod/{$module->name}/lib.php";
if (file_exists($modfile)) {
include_once $modfile;
$modfunction = $module->name . '_get_extra_capabilities';
if (function_exists($modfunction)) {
$extracaps = $modfunction();
}
}
if (empty($extracaps)) {
$extracaps = array();
}
// All modules allow viewhiddenactivities. This is so you can hide
// the module then override to allow specific roles to see it.
// The actual check is in course page so not module-specific
$extracaps[] = "moodle/course:viewhiddenactivities";
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
$extra = "OR name {$extra}";
$SQL = "SELECT *\n FROM {capabilities}\n WHERE (contextlevel = " . CONTEXT_MODULE . "\n AND component = :component)\n {$extra}";
$params['component'] = "mod/{$module->name}";
break;
case CONTEXT_BLOCK:
// block caps
$bi = $DB->get_record('block_instances', array('id' => $context->instanceid));
$extra = '';
$extracaps = block_method_result($bi->blockname, 'get_extra_capabilities');
if ($extracaps) {
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
$extra = "OR name {$extra}";
}
$SQL = "SELECT *\n FROM {capabilities}\n WHERE (contextlevel = " . CONTEXT_BLOCK . "\n AND component = :component)\n {$extra}";
$params['component'] = 'block/' . $bi->blockname;
break;
default:
return false;
}
if (!($records = $DB->get_records_sql($SQL . ' ' . $sort, $params))) {
$records = array();
}
return $records;
}
示例7: 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;
}
示例8: page_blocks_execute_url_action
/**
* Same functionality as blocks_execute_url_action()
* Handle all block actions ourselves.
*
* @param boolean $redirect (Optional) Redirect after action
* @return void
**/
function page_blocks_execute_url_action($redirect = true)
{
global $CFG, $COURSE, $PAGE;
$pageitemid = optional_param('pageitemid', 0, PARAM_INT);
$blockaction = optional_param('blockaction', '', PARAM_ALPHA);
// Reasons to stop right meow
if (empty($blockaction) || !$PAGE->user_allowed_editing() || !confirm_sesskey()) {
return;
}
// Make sure if we have a valid pageitem.
if ($pageitemid and !($pageitem = get_record('format_page_items', 'id', $pageitemid))) {
return;
}
switch ($blockaction) {
case 'config':
if (empty($pageitem->blockinstance) and !empty($pageitem->cmid)) {
// Its a module - go to module update
redirect("{$CFG->wwwroot}/course/mod.php?update={$pageitem->cmid}&sesskey=" . sesskey());
} else {
if (!empty($pageitem->blockinstance)) {
// Its a block instance - allow core routine to handle
redirect($PAGE->url_build('instanceid', $pageitem->blockinstance, 'blockaction', 'config', 'sesskey', sesskey()));
} else {
error('Invalid page item to configure');
}
}
break;
case 'toggle':
$update = new stdClass();
$update->id = $pageitem->id;
if (empty($pageitem->visible)) {
$update->visible = 1;
} else {
$update->visible = 0;
}
update_record('format_page_items', $update);
break;
case 'delete':
page_block_delete($pageitem);
break;
case 'moveup':
page_block_move($pageitem, $pageitem->position, $pageitem->sortorder - 1);
break;
case 'movedown':
page_block_move($pageitem, $pageitem->position, $pageitem->sortorder + 1);
break;
case 'moveright':
$destposition = $PAGE->blocks_move_position($pageitem, BLOCK_MOVE_RIGHT);
$destweight = page_get_next_weight($pageitem->pageid, $destposition);
page_block_move($pageitem, $destposition, $destweight);
break;
case 'moveleft':
$destposition = $PAGE->blocks_move_position($pageitem, BLOCK_MOVE_LEFT);
$destweight = page_get_next_weight($pageitem->pageid, $destposition);
page_block_move($pageitem, $destposition, $destweight);
break;
case 'addmod':
// Right now, modules are added differently
$instance = required_param('instance', PARAM_INT);
$record = new stdClass();
$record->pageid = $PAGE->formatpage->id;
$record->cmid = $instance;
$record->blockinstance = 0;
$record->position = $PAGE->blocks_default_position();
$record->sortorder = page_get_next_weight($record->pageid, $record->position);
insert_record('format_page_items', $record);
break;
case 'add':
// Add a block instance and a pageitem
$blockid = required_param('blockid', PARAM_INT);
$block = blocks_get_record($blockid);
if (empty($block) or !$block->visible) {
break;
}
if (!block_method_result($block->name, 'user_can_addto', $PAGE)) {
break;
}
// Add a block instance if one does not already exist or if the block allows multiple block instances
$exists = record_exists('block_instance', 'pageid', $PAGE->get_id(), 'pagetype', $PAGE->get_type(), 'blockid', $blockid);
if ($block->multiple || !$exists) {
// Get the next weight value NOTE: hard code left position
$weight = get_record_sql('SELECT 1, MAX(weight) + 1 ' . sql_as() . ' nextfree
FROM ' . $CFG->prefix . 'block_instance
WHERE pageid = ' . $PAGE->get_id() . '
AND pagetype = \'' . $PAGE->get_type() . '\'
AND position = \'' . BLOCK_POS_LEFT . '\'');
if (empty($weight->nextfree)) {
$weight->nextfree = 0;
}
$newinstance = new stdClass();
$newinstance->blockid = $blockid;
$newinstance->pageid = $PAGE->get_id();
$newinstance->pagetype = $PAGE->get_type();
//.........这里部分代码省略.........
示例9: page_theme_get_tab_menu
/**
* Gets the tab menu from the course_menu block
*
* @return mixed
**/
function page_theme_get_tab_menu()
{
global $CFG, $COURSE;
static $tabmenus;
if (!isset($tabmenus)) {
$tabmenus = array();
if ($pagemenus = get_records_sql("SELECT c.id, c.instance, c.visible, p.name\n FROM {$CFG->prefix}pagemenu p,\n {$CFG->prefix}course_modules c,\n {$CFG->prefix}modules m\n WHERE c.instance = p.id\n AND m.id = c.module\n AND m.name = 'pagemenu'\n AND p.course = {$COURSE->id}\n AND p.useastab = 1\n ORDER BY p.taborder, p.name")) {
require_once $CFG->dirroot . '/mod/pagemenu/locallib.php';
if ($menuinfos = pagemenu_build_menus($pagemenus, true, true, $COURSE->id)) {
$count = 0;
foreach ($menuinfos as $cmid => $menuinfo) {
if (isset($menuinfo->menuitems[0])) {
$tablink = $menuinfo->menuitems[0]->url;
} else {
$tablink = '#';
}
$tabmenu = new stdClass();
$tabmenu->active = $menuinfo->active;
$tabmenu->id = 'menutree' . $count;
$tabmenu->name = format_string($pagemenus[$cmid]->name);
$tabmenu->tablink = $tablink;
$tabmenu->menuhtml = $menuinfo->html;
$tabmenus[] = $tabmenu;
$count++;
}
}
} else {
// Legacy
require_once $CFG->libdir . '/blocklib.php';
require_once $CFG->dirroot . '/course/format/page/lib.php';
if ($tabmenu = block_method_result('course_menu', 'get_tab_menu', 'menutree')) {
$tabmenu->id = 'menutree0';
$tabmenu->tablink = '#';
$tabmenu->menuhtml = "<div class=\"bd\">\n{$tabmenu->menuhtml}</div>\n";
$tabmenus[] = $tabmenu;
}
}
}
return $tabmenus;
}
示例10: notify
notify('You do not have permission for RAFL View on this learning path. Please switch back to Standard View.');
echo '</td>';
echo '<td id="right-column"></td>';
echo '</tr>';
}
} else {
// standard mode
/// Layout the whole page as three columns.
echo '<tr>';
page_print_position($pageblocks, BLOCK_POS_LEFT, null);
page_print_position($pageblocks, BLOCK_POS_CENTER, null);
page_print_position($pageblocks, BLOCK_POS_RIGHT, null);
echo '</tr>';
}
/// Silently attempts to call a function from the block_recent_history block
@block_method_result('recent_history', 'block_recent_history_record', $page);
/// Display navigation buttons
if ($page->showbuttons && !$USER->raflmode) {
$nav = page_get_next_previous_pages($page->id, $page->courseid);
$buttons = '';
if ($nav->prev and $page->showbuttons & BUTTON_PREV) {
$buttons .= '<span class="prevpage"><a href="' . $PAGE->url_build('page', $nav->prev->id) . '">' . get_string('previous', 'format_page', page_get_name($nav->prev)) . '</a></span>';
}
if ($completion_link) {
$buttons .= '<span class="completion">' . $completion_link . '</span>';
}
if ($overview_link) {
$buttons .= '<span class="overview">' . $overview_link . '</span>';
}
if ($nav->next and $page->showbuttons & BUTTON_NEXT) {
$buttons .= '<span class="nextpage"><a href="' . $PAGE->url_build('page', $nav->next->id) . '">' . get_string('next', 'format_page', page_get_name($nav->next)) . '</a></span>';
示例11: dirname
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @author Mark Nielsen
*/
/**
* Cron file - cannot run this block's
* cron on the main cron because it conflicts
* with /search/Zend
*
* @author Mark Nielsen
* @version $Id$
* @package blocks_gdata
**/
$nomoodlecookie = true;
// cookie not needed
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
// global moodle config file.
require_once $CFG->libdir . '/blocklib.php';
set_time_limit(0);
$starttime = microtime();
$timenow = time();
if ($block = $DB->get_record_select("block", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1 AND name = 'gdata'", array($timenow))) {
if (block_method_result('gdata', 'cron_alt')) {
if (!$DB->set_field('block', 'lastcron', $timenow, array('id' => $block->id))) {
mtrace('Error: could not update timestamp for ' . $block->name);
}
}
} else {
mtrace('Not time to run gdata block cron');
}
$difftime = microtime_diff($starttime, microtime());
mtrace("Execution took " . $difftime . " seconds");