From e90a0396e139c86e2d71ca5ce752bdc0e1cbd2eb Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 8 Oct 2014 09:39:44 +1300 Subject: [PATCH] MDL-3714 mod_forum: pre-integration clean up --- .../classes/message/inbound/reply_handler.php | 32 +++++++++---------- mod/forum/db/messageinbound_handlers.php | 2 +- mod/forum/lang/en/forum.php | 20 ++++++------ mod/forum/lib.php | 6 ++-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mod/forum/classes/message/inbound/reply_handler.php b/mod/forum/classes/message/inbound/reply_handler.php index c70ad9f0ce8..67e7b08cd2c 100644 --- a/mod/forum/classes/message/inbound/reply_handler.php +++ b/mod/forum/classes/message/inbound/reply_handler.php @@ -36,7 +36,6 @@ require_once($CFG->dirroot . '/repository/lib.php'); * @copyright 2014 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class reply_handler extends \core\message\inbound\handler { /** @@ -61,12 +60,13 @@ class reply_handler extends \core\message\inbound\handler { /** * Process a message received and validated by the Inbound Message processor. * - * @param $messagedata The Inbound Message record - * @param $messagedata The message data packet + * @throws \core\message\inbound\processing_failed_exception + * @param \stdClass $messagedata The Inbound Message record + * @param \stdClass $messagedata The message data packet * @return bool Whether the message was successfully processed. */ public function process_message(\stdClass $record, \stdClass $messagedata) { - global $DB, $CFG, $USER; + global $DB, $USER; // Load the post being replied to. $post = $DB->get_record('forum_posts', array('id' => $record->datavalue)); @@ -85,7 +85,6 @@ class reply_handler extends \core\message\inbound\handler { // Load the other required data. $forum = $DB->get_record('forum', array('id' => $discussion->forum)); $course = $DB->get_record('course', array('id' => $forum->course)); - $coursecontext = \context_course::instance($course->id); $cm = get_fast_modinfo($course->id)->instances['forum'][$forum->id]; $modcontext = \context_module::instance($cm->id); $usercontext = \context_user::instance($USER->id); @@ -114,14 +113,14 @@ class reply_handler extends \core\message\inbound\handler { if (!$canpost) { $data = new \stdClass(); $data->forum = $forum; - throw new \message\inbound\processing_failed_exception('messageinboundnopostforum', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundnopostforum', 'mod_forum', $data); } // And check the availability. if (!\core_availability\info_module::is_user_visible($cm, $USER, true)) { $data = new \stdClass(); $data->forum = $forum; - throw new \message\inbound\processing_failed_exception('messageinboundforumhidden', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundforumhidden', 'mod_forum', $data); } // Before we add this we must check that the user will not exceed the blocking threshold. @@ -131,7 +130,7 @@ class reply_handler extends \core\message\inbound\handler { $data = new \stdClass(); $data->forum = $forum; $data->message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional); - throw new \message\inbound\processing_failed_exception('messageinboundthresholdhit', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundthresholdhit', 'mod_forum', $data); } $addpost = new \stdClass(); @@ -165,7 +164,7 @@ class reply_handler extends \core\message\inbound\handler { $data = new \stdClass(); $data->forum = $forum; $data->attachmentcount = $attachmentcount; - throw new \message\inbound\processing_failed_exception('messageinboundattachmentdisallowed', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundattachmentdisallowed', 'mod_forum', $data); } if ($forum->maxattachments < $attachmentcount) { @@ -176,7 +175,7 @@ class reply_handler extends \core\message\inbound\handler { $data = new \stdClass(); $data->forum = $forum; $data->attachmentcount = $attachmentcount; - throw new \message\inbound\processing_failed_exception('messageinboundfilecountexceeded', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundfilecountexceeded', 'mod_forum', $data); } $filesize = 0; @@ -195,7 +194,7 @@ class reply_handler extends \core\message\inbound\handler { $data->forum = $forum; $data->maxbytes = display_size($forum->maxbytes); $data->filesize = display_size($filesize); - throw new \message\inbound\processing_failed_exception('messageinboundfilesizeexceeded', 'mod_forum', $data); + throw new \core\message\inbound\processing_failed_exception('messageinboundfilesizeexceeded', 'mod_forum', $data); } } @@ -236,13 +235,14 @@ class reply_handler extends \core\message\inbound\handler { /** * Process attachments included in a message. * - * @param $acceptedtypes String The mimetypes of the acceptable attachment types. - * @param $context context_user The context of the user creating this attachment. - * @param $itemid int The itemid to store this attachment under. - * @param $attachment stdClass The Attachment data to store. + * @param string[] $acceptedtypes String The mimetypes of the acceptable attachment types. + * @param \context_user $context context_user The context of the user creating this attachment. + * @param int $itemid int The itemid to store this attachment under. + * @param \stdClass $attachment stdClass The Attachment data to store. + * @return \stored_file */ protected function process_attachment($acceptedtypes, \context_user $context, $itemid, \stdClass $attachment) { - global $DB, $USER, $CFG; + global $USER, $CFG; // Create the file record. $record = new \stdClass(); diff --git a/mod/forum/db/messageinbound_handlers.php b/mod/forum/db/messageinbound_handlers.php index 97ba7925d45..6f164bfdf78 100644 --- a/mod/forum/db/messageinbound_handlers.php +++ b/mod/forum/db/messageinbound_handlers.php @@ -18,7 +18,7 @@ * Message Inbound Handlers for mod_forum. * * @package mod_forum - * @copyright 2014 Andrew NIcols + * @copyright 2014 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index 2ba717fee40..177939af650 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -282,6 +282,12 @@ $string['maxattachmentsize'] = 'Maximum attachment size'; $string['maxattachmentsize_help'] = 'This setting specifies the largest size of file that can be attached to a forum post.'; $string['maxtimehaspassed'] = 'Sorry, but the maximum time for editing this post ({$a}) has passed!'; $string['message'] = 'Message'; +$string['messageinboundattachmentdisallowed'] = 'Unable to post your reply, since it includes an attachment and the forum doesn\'t allow attachments.'; +$string['messageinboundfilecountexceeded'] = 'Unable to post your reply, since it includes more than the maximum number of attachments allowed for the forum ({$a->forum->maxattachments}).'; +$string['messageinboundfilesizeexceeded'] = 'Unable to post your reply, since the total attachment size ({$a->filesize}) is greater than the maximum size allowed for the forum ({$a->maxbytes}).'; +$string['messageinboundforumhidden'] = 'Unable to post your reply, since the forum is currently unavailable.'; +$string['messageinboundnopostforum'] = 'Unable to post your reply, since you do not have permission to post in the {$a->forum->name} forum.'; +$string['messageinboundthresholdhit'] = 'Unable to post your reply. You have exceeded the posting threshold set for this forum'; $string['messageprovider:digests'] = 'Subscribed forum digests'; $string['messageprovider:posts'] = 'Subscribed forum posts'; $string['missingsearchterms'] = 'The following search terms occur only in the HTML markup of this message:'; @@ -367,6 +373,8 @@ $string['pluginname'] = 'Forum'; $string['postadded'] = '

Your post was successfully added.

You have {$a} to edit it if you want to make any changes.

'; $string['postaddedsuccess'] = 'Your post was successfully added.'; $string['postaddedtimeleft'] = 'You have {$a} to edit it if you want to make any changes.'; +$string['postbymailsuccess'] = 'Congratulations, your forum post with subject "{$a->subject}" was successfully added. You can view it at {$a->discussionurl}.'; +$string['postbymailsuccess_html'] = 'Congratulations, your forum post with subject "{$a->subject}" was successfully posted.'; $string['postbyuser'] = '{$a->post} by {$a->user}'; $string['postincontext'] = 'See this post in context'; $string['postmailinfo'] = 'This is a copy of a message posted on the {$a} website. @@ -400,6 +408,8 @@ $string['replyforum'] = 'Reply to forum'; $string['replytoforumpost'] = 'Reply via email to {$a}'; $string['replytoforumpost_html'] = 'Reply via email'; $string['replytouser'] = 'Use email address in reply'; +$string['reply_handler'] = 'Reply to forum posts via email'; +$string['reply_handler_name'] = 'Reply to forum posts'; $string['resetforums'] = 'Delete posts from'; $string['resetforumsall'] = 'Delete all posts'; $string['resetdigests'] = 'Delete all per-user forum digest preferences'; @@ -492,13 +502,3 @@ $string['warnformorepost'] = 'Warning! There is more than one discussion in this $string['yournewquestion'] = 'Your new question'; $string['yournewtopic'] = 'Your new discussion topic'; $string['yourreply'] = 'Your reply'; -$string['reply_handler'] = 'Reply to forum posts via email'; -$string['reply_handler_name'] = 'Reply to forum posts'; -$string['messageinboundattachmentdisallowed'] = 'Unable to post your reply, since it includes an attachment and the forum doesn\'t allow attachments.'; -$string['messageinboundfilecountexceeded'] = 'Unable to post your reply, since it includes more than the maximum number of attachments allowed for the forum ({$a->forum->maxattachments}).'; -$string['messageinboundfilesizeexceeded'] = 'Unable to post your reply, since the total attachment size ({$a->filesize}) is greater than the maximum size allowed for the forum ({$a->maxbytes}).'; -$string['messageinboundforumhidden'] = 'Unable to post your reply, since the forum is currently unavailable.'; -$string['messageinboundnopostforum'] = 'Unable to post your reply, since you do not have permission to post in the {$a->forum->name} forum.'; -$string['messageinboundthresholdhit'] = 'Unable to post your reply. You have exceeded the posting threshold set for this forum'; -$string['postbymailsuccess'] = 'Congratulations, your forum post with subject "{$a->subject}" was successfully added. You can view it at {$a->discussionurl}.'; -$string['postbymailsuccess_html'] = 'Congratulations, your forum post with subject "{$a->subject}" was successfully posted.'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index a5610715e13..8848e70efb6 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1147,7 +1147,7 @@ function forum_cron() { * @param object $userfrom * @param object $userto * @param boolean $bare - * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. + * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. [Since 2.8]. * @return string The email body in plain text format. */ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $bare = false, $replyaddress = null) { @@ -1237,7 +1237,7 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro * @param object $post * @param object $userfrom * @param object $userto - * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. + * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. [Since 2.8]. * @return string The email text in HTML format */ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $replyaddress = null) { @@ -4275,7 +4275,7 @@ function forum_add_attachment($post, $forum, $cm, $mform=null, $unused=null) { * @global object * @param object $post * @param mixed $mform - * @param string $message + * @param string $unused formerly $message, renamed in 2.8 as it was unused. * @return int */ function forum_add_new_post($post, $mform, $unused = null) { -- 2.43.0