简体   繁体   中英

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
  • 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)

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).

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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