Skip to content

Commit

Permalink
MDL-31355 mod_forum: Add duedate and cutoffdate to form
Browse files Browse the repository at this point in the history
AMOS BEGIN
CPY [availability,mod_assign],[availability,mod_forum]
CPY [cutoffdate,mod_assign],[cutoffdate,mod_forum]
CPY [cutoffdatevalidation,mod_assign],[cutoffdatevalidation,mod_forum]
CPY [duedate,mod_assign],[duedate,mod_forum]
AMOS END
  • Loading branch information
rezaies committed Apr 10, 2019
1 parent f6b07fe commit ceea2d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mod/forum/lang/en/forum.php
Expand Up @@ -43,6 +43,7 @@
$string['attachmentnopost'] = 'You cannot export attachments without a post id';
$string['attachments'] = 'Attachments';
$string['attachmentswordcount'] = 'Attachments and word count';
$string['availability'] = 'Availability';
$string['blockafter'] = 'Post threshold for blocking';
$string['blockafter_help'] = 'This setting specifies the maximum number of posts which a user can post in the given time period. Users with the capability mod/forum:postwithoutthrottling are exempt from post limits.';
$string['blockperiod'] = 'Time period for blocking';
Expand Down Expand Up @@ -122,6 +123,9 @@
$string['couldnotdeletereplies'] = 'Sorry, that cannot be deleted as people have already responded to it';
$string['couldnotupdate'] = 'Could not update your post due to an unknown error';
$string['crontask'] = 'Forum mailings and maintenance jobs';
$string['cutoffdate'] = 'Cut-off date';
$string['cutoffdate_help'] = 'If set, the forum will not accept posts after this date.';
$string['cutoffdatevalidation'] = 'The cut-off date cannot be earlier than the due date.';
$string['delete'] = 'Delete';
$string['deleteddiscussion'] = 'The discussion topic has been deleted';
$string['deletedpost'] = 'The post has been deleted';
Expand Down Expand Up @@ -170,6 +174,9 @@
$string['displaystart_help'] = 'This setting specifies whether a forum post should be displayed from a certain date. Note that administrators can always view forum posts.';
$string['displaywordcount'] = 'Display word count';
$string['displaywordcount_help'] = 'This setting specifies whether the word count of each post should be displayed or not.';
$string['duedate'] = 'Due date';
$string['duedate_help'] = 'This is when the forum is due. Although this date is displayed on the calendar as the due date for the forum, posting to the forum will still be allowed after this date. To prevent posting to the forum after a certain date - set the forum cut off date.';
$string['duedatetodisplayincalendar'] = 'Due date to display in calendar';
$string['eachuserforum'] = 'Each person posts one discussion';
$string['edit'] = 'Edit';
$string['editedby'] = 'Edited by {$a->name} - original submission {$a->date}';
Expand Down
22 changes: 22 additions & 0 deletions mod/forum/mod_form.php
Expand Up @@ -54,6 +54,16 @@ function definition() {
$mform->addHelpButton('type', 'forumtype', 'forum');
$mform->setDefault('type', 'general');

$mform->addElement('header', 'availability', get_string('availability', 'forum'));

$name = get_string('duedate', 'forum');
$mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true));
$mform->addHelpButton('duedate', 'duedate', 'forum');

$name = get_string('cutoffdate', 'forum');
$mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional' => true));
$mform->addHelpButton('cutoffdate', 'cutoffdate', 'forum');

// Attachments and word count.
$mform->addElement('header', 'attachmentswordcounthdr', get_string('attachmentswordcount', 'forum'));

Expand Down Expand Up @@ -229,6 +239,18 @@ function definition_after_data() {

}

public function validation($data, $files) {
$errors = parent::validation($data, $files);

if ($data['duedate'] && $data['cutoffdate']) {
if ($data['duedate'] > $data['cutoffdate']) {
$errors['cutoffdate'] = get_string('cutoffdatevalidation', 'forum');
}
}

return $errors;
}

function data_preprocessing(&$default_values) {
parent::data_preprocessing($default_values);

Expand Down

0 comments on commit ceea2d2

Please sign in to comment.