Add-ons
  1. Add-ons
  2. CONTRIB-2087

ForumNG: Auto archive/delete old discussions (OU 9779)

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.8
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      22084

      Description

      1) New options on forum settings form - a heading with 2 dropdowns

      – Remove old discussions – (heading)

      Remove old discussions after [ ]

      Never remove [default]
      1 month
      2 months
      ...
      11 months
      1 year
      2 years
      3 years

      With removed discussions [ ]

      Delete permanently [default]
      Move to:
      Some other forum on this course
      Another forum on this course
      Yet another forum on this course

      These options need to be stored in forumng table in 2 extra columns:

      removeafter = int(10) default 0; number of seconds to remove old discussions after; 0 = do not remove

      removeto = int(10); target forum to remove old discussions to; null = delete old discussions

      2) Add new admin setting forumng/housekeepingstarthour and forumng/housekeepingstophour. These go on the forumng settings page and have ideally dropdowns of values 0-23, otherwise just int type-in fields

      3) In cron, make it do the following:

      a) get the values of housekeepingstarthour, stophour work out if the current hour is between those two hours (there is a function in course/report/completelogs/cron for how you can make it work whether they are like 0-4 or like 23-7).
      if it is not between those two hours then do not do this bit at all, otherwise continue

      b) get the value of forumng plugin setting housekeepinglastrun
      c) get the current date in format YYYY-MM-DD
      d) if current date = the plugin setting, do not continue, otherwise

      e) set housekeepinglastrun to current date
      f) call a new function forum::remove_old_discussions()

      4) Function forum::remove_old_discussions

      SQL query through all forums and discussions to find discussions where:

      • the forum has removeafter set (non-zero)
      • the modified date of the last post in the discussion is < current time - removeafter

      For each discussion:

      • depending on the value of removeto, either . move it to the given forum (if the forum does not exist, mtrace an error, and do not move it) or . delete it permanently - is there already a function to do permanent delete? - if not then write one

        Activity

        Hide
        Ray Guo added a comment -

        This feature has been completed

        Show
        Ray Guo added a comment - This feature has been completed

          People

          • Assignee:
            Ray Guo
            Reporter:
            Ray Guo
            Participants:
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development