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));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 数字信号处理实验报告
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程