本文整理汇总了PHP中chat_update_chat_times函数的典型用法代码示例。如果您正苦于以下问题:PHP chat_update_chat_times函数的具体用法?PHP chat_update_chat_times怎么用?PHP chat_update_chat_times使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chat_update_chat_times函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: chat_cron
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @global object
* @return bool
*/
function chat_cron()
{
global $DB;
chat_update_chat_times();
chat_delete_old_users();
/// Delete old messages with a
/// single SQL query.
$subselect = "SELECT c.keepdays\n FROM {chat} c\n WHERE c.id = {chat_messages}.chatid";
$sql = "DELETE\n FROM {chat_messages}\n WHERE ({$subselect}) > 0 AND timestamp < ( " . time() . " -({$subselect}) * 24 * 3600)";
$DB->execute($sql);
$sql = "DELETE\n FROM {chat_messages_current}\n WHERE timestamp < ( " . time() . " - 8 * 3600)";
$DB->execute($sql);
return true;
}
示例2: print_error
if (! $cm = get_coursemodule_from_id('chat', $id)) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
print_error('coursemisconf');
}
chat_update_chat_times($cm->instance);
if (! $chat = $DB->get_record('chat', array('id'=>$cm->instance))) {
print_error('invalidid', 'chat');
}
} else {
chat_update_chat_times($c);
if (! $chat = $DB->get_record('chat', array('id'=>$c))) {
print_error('coursemisconf');
}
if (! $course = $DB->get_record('course', array('id'=>$chat->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
print_error('invalidcoursemodule');
}
}
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
示例3: chat_cron
function chat_cron()
{
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
global $CFG;
chat_update_chat_times();
chat_delete_old_users();
/// Delete old messages
if ($chats = get_records("chat")) {
foreach ($chats as $chat) {
if ($chat->keepdays) {
$timeold = time() - $chat->keepdays * 24 * 3600;
delete_records_select("chat_messages", "chatid = '{$chat->id}' AND timestamp < '{$timeold}'");
}
}
}
return true;
}
示例4: chat_cron
function chat_cron()
{
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
global $CFG;
chat_update_chat_times();
chat_delete_old_users();
/// Delete old messages
$sql = "SELECT m.id \n FROM {$CFG->prefix}chat_messages m \n JOIN {$CFG->prefix}chat c\n ON m.chatid = c.id\n WHERE c.keepdays != 0 \n AND m.timestamp < ( " . time() . " - c.keepdays * 24 * 3600)";
delete_records_select("chat_messages", "id IN ({$sql})");
return true;
}
示例5: chat_cron
function chat_cron()
{
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
global $DB;
chat_update_chat_times();
chat_delete_old_users();
/// Delete old messages with a
/// single SQL query.
$subselect = "SELECT c.keepdays\n FROM {chat} c\n WHERE c.id = {chat_messages}.chatid";
$sql = "DELETE\n FROM {chat_messages}\n WHERE ({$subselect}) > 0 AND timestamp < ( " . time() . " -({$subselect}) * 24 * 3600)";
$DB->execute($sql);
$sql = "DELETE\n FROM {chat_messages_current}\n WHERE timestamp < ( " . time() . " - 8 * 3600)";
$DB->execute($sql);
return true;
}