dongyi6845 2015-06-16 13:37
浏览 107
已采纳

Moodle消息阻止不显示新消息

I am using Moodle 2.9.

I have added the messages block to a moodle site and made it show on every page of the site. But after the users recieve new messages on the system (they show in their messages area of their profiles) the block just says "No messages waiting"??

Is there a problem with this block or is there a setting somewhere in moodle to activate this?

Any advice on this would be great!

It seems that message sent directly through the messages area are appearing in the block, but I am using a message_send() function from an Activity Mod and those messages do not appear in the block, but they appear in the messages section? Is there some code I am missing out?

$message = new \core\message\message();

$message->component = 'moodle';

$message->name = 'instantmessage';

$message->userfrom = $userfrom;

$message->userto = $userto;

$message->subject = 'Test';

$message->fullmessage = 'Test.';

$message->fullmessageformat = FORMAT_HTML;

$message->fullmessagehtml = '<p>Text</p>';

$message->smallmessage = '';

$message->notification = '1';

$message->contexturl = '';

$message->contexturlname = '';

$message->replyto = "";

$content = '';


$messageid = message_send($message);
  • 写回答

1条回答 默认 最新

  • duanhangjian8149 2015-06-30 09:13
    关注

    SOLVED

    The messages block only shows messages that are set to not notify. So the notification object needs to be set to "0", it will not show a popup in Moodle but it will appear in the block.

    Or you can change the block itself here to allow all messages to pass into the block no matter what the notification setting is: -

    moodle\blocks\messages\block_messages.php

    Change the SQL query on line 58 from: -

    $users = $DB->get_records_sql("SELECT $ufields, COUNT(m.useridfrom) AS count
                                             FROM {user} u, {message} m
                                            WHERE m.useridto = ? AND u.id = m.useridfrom AND m.notification = 0
                                         GROUP BY $ufields", array($USER->id));
    

    To

    $users = $DB->get_records_sql("SELECT $ufields, COUNT(m.useridfrom) AS count
                                             FROM {user} u, {message} m
                                            WHERE m.useridto = ? AND u.id = m.useridfrom
                                         GROUP BY $ufields", array($USER->id));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测