mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-64017 core_message: can specify conversation to view on index page
This commit is contained in:
parent
9b6034bc77
commit
d5d4a5aab2
2
message/amd/build/message_drawer.min.js
vendored
2
message/amd/build/message_drawer.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_view_contact","core_message/message_drawer_view_contacts","core_message/message_drawer_view_conversation","core_message/message_drawer_view_group_info","core_message/message_drawer_view_overview","core_message/message_drawer_view_search","core_message/message_drawer_view_settings","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={VIEW_CONTACT:'[data-region="view-contact"]',VIEW_CONTACTS:'[data-region="view-contacts"]',VIEW_CONVERSATION:'[data-region="view-conversation"]',VIEW_GROUP_INFO:'[data-region="view-group-info"]',VIEW_OVERVIEW:'[data-region="view-overview"]',VIEW_SEARCH:'[data-region="view-search"]',VIEW_SETTINGS:'[data-region="view-settings"]',ROUTES:"[data-route]",ROUTES_BACK:"[data-route-back]",HEADER_CONTAINER:'[data-region="header-container"]',BODY_CONTAINER:'[data-region="body-container"]',FOOTER_CONTAINER:'[data-region="footer-container"]'},o=function(a,b,c){var d=b.children(),e=d.filter(n.HEADER_CONTAINER).find(c),f=d.filter(n.BODY_CONTAINER).find(c),g=d.filter(n.FOOTER_CONTAINER).find(c);return[a,e.length?e:null,f.length?f:null,g.length?g:null]},p=[[l.VIEW_CONTACT,n.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,n.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,n.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,n.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,n.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,n.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,n.VIEW_SETTINGS,j.show,j.description]],q=function(a,b){p.forEach(function(c){k.add(a,c[0],o(a,b,c[1]),c[2],c[3])})},r=function(a,b){b.attr("data-shown")||(k.go(a,l.VIEW_OVERVIEW),b.attr("data-shown",!0)),b.removeClass("hidden"),b.attr("aria-expanded",!0),b.attr("aria-hidden",!1)},s=function(a){a.addClass("hidden"),a.attr("aria-expanded",!1),a.attr("aria-hidden",!0)},t=function(a){return!a.hasClass("hidden")},u=function(d,e,f){b.define(e,[b.events.activate]);var g=/^data-route-param-?(\d*)$/;e.on(b.events.activate,n.ROUTES,function(b,c){for(var e=a(b.target).closest(n.ROUTES),f=e.attr("data-route"),h=[],i=0;i<e[0].attributes.length;i++)h.push(e[0].attributes[i]);var j=h.filter(function(a){var b=a.nodeName,c=g.test(b);return c});j.sort(function(a,b){var c=g.exec(a.nodeName),d=g.exec(b.nodeName),e=c.length>1?c[1]:0,f=d.length>1?d[1]:0;return e<f?-1:f<e?1:0});var l=j.map(function(a){return a.nodeValue}),m=[d,f].concat(l);k.go.apply(null,m),c.originalEvent.preventDefault()}),e.on(b.events.activate,n.ROUTES_BACK,function(a,b){k.back(d),b.originalEvent.preventDefault()}),f||(c.subscribe(m.SHOW,function(){r(d,e)}),c.subscribe(m.HIDE,function(){s(e)}),c.subscribe(m.TOGGLE_VISIBILITY,function(){t(e)?s(e):r(d,e)})),c.subscribe(m.SHOW_CONVERSATION,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,a)}),c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,null,"create",a)}),c.subscribe(m.SHOW_SETTINGS,function(){r(d,e),k.go(d,l.VIEW_SETTINGS)}),c.subscribe(m.PREFERENCES_UPDATED,function(a){var b=a.filter(function(a){return"message_entertosend"==a.type}),c=b.length?b[0]:null;if(c){var d=e.find(n.FOOTER_CONTAINER).find(n.VIEW_CONVERSATION);d.attr("data-enter-to-send",c.value)}})},v=function(b,c,d,e,f){b=a(b),q(c,b),u(c,b,d),d&&(r(c,b),e&&(f?k.go(c,l.VIEW_CONVERSATION,f):k.go(c,l.VIEW_CONVERSATION,null,"create",e)))};return{init:v}});
|
||||
define(["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_view_contact","core_message/message_drawer_view_contacts","core_message/message_drawer_view_conversation","core_message/message_drawer_view_group_info","core_message/message_drawer_view_overview","core_message/message_drawer_view_search","core_message/message_drawer_view_settings","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={VIEW_CONTACT:'[data-region="view-contact"]',VIEW_CONTACTS:'[data-region="view-contacts"]',VIEW_CONVERSATION:'[data-region="view-conversation"]',VIEW_GROUP_INFO:'[data-region="view-group-info"]',VIEW_OVERVIEW:'[data-region="view-overview"]',VIEW_SEARCH:'[data-region="view-search"]',VIEW_SETTINGS:'[data-region="view-settings"]',ROUTES:"[data-route]",ROUTES_BACK:"[data-route-back]",HEADER_CONTAINER:'[data-region="header-container"]',BODY_CONTAINER:'[data-region="body-container"]',FOOTER_CONTAINER:'[data-region="footer-container"]'},o=function(a,b,c){var d=b.children(),e=d.filter(n.HEADER_CONTAINER).find(c),f=d.filter(n.BODY_CONTAINER).find(c),g=d.filter(n.FOOTER_CONTAINER).find(c);return[a,e.length?e:null,f.length?f:null,g.length?g:null]},p=[[l.VIEW_CONTACT,n.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,n.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,n.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,n.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,n.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,n.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,n.VIEW_SETTINGS,j.show,j.description]],q=function(a,b){p.forEach(function(c){k.add(a,c[0],o(a,b,c[1]),c[2],c[3])})},r=function(a,b){b.attr("data-shown")||(k.go(a,l.VIEW_OVERVIEW),b.attr("data-shown",!0)),b.removeClass("hidden"),b.attr("aria-expanded",!0),b.attr("aria-hidden",!1)},s=function(a){a.addClass("hidden"),a.attr("aria-expanded",!1),a.attr("aria-hidden",!0)},t=function(a){return!a.hasClass("hidden")},u=function(d,e,f){b.define(e,[b.events.activate]);var g=/^data-route-param-?(\d*)$/;e.on(b.events.activate,n.ROUTES,function(b,c){for(var e=a(b.target).closest(n.ROUTES),f=e.attr("data-route"),h=[],i=0;i<e[0].attributes.length;i++)h.push(e[0].attributes[i]);var j=h.filter(function(a){var b=a.nodeName,c=g.test(b);return c});j.sort(function(a,b){var c=g.exec(a.nodeName),d=g.exec(b.nodeName),e=c.length>1?c[1]:0,f=d.length>1?d[1]:0;return e<f?-1:f<e?1:0});var l=j.map(function(a){return a.nodeValue}),m=[d,f].concat(l);k.go.apply(null,m),c.originalEvent.preventDefault()}),e.on(b.events.activate,n.ROUTES_BACK,function(a,b){k.back(d),b.originalEvent.preventDefault()}),f||(c.subscribe(m.SHOW,function(){r(d,e)}),c.subscribe(m.HIDE,function(){s(e)}),c.subscribe(m.TOGGLE_VISIBILITY,function(){t(e)?s(e):r(d,e)})),c.subscribe(m.SHOW_CONVERSATION,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,a)}),c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,null,"create",a)}),c.subscribe(m.SHOW_SETTINGS,function(){r(d,e),k.go(d,l.VIEW_SETTINGS)}),c.subscribe(m.PREFERENCES_UPDATED,function(a){var b=a.filter(function(a){return"message_entertosend"==a.type}),c=b.length?b[0]:null;if(c){var d=e.find(n.FOOTER_CONTAINER).find(n.VIEW_CONVERSATION);d.attr("data-enter-to-send",c.value)}})},v=function(b,c,d,e,f){b=a(b),q(c,b),u(c,b,d),d&&(r(c,b),e?f?k.go(c,l.VIEW_CONVERSATION,f):k.go(c,l.VIEW_CONVERSATION,null,"create",e):f&&k.go(c,l.VIEW_CONVERSATION,f))};return{init:v}});
|
@ -267,12 +267,16 @@ function(
|
||||
registerEventListeners(uniqueId, root, alwaysVisible);
|
||||
if (alwaysVisible) {
|
||||
show(uniqueId, root);
|
||||
// Are we sending to a specific user?
|
||||
if (sendToUser) {
|
||||
// Check if a conversation already exists, if not, create one.
|
||||
if (conversationId) {
|
||||
Router.go(uniqueId, Routes.VIEW_CONVERSATION, conversationId);
|
||||
} else {
|
||||
Router.go(uniqueId, Routes.VIEW_CONVERSATION, null, 'create', sendToUser);
|
||||
}
|
||||
} else if (conversationId) { // We aren't sending to a specific user, but to a group conversation.
|
||||
Router.go(uniqueId, Routes.VIEW_CONVERSATION, conversationId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -763,6 +763,9 @@ class helper {
|
||||
|
||||
if ($sendtouser) {
|
||||
$templatecontext['sendtouser'] = $sendtouser;
|
||||
}
|
||||
|
||||
if ($conversationid) {
|
||||
$templatecontext['conversationid'] = $conversationid;
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,20 @@ $id = optional_param('id', 0, PARAM_INT);
|
||||
// We no longer support viewing another user's messaging area (that can be achieved
|
||||
// via the 'Log-in as' feature). The 'user2' value takes preference over 'id'.
|
||||
$userid = optional_param('user2', $id, PARAM_INT);
|
||||
$conversationid = optional_param('convid', null, PARAM_INT);
|
||||
|
||||
if (!core_user::is_real_user($userid)) {
|
||||
$userid = null;
|
||||
}
|
||||
// You can specify either a user, or a conversation, not both.
|
||||
if ($userid) {
|
||||
$conversationid = \core_message\api::get_conversation_between_users([$USER->id, $userid]);
|
||||
} else if ($conversationid) {
|
||||
// Check that the user belongs to the conversation.
|
||||
if (!\core_message\api::is_user_in_conversation($USER->id, $conversationid)) {
|
||||
$conversationid = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
$recipient = new stdClass();
|
||||
@ -73,12 +83,6 @@ $usernode->remove();
|
||||
$settings = $PAGE->settingsnav->find('messages', null);
|
||||
$settings->make_active();
|
||||
|
||||
// Check if there is an existing conversation with the supplied user (if there is one).
|
||||
$conversationid = null;
|
||||
if ($userid) {
|
||||
$conversationid = \core_message\api::get_conversation_between_users([$USER->id, $userid]);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// Display a message if the messages have not been migrated yet.
|
||||
if (!get_user_preferences('core_message_migrate_data', false)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user