简体   繁体   English

Moodle-扩展现有插件

[英]Moodle - extending an existing plugin

I would like to add a functionality to the existing forum plugin. 我想向现有的论坛插件添加功能。 The functionality I want is that I can select a published date when creating a post in a forum. 我想要的功能是在论坛中创建帖子时可以选择发布日期 When I select a date a week in the future, the post will be published (and shown to the user) a week in the future. 当我选择未来一周的日期时,该帖子将在未来一周的某个时间发布(并显示给用户)。

I think the following need to happen: 我认为需要发生以下情况:

  • Add a published_date field to table mdl_forum_posts 在表mdl_forum_posts中添加一个published_date字段
  • Change query that shows the posts in the forum (select posts where published date is in the past) 更改查询以显示论坛中的帖子(选择发布日期为过去的帖子)
  • Change cron that sends notifications of forum posts (that only published posts will be sent) 更改发送论坛帖子通知的cron(仅发送已发布的帖子)

Now I'm wondering if there's already a plugin that provides this functionality. 现在,我想知道是否已经有一个提供此功能的插件。 I've searched in plugins but couldn't find any with this functionality. 我已经搜索了插件,但找不到与此功能的任何插件。

And how can I code this functionality? 以及如何编码此功能? I don't think it's good to overwrite the core code of the plugin. 我认为覆盖插件的核心代码不是很好。 How can I extend this plugin with clean structure/code? 如何使用干净的结构/代码扩展此插件?

Can you help me on my way? 您能帮我吗?

The only way to add that functionality directly into the forum without changing the core code would be to make a complete copy of the forum module, rename it and then add your functionality to the copy (users would have to switch to this new version of the forum). 将功能直接添加到论坛而不更改核心代码的唯一方法是制作论坛模块的完整副本,对其进行重命名,然后将功能添加到副本中(用户必须切换到此新版本的论坛)。

In my experience, doing that will result in much more future maintenance problems than making small, careful core changes (then using git rebase to merge the changes in the future). 以我的经验,这样做将导致未来的维护问题,而不是进行小的,仔细的核心更改(然后使用git rebase将来合并更改)。

The alternative might be a separate plugin that allows you to enter a post + a date and which will insert that post into the forum activity at the scheduled time (this could be in the form of a block, on the side of the page, or a local plugin that inserts a link into the forum settings, then takes you off to a separate page to do the scheduling). 替代方法可能是单独的插件,该插件可让您输入帖子+日期,并将该帖子按计划的时间插入论坛活动中(这可以是页面侧面的块形式,或者一个本地插件,该插件会在论坛设置中插入一个链接,然后将您带到单独的页面进行安排)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM