Skip to content
Permalink
Browse files

MDL-56411 message: dont render message area without other user

Stop the message area header and footer from being rendered if there is
no other user being messaged, otherwise notices are generated and the
messages fail to send.
  • Loading branch information...
ryanwyllie committed Oct 18, 2016
1 parent 4455ff2 commit f5a174f451839149839789cbe4bff9fa4ca2972d
@@ -82,7 +82,13 @@ public function export_for_template(\renderer_base $output) {
$data->currentuserid = $this->currentuserid;
$data->otheruserid = $this->otheruserid;
$data->otheruserfullname = fullname($this->otheruser);
$data->isonline = \core_message\helper::is_online($this->otheruser->lastaccess);
if (empty($this->otheruser)) {
$data->isonline = false;
} else {
$data->isonline = \core_message\helper::is_online($this->otheruser->lastaccess);
}
$data->messages = array();
foreach ($this->messages as $message) {
$message = new message($message);
@@ -99,7 +99,7 @@
$renderer = $PAGE->get_renderer('core_message');
$requestedconversation = false;
$conversations = \core_message\api::get_conversations($user1->id, 0, 20);
$messages = null;
$messages = [];
if (!$user2realuser) {
// If there are conversations, but the user has not chosen a particular one, then render the most recent one.
$user2 = new stdClass();
@@ -14,6 +14,7 @@
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{#otheruserid}}
<div class="messages-header">
<div class="view-toggle btn-container">
<button class="btn btn-link" data-action="show-contacts">&lt; {{#str}} messages, message {{/str}}</button>
@@ -38,9 +39,11 @@
<button class="btn btn-link cancel-messages-delete" data-action="cancel-delete-messages">{{#str}}cancel{{/str}}</button>
</div>
</div>
{{/otheruserid}}
<div class="messages" data-region="messages" data-userid="{{otheruserid}}">
{{> core_message/message_area_messages }}
</div>
{{#otheruserid}}
<div class="response" data-region="response">
{{#iscurrentuser}}
<div class="message-box">
@@ -51,3 +54,4 @@
<button class="btn btn-link confirm" data-action="delete-messages">{{#str}} deleteselectedmessages, message {{/str}}</button>
</div>
</div>
{{/otheruserid}}

0 comments on commit f5a174f

Please sign in to comment.
You can’t perform that action at this time.