本文整理汇总了PHP中events_cron函数的典型用法代码示例。如果您正苦于以下问题:PHP events_cron函数的具体用法?PHP events_cron怎么用?PHP events_cron使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了events_cron函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test__events_trigger__failed_instant
/**
* tests events_trigger funtion() when instant handler fails
*/
function test__events_trigger__failed_instant()
{
$this->assertEqual(1, events_trigger('test_instant', 'fail'), 'fail first event: %s');
$this->assertEqual(1, events_trigger('test_instant', 'ok'), 'this one should fail too: %s');
$this->assertEqual(0, events_cron('test_instant'), 'all events should stay in queue: %s');
$this->assertEqual(2, events_pending_count('test_instant'), 'two events should in queue: %s');
$this->assertEqual(0, sample_function_handler('status'), 'verify no event dispatched yet: %s');
sample_function_handler('ignorefail');
//ignore "fail" eventdata from now on
$this->assertEqual(1, events_trigger('test_instant', 'ok'), 'this one should go to queue directly: %s');
$this->assertEqual(3, events_pending_count('test_instant'), 'three events should in queue: %s');
$this->assertEqual(0, sample_function_handler('status'), 'verify previous event was not dispatched: %s');
$this->assertEqual(3, events_cron('test_instant'), 'all events should be dispatched: %s');
$this->assertEqual(3, sample_function_handler('status'), 'verify three events were dispatched: %s');
$this->assertEqual(0, events_pending_count('test_instant'), 'no events should in queue: %s');
$this->assertEqual(0, events_trigger('test_instant', 'ok'), 'this event should be dispatched immediately: %s');
$this->assertEqual(4, sample_function_handler('status'), 'verify event was dispatched: %s');
$this->assertEqual(0, events_pending_count('test_instant'), 'no events should in queue: %s');
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:22,代码来源:testeventslib.php
示例2: cron_run
//.........这里部分代码省略.........
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 . '....', '');
cron_trace_time_and_memory();
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');
mtrace('Starting admin reports');
cron_execute_plugin_type('report');
mtrace('Finished admin reports');
mtrace('Starting main gradebook job...');
cron_trace_time_and_memory();
grade_cron();
mtrace('done.');
mtrace('Starting processing the event queue...');
cron_trace_time_and_memory();
events_cron();
mtrace('done.');
if ($CFG->enablecompletion) {
// Completion cron
mtrace('Starting the completion cron...');
cron_trace_time_and_memory();
require_once $CFG->dirroot . '/completion/cron.php';
completion_cron();
mtrace('done');
}
if ($CFG->enableportfolios) {
// Portfolio cron
mtrace('Starting the portfolio cron...');
cron_trace_time_and_memory();
require_once $CFG->libdir . '/portfoliolib.php';
portfolio_cron();
mtrace('done');
}
//now do plagiarism checks
require_once $CFG->libdir . '/plagiarismlib.php';
plagiarism_cron();
mtrace('Starting course reports');
cron_execute_plugin_type('coursereport');
mtrace('Finished course reports');
// run gradebook import/export/report cron
mtrace('Starting gradebook plugins');
cron_execute_plugin_type('gradeimport');
cron_execute_plugin_type('gradeexport');
cron_execute_plugin_type('gradereport');
mtrace('Finished gradebook plugins');
// run calendar cron
require_once "{$CFG->dirroot}/calendar/lib.php";
calendar_cron();
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:67,代码来源:cronlib.php
示例3: cron_run
//.........这里部分代码省略.........
}
}
}
}
mtrace("Finished quiz reports");
mtrace('Starting admin reports');
// Admin reports do not have a database table that lists them. Instead a
// report includes cron.php with function report_reportname_cron() if it wishes
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
// actually do anything occasionally.
$reports = get_plugin_list('report');
foreach ($reports as $report => $reportdir) {
$cronfile = $reportdir . '/cron.php';
if (file_exists($cronfile)) {
require_once $cronfile;
$cronfunction = 'report_' . $report . '_cron';
mtrace('Processing cron function for ' . $report . '...', '');
$pre_dbqueries = null;
$pre_dbqueries = $DB->perf_get_queries();
$pre_time = microtime(true);
$cronfunction();
if (isset($pre_dbqueries)) {
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
}
mtrace('done.');
}
}
mtrace('Finished admin reports');
mtrace('Starting main gradebook job ...');
grade_cron();
mtrace('done.');
mtrace('Starting processing the event queue...');
events_cron();
mtrace('done.');
if ($CFG->enablecompletion) {
// Completion cron
mtrace('Starting the completion cron...');
require_once $CFG->libdir . '/completion/cron.php';
completion_cron();
mtrace('done');
}
if ($CFG->enableportfolios) {
// Portfolio cron
mtrace('Starting the portfolio cron...');
require_once $CFG->libdir . '/portfoliolib.php';
portfolio_cron();
mtrace('done');
}
/// Run all 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.
srand((double) microtime() * 10000000);
$random100 = rand(0, 100);
if ($random100 < 20) {
// Approximately 20% of the time.
mtrace("Running clean-up tasks...");
/// Delete users who haven't confirmed within required period
if (!empty($CFG->deleteunconfirmed)) {
$cuttime = $timenow - $CFG->deleteunconfirmed * 3600;
$rs = $DB->get_recordset_sql("SELECT id, firstname, lastname\n FROM {user}\n WHERE confirmed = 0 AND firstaccess > 0\n AND firstaccess < ?", array($cuttime));
foreach ($rs as $user) {
if ($DB->delete_records('user', array('id' => $user->id))) {
mtrace("Deleted unconfirmed user for " . fullname($user, true) . " ({$user->id})");
}
}
开发者ID:vuchannguyen,项目名称:web,代码行数:67,代码来源:cronlib.php
示例4: test_events_trigger__failed_instant
/**
* Tests events_trigger_legacy() function when instant handler fails.
*/
public function test_events_trigger__failed_instant()
{
global $CFG;
events_update_definition('unittest');
$this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
$olddebug = $CFG->debug;
$this->assertEquals(1, events_trigger_legacy('test_instant', 'fail'), 'fail first event: %s');
$this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
$this->assertEquals(1, events_trigger_legacy('test_instant', 'ok'), 'this one should fail too: %s');
$this->assertDebuggingNotCalled();
$this->assertEquals(0, events_cron('test_instant'), 'all events should stay in queue: %s');
// events_cron + one for each dispatched event.
$this->assertDebuggingCalledCount(3);
$this->assertEquals(2, events_pending_count('test_instant'), 'two events should in queue: %s');
$this->assertDebuggingCalled('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2' . ' API, please use it instead.', DEBUG_DEVELOPER);
$this->assertEquals(0, eventslib_sample_function_handler('status'), 'verify no event dispatched yet: %s');
eventslib_sample_function_handler('ignorefail');
// Ignore "fail" eventdata from now on.
$this->assertEquals(1, events_trigger_legacy('test_instant', 'ok'), 'this one should go to queue directly: %s');
$this->assertDebuggingNotCalled();
$this->assertEquals(3, events_pending_count('test_instant'), 'three events should in queue: %s');
$this->assertDebuggingCalled('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2' . ' API, please use it instead.', DEBUG_DEVELOPER);
$this->assertEquals(0, eventslib_sample_function_handler('status'), 'verify previous event was not dispatched: %s');
$this->assertEquals(3, events_cron('test_instant'), 'all events should be dispatched: %s');
// events_cron + one for each dispatched event.
$this->assertDebuggingCalledCount(4);
$this->assertEquals(3, eventslib_sample_function_handler('status'), 'verify three events were dispatched: %s');
$this->assertEquals(0, events_pending_count('test_instant'), 'no events should in queue: %s');
$this->assertDebuggingCalled('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2' . ' API, please use it instead.', DEBUG_DEVELOPER);
$this->assertEquals(0, events_trigger_legacy('test_instant', 'ok'), 'this event should be dispatched immediately: %s');
$this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
$this->assertEquals(4, eventslib_sample_function_handler('status'), 'verify event was dispatched: %s');
$this->assertEquals(0, events_pending_count('test_instant'), 'no events should in queue: %s');
$this->assertDebuggingCalled('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2' . ' API, please use it instead.', DEBUG_DEVELOPER);
}
开发者ID:evltuma,项目名称:moodle,代码行数:38,代码来源:eventslib_test.php
示例5: get_recordset_sql
$rs_enrol = get_recordset_sql("SELECT ra.roleid, ra.userid, ra.contextid\n FROM {$CFG->prefix}course c\n INNER JOIN {$CFG->prefix}context cx ON cx.instanceid = c.id\n INNER JOIN {$CFG->prefix}role_assignments ra ON ra.contextid = cx.id\n WHERE cx.contextlevel = '" . CONTEXT_COURSE . "'\n AND ra.timeend > 0\n AND ra.timeend < '{$timenow}'\n AND c.enrolperiod > 0\n ");
while ($oldenrolment = rs_fetch_next_record($rs_enrol)) {
role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid);
$somefound = true;
}
rs_close($rs_enrol);
if ($somefound) {
mtrace('Done');
} else {
mtrace('none found');
}
mtrace('Starting main gradebook job ...');
grade_cron();
mtrace('done.');
mtrace('Starting processing the event queue...');
events_cron();
mtrace('done.');
/// Run all 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.
srand((double) microtime() * 10000000);
$random100 = rand(0, 100);
if ($random100 < 20) {
// Approximately 20% of the time.
mtrace("Running clean-up tasks...");
/// Unenrol users who haven't logged in for $CFG->longtimenosee
if ($CFG->longtimenosee) {
// value in days
$cuttime = $timenow - $CFG->longtimenosee * 3600 * 24;
$rs = get_recordset_sql("SELECT id, userid, courseid\n FROM {$CFG->prefix}user_lastaccess\n WHERE courseid != " . SITEID . "\n AND timeaccess < {$cuttime} ");
while ($assign = rs_fetch_next_record($rs)) {
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:cron.php
示例6: test_events_trigger__failed_instant
/**
* Tests events_trigger_legacy() function when instant handler fails.
*/
public function test_events_trigger__failed_instant()
{
global $CFG;
$olddebug = $CFG->debug;
$this->assertEquals(1, events_trigger_legacy('test_instant', 'fail'), 'fail first event: %s');
$this->assertEquals(1, events_trigger_legacy('test_instant', 'ok'), 'this one should fail too: %s');
$this->assertEquals(0, events_cron('test_instant'), 'all events should stay in queue: %s');
$this->assertDebuggingCalled();
$this->assertEquals(2, events_pending_count('test_instant'), 'two events should in queue: %s');
$this->assertEquals(0, eventslib_sample_function_handler('status'), 'verify no event dispatched yet: %s');
eventslib_sample_function_handler('ignorefail');
// Ignore "fail" eventdata from now on.
$this->assertEquals(1, events_trigger_legacy('test_instant', 'ok'), 'this one should go to queue directly: %s');
$this->assertEquals(3, events_pending_count('test_instant'), 'three events should in queue: %s');
$this->assertEquals(0, eventslib_sample_function_handler('status'), 'verify previous event was not dispatched: %s');
$this->assertEquals(3, events_cron('test_instant'), 'all events should be dispatched: %s');
$this->assertEquals(3, eventslib_sample_function_handler('status'), 'verify three events were dispatched: %s');
$this->assertEquals(0, events_pending_count('test_instant'), 'no events should in queue: %s');
$this->assertEquals(0, events_trigger_legacy('test_instant', 'ok'), 'this event should be dispatched immediately: %s');
$this->assertEquals(4, eventslib_sample_function_handler('status'), 'verify event was dispatched: %s');
$this->assertEquals(0, events_pending_count('test_instant'), 'no events should in queue: %s');
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:25,代码来源:eventslib_test.php
示例7: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
events_cron();
}
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:events_cron_task.php
注:本文中的events_cron函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论