$string['messages'] = 'Messages';
$string['messagingdisabled'] = 'Messaging is disabled on this site, emails will be sent instead';
$string['newonlymsg'] = 'Show only new';
+$string['newmessage'] = 'New message';
+$string['newmessagesearch'] = 'Select or search for a contact to send a new message.';
+$string['newsearch'] = 'New search';
$string['noframesjs'] = 'Use more accessible interface';
$string['nocontacts'] = 'No contacts';
$string['nomessages'] = 'No messages';
return this.node.data('userid');
};
+ /**
+ * Function to determine if we should be showing contacts initially or messages.
+ *
+ * @return {boolean} True to show contacts first, otherwise show messages.
+ */
+ Messagearea.prototype.showContactsFirst = function() {
+ return !!this.node.data('displaycontacts');
+ };
+
return Messagearea;
}
);
this.messageArea.onDelegateEvent(CustomEvents.events.scrollBottom, SELECTORS.CONTACTS,
this._loadContacts.bind(this));
- // Set the number of conversations. We set this to the number of conversations we asked to retrieve not by
- // the number that was actually retrieved, see MDL-55870.
- this._numConversationsDisplayed = 20;
+ if (!this.messageArea.showContactsFirst()) {
+ // Set the initial number of conversations to retrieve. Otherwise it will display no conversations.
+ this._numConversationsDisplayed = 20;
+ }
};
/**
);
// Set the initial search area.
- this._searchArea = this._searchAreas.MESSAGES;
+ this._searchArea = (this.messageArea.showContactsFirst()) ? this._searchAreas.USERS : this._searchAreas.MESSAGES;
};
/**
*/
public $polltimeout;
+ /**
+ * @var bool Are we creating a new message and show the contacts section first?
+ */
+ public $contactsfirst;
+
/**
* Constructor.
*
* @param array $contacts
* @param array|null $messages
* @param bool $requestedconversation
+ * @param bool $contactsfirst Whether we are viewing the contacts first.
* @param int $pollmin
* @param int $pollmax
* @param int $polltimeout
*/
- public function __construct($userid, $otheruserid, $contacts, $messages, $requestedconversation, $pollmin, $pollmax,
- $polltimeout) {
+ public function __construct($userid, $otheruserid, $contacts, $messages, $requestedconversation, $contactsfirst, $pollmin,
+ $pollmax, $polltimeout) {
$this->userid = $userid;
- $this->otheruserid = $otheruserid;
+ // Setting the other user to null when showing contacts will remove any contact from being selected.
+ $this->otheruserid = (!$contactsfirst) ? $otheruserid : null;
$this->contacts = $contacts;
$this->messages = $messages;
$this->requestedconversation = $requestedconversation;
$this->pollmin = $pollmin;
$this->pollmax = $pollmax;
$this->polltimeout = $polltimeout;
+ $this->contactsfirst = $contactsfirst;
}
public function export_for_template(\renderer_base $output) {
$data->userid = $this->userid;
$contacts = new contacts($this->otheruserid, $this->contacts);
$data->contacts = $contacts->export_for_template($output);
- $messages = new messages($this->userid, $this->otheruserid, $this->messages);
+ if ($this->contactsfirst) {
+ // Don't show any messages if we are creating a new message.
+ $messages = new messages($this->userid, null, array());
+ } else {
+ $messages = new messages($this->userid, $this->otheruserid, $this->messages);
+ }
$data->messages = $messages->export_for_template($output);
- $data->isconversation = true;
+ $data->isconversation = ($this->contactsfirst) ? false : true;
$data->requestedconversation = $this->requestedconversation;
$data->pollmin = $this->pollmin;
$data->pollmax = $this->pollmax;
$data->polltimeout = $this->polltimeout;
+ $data->contactsfirst = $this->contactsfirst;
return $data;
}
// we are going to accept other URL parameters to figure this out.
$user1id = optional_param('user1', $USER->id, PARAM_INT);
$user2id = optional_param('user2', $id, PARAM_INT);
+$contactsfirst = optional_param('contactsfirst', 0, PARAM_INT);
$url = new moodle_url('/message/index.php');
if ($id) {
if ($user2id) {
$url->param('user2', $user2id);
}
+ if ($contactsfirst) {
+ $url->param('contactsfirst', $contactsfirst);
+ }
}
$PAGE->set_url($url);
// Get the renderer and the information we are going to be use.
$renderer = $PAGE->get_renderer('core_message');
$requestedconversation = false;
-$conversations = \core_message\api::get_conversations($user1->id, 0, 20);
+if ($contactsfirst) {
+ $conversations = \core_message\api::get_contacts($user1->id, 0, 20);
+} else {
+ $conversations = \core_message\api::get_conversations($user1->id, 0, 20);
+}
$messages = [];
if (!$user2realuser) {
// If there are conversations, but the user has not chosen a particular one, then render the most recent one.
$pollmax = !empty($CFG->messagingmaxpoll) ? $CFG->messagingmaxpoll : MESSAGE_DEFAULT_MAX_POLL_IN_SECONDS;
$polltimeout = !empty($CFG->messagingtimeoutpoll) ? $CFG->messagingtimeoutpoll : MESSAGE_DEFAULT_TIMEOUT_POLL_IN_SECONDS;
$messagearea = new \core_message\output\messagearea\message_area($user1->id, $user2->id, $conversations, $messages,
- $requestedconversation, $pollmin, $pollmax, $polltimeout);
+ $requestedconversation, $contactsfirst, $pollmin, $pollmax, $polltimeout);
// Now the page contents.
echo $OUTPUT->header();
$context = [
'userid' => $USER->id,
'urls' => [
+ 'writeamessage' => (new moodle_url('/message/index.php', ['contactsfirst' => 1]))->out(),
'preferences' => (new moodle_url('/message/edit.php', ['id' => $USER->id]))->out(),
],
];
{{$headertext}}{{#str}} messages, message {{/str}}{{/headertext}}
{{$headeractions}}
+ <div class="newmessage-link">
+ {{$anchor}}
+ <a href="{{{urls.writeamessage}}}">{{#str}} newmessage, message {{/str}}
+ </a>
+ {{/anchor}}
+ </div>
{{< core/hover_tooltip }}
{{$anchor}}
<a class="mark-all-read-button"
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
-<div class="messaging-area-container" data-userid="{{userid}}">
+<div class="messaging-area-container" data-userid="{{userid}}" data-displaycontacts="{{contactsfirst}}">
<div class="messaging-area {{#requestedconversation}}show-messages{{/requestedconversation}}
{{^requestedconversation}}hide-messages{{/requestedconversation}}" data-region="messaging-area">
<div class="contacts-area" data-region="contacts-area" role="tablist">
}}
<div class="searchtextarea" data-region="search-text-area">
<label class="accesshide" for="searchtext">{{#str}}search{{/str}}</label>
- <input data-region="search-box" type="text" id="searchtext" placeholder="{{#str}}searchmessages, message{{/str}}">
+ <input data-region="search-box" type="text" id="searchtext" placeholder="{{#contactsfirst}} {{#str}}searchforuserorcourse, message{{/str}} {{/contactsfirst}} {{^contactsfirst}} {{#str}}searchmessages, message{{/str}} {{/contactsfirst}}">
<div data-region="search-filter-area" class="searchfilterarea" style="display:none">
<div data-region="search-filter" class="searchfilter"></div>
<div data-action="search-filter-delete" class="searchfilterdelete">{{#pix}}t/delete{{/pix}}</div>
</div>
</div>
+{{#contactsfirst}}
+<div class="contacts" data-region="contacts" data-region-content="conversations" style="display:none;" role="tabpanel" id="conversations-tab-panel"></div>
+<div class="contacts" data-region="contacts" data-region-content="contacts" role="tabpanel" id="contacts-tab-panel">
+ {{> core_message/message_area_contacts }}
+</div>
+{{/contactsfirst}}
+{{^contactsfirst}}
<div class="contacts" data-region="contacts" data-region-content="conversations" role="tabpanel" id="conversations-tab-panel">
{{> core_message/message_area_contacts }}
</div>
-{{! Hidden divs to load the other tab and search panels via JS when appropriate. }}
<div class="contacts" data-region="contacts" data-region-content="contacts" style="display:none;" role="tabpanel" id="contacts-tab-panel"></div>
+{{/contactsfirst}}
+{{! Hidden divs to load the other tab and search panels via JS when appropriate. }}
<div class="contacts searcharea" data-region="search-results-area" style="display:none;"></div>
<div class="tabs">
- <div class="tab tabconversations selected" data-action="conversations-view" role="tab" aria-controls="conversations-tab-panel" aria-selected="true" tabindex="0">
+ <div class="tab tabconversations {{^contactsfirst}}selected{{/contactsfirst}} " data-action="conversations-view" role="tab" aria-controls="conversations-tab-panel" aria-selected="{{^contactsfirst}}true{{/contactsfirst}}{{#contactsfirst}}false{{/contactsfirst}}" tabindex="0">
<div class="tabimage">{{#pix}}t/message, moodle{{/pix}}</div>
<div>{{#str}}messages, message{{/str}}</div>
</div>
- <div class="tab tabcontacts" data-action="contacts-view" role="tab" aria-controls="contacts-tab-panel" aria-selected="false" tabindex="-1">
+ <div class="tab tabcontacts {{#contactsfirst}}selected{{/contactsfirst}}" data-action="contacts-view" role="tab" aria-controls="contacts-tab-panel" aria-selected="{{#contactsfirst}}true{{/contactsfirst}}{{^contactsfirst}}false{{/contactsfirst}}" tabindex="-1">
<div class="tabimage">{{#pix}}i/cohort, moodle{{/pix}}</div>
<div>{{#str}}contacts, message{{/str}}</div>
</div>
</div>
</div>
{{/otheruserid}}
+{{#contactsfirst}}
+<div class="messages-header">
+ <div class="name-container">
+ <div class="name">
+ {{#str}}newmessagesearch, message{{/str}}
+ </div>
+ </div>
+</div>
+{{/contactsfirst}}
<div class="messages" data-region="messages" data-userid="{{otheruserid}}">
{{> core_message/message_area_messages }}
</div>
height: 12px;
width: 12px;
}
+
+ .newmessage-link {
+ margin-right: 10px;
+ }
+
label {
display: inline-block;
text-align: center;
height: 12px;
width: 12px;
}
+ .newmessage-link {
+ margin-right: 10px;
+ }
label {
display: inline-block;
text-align: center;
.popover-region-header-actions {
float: left;
+
+ .newmessage-link {
+ margin-left: 10px;
+ }
}
}
height: 12px;
width: 12px;
}
+.popover-region-header-actions .newmessage-link {
+ margin-right: 10px;
+}
.popover-region-header-actions label {
display: inline-block;
text-align: center;
.dir-rtl .popover-region .popover-region-header-actions {
float: left;
}
+.dir-rtl .popover-region .popover-region-header-actions .newmessage-link {
+ margin-left: 10px;
+}
.dir-rtl .navbar .popover-region {
float: left;
}