本文整理汇总了PHP中registration_manager::cron方法的典型用法代码示例。如果您正苦于以下问题:PHP registration_manager::cron方法的具体用法?PHP registration_manager::cron怎么用?PHP registration_manager::cron使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registration_manager
的用法示例。
在下文中一共展示了registration_manager::cron方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php';
$registrationmanager = new \registration_manager();
$registrationmanager->cron();
}
示例2: cron_run
/**
* Execute cron tasks
*/
function cron_run()
{
global $DB, $CFG, $OUTPUT;
if (CLI_MAINTENANCE) {
echo "CLI maintenance mode active, cron execution suspended.\n";
exit(1);
}
if (moodle_needs_upgrading()) {
echo "Moodle upgrade pending, cron execution suspended.\n";
exit(1);
}
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/gradelib.php';
if (!empty($CFG->showcronsql)) {
$DB->set_debug(true);
}
if (!empty($CFG->showcrondebugging)) {
set_debugging(DEBUG_DEVELOPER, true);
}
set_time_limit(0);
$starttime = microtime();
// Increase memory limit
raise_memory_limit(MEMORY_EXTRA);
// Emulate normal session - we use admin accoutn by default
cron_setup_user();
// Start output log
$timenow = time();
mtrace("Server Time: " . date('r', $timenow) . "\n\n");
// Run cleanup core cron jobs, but not every time since they aren't too important.
// These don't have a timer to reduce load, so we'll use a random number
// to randomly choose the percentage of times we should run these jobs.
$random100 = rand(0, 100);
if ($random100 < 20) {
// Approximately 20% of the time.
mtrace("Running clean-up tasks...");
cron_trace_time_and_memory();
// Delete users who haven't confirmed within required period
if (!empty($CFG->deleteunconfirmed)) {
$cuttime = $timenow - $CFG->deleteunconfirmed * 3600;
$rs = $DB->get_recordset_sql("SELECT *\n FROM {user}\n WHERE confirmed = 0 AND firstaccess > 0\n AND firstaccess < ?", array($cuttime));
foreach ($rs as $user) {
delete_user($user);
// we MUST delete user properly first
$DB->delete_records('user', array('id' => $user->id));
// this is a bloody hack, but it might work
mtrace(" Deleted unconfirmed user for " . fullname($user, true) . " ({$user->id})");
}
$rs->close();
}
// Delete users who haven't completed profile within required period
if (!empty($CFG->deleteincompleteusers)) {
$cuttime = $timenow - $CFG->deleteincompleteusers * 3600;
$rs = $DB->get_recordset_sql("SELECT *\n FROM {user}\n WHERE confirmed = 1 AND lastaccess > 0\n AND lastaccess < ? AND deleted = 0\n AND (lastname = '' OR firstname = '' OR email = '')", array($cuttime));
foreach ($rs as $user) {
if (isguestuser($user) or is_siteadmin($user)) {
continue;
}
delete_user($user);
mtrace(" Deleted not fully setup user {$user->username} ({$user->id})");
}
$rs->close();
}
// Delete old logs to save space (this might need a timer to slow it down...)
if (!empty($CFG->loglifetime)) {
// value in days
$loglifetime = $timenow - $CFG->loglifetime * 3600 * 24;
$DB->delete_records_select("log", "time < ?", array($loglifetime));
mtrace(" Deleted old log records");
}
// Delete old backup_controllers and logs.
$loglifetime = get_config('backup', 'loglifetime');
if (!empty($loglifetime)) {
// Value in days.
$loglifetime = $timenow - $loglifetime * 3600 * 24;
// Delete child records from backup_logs.
$DB->execute("DELETE FROM {backup_logs}\n WHERE EXISTS (\n SELECT 'x'\n FROM {backup_controllers} bc\n WHERE bc.backupid = {backup_logs}.backupid\n AND bc.timecreated < ?)", array($loglifetime));
// Delete records from backup_controllers.
$DB->execute("DELETE FROM {backup_controllers}\n WHERE timecreated < ?", array($loglifetime));
mtrace(" Deleted old backup records");
}
// Delete old cached texts
if (!empty($CFG->cachetext)) {
// Defined in config.php
$cachelifetime = time() - $CFG->cachetext - 60;
// Add an extra minute to allow for really heavy sites
$DB->delete_records_select('cache_text', "timemodified < ?", array($cachelifetime));
mtrace(" Deleted old cache_text records");
}
if (!empty($CFG->usetags)) {
require_once $CFG->dirroot . '/tag/lib.php';
tag_cron();
mtrace(' Executed tag cron');
}
// Context maintenance stuff
context_helper::cleanup_instances();
mtrace(' Cleaned up context instances');
context_helper::build_all_paths(false);
//.........这里部分代码省略.........
示例3: cron_run
/**
* Cron functions.
*
* @package core
* @subpackage admin
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function cron_run()
{
global $DB, $CFG, $OUTPUT;
if (CLI_MAINTENANCE) {
echo "CLI maintenance mode active, cron execution suspended.\n";
exit(1);
}
if (moodle_needs_upgrading()) {
echo "Moodle upgrade pending, cron execution suspended.\n";
exit(1);
}
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/gradelib.php';
if (!empty($CFG->showcronsql)) {
$DB->set_debug(true);
}
if (!empty($CFG->showcrondebugging)) {
$CFG->debug = DEBUG_DEVELOPER;
$CFG->debugdisplay = true;
}
set_time_limit(0);
$starttime = microtime();
/// increase memory limit
raise_memory_limit(MEMORY_EXTRA);
/// emulate normal session
cron_setup_user();
/// Start output log
$timenow = time();
mtrace("Server Time: " . date('r', $timenow) . "\n\n");
/// Session gc
mtrace("Cleaning up stale sessions");
session_gc();
/// Run all cron jobs for each module
mtrace("Starting activity modules");
get_mailer('buffer');
if ($mods = $DB->get_records_select("modules", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1", array($timenow))) {
foreach ($mods as $mod) {
$libfile = "{$CFG->dirroot}/mod/{$mod->name}/lib.php";
if (file_exists($libfile)) {
include_once $libfile;
$cron_function = $mod->name . "_cron";
if (function_exists($cron_function)) {
mtrace("Processing module function {$cron_function} ...", '');
$pre_dbqueries = null;
$pre_dbqueries = $DB->perf_get_queries();
$pre_time = microtime(1);
if ($cron_function()) {
$DB->set_field("modules", "lastcron", $timenow, array("id" => $mod->id));
}
if (isset($pre_dbqueries)) {
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
}
/// Reset possible changes by modules to time_limit. MDL-11597
@set_time_limit(0);
mtrace("done.");
}
}
}
}
get_mailer('close');
mtrace("Finished activity modules");
mtrace("Starting blocks");
if ($blocks = $DB->get_records_select("block", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1", array($timenow))) {
// we will need the base class.
require_once $CFG->dirroot . '/blocks/moodleblock.class.php';
foreach ($blocks as $block) {
$blockfile = $CFG->dirroot . '/blocks/' . $block->name . '/block_' . $block->name . '.php';
if (file_exists($blockfile)) {
require_once $blockfile;
$classname = 'block_' . $block->name;
$blockobj = new $classname();
if (method_exists($blockobj, 'cron')) {
mtrace("Processing cron function for " . $block->name . '....', '');
if ($blockobj->cron()) {
$DB->set_field('block', 'lastcron', $timenow, array('id' => $block->id));
}
/// Reset possible changes by blocks to time_limit. MDL-11597
@set_time_limit(0);
mtrace('done.');
}
}
}
}
mtrace('Finished blocks');
//now do plagiarism checks
require_once $CFG->libdir . '/plagiarismlib.php';
plagiarism_cron();
mtrace("Starting quiz reports");
if ($reports = $DB->get_records_select('quiz_report', "cron > 0 AND ((? - lastcron) > cron)", array($timenow))) {
foreach ($reports as $report) {
$cronfile = "{$CFG->dirroot}/mod/quiz/report/{$report->name}/cron.php";
//.........这里部分代码省略.........