commit
c6cae89d98
|
@ -148,9 +148,9 @@
|
|||
"addon.files.sitefiles": "moodle",
|
||||
"addon.messageoutput_airnotifier.processorsettingsdesc": "local_moodlemobileapp",
|
||||
"addon.messages.addcontact": "message",
|
||||
"addon.messages.blockcontact": "message",
|
||||
"addon.messages.blockcontactconfirm": "local_moodlemobileapp",
|
||||
"addon.messages.blocknoncontacts": "message",
|
||||
"addon.messages.blockuser": "message",
|
||||
"addon.messages.blockuserconfirm": "message",
|
||||
"addon.messages.contactableprivacy": "message",
|
||||
"addon.messages.contactableprivacy_coursemember": "message",
|
||||
"addon.messages.contactableprivacy_onlycontacts": "message",
|
||||
|
@ -179,7 +179,8 @@
|
|||
"addon.messages.type_online": "local_moodlemobileapp",
|
||||
"addon.messages.type_search": "local_moodlemobileapp",
|
||||
"addon.messages.type_strangers": "local_moodlemobileapp",
|
||||
"addon.messages.unblockcontact": "message",
|
||||
"addon.messages.unblockuser": "message",
|
||||
"addon.messages.unblockuserconfirm": "message",
|
||||
"addon.messages.warningmessagenotsent": "local_moodlemobileapp",
|
||||
"addon.mod_assign.acceptsubmissionstatement": "local_moodlemobileapp",
|
||||
"addon.mod_assign.addattempt": "assign",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"addcontact": "Add contact",
|
||||
"blockcontact": "Block contact",
|
||||
"blockcontactconfirm": "You will no longer receive messages from this contact.",
|
||||
"blocknoncontacts": "Prevent non-contacts from messaging me",
|
||||
"blockuser": "Block user",
|
||||
"blockuserconfirm": "Are you sure you want to block {{$a}}?",
|
||||
"contactableprivacy": "Accept messages from:",
|
||||
"contactableprivacy_coursemember": "My contacts and anyone in my courses",
|
||||
"contactableprivacy_onlycontacts": "My contacts only",
|
||||
|
@ -31,6 +31,7 @@
|
|||
"type_online": "Online",
|
||||
"type_search": "Search results",
|
||||
"type_strangers": "Others",
|
||||
"unblockcontact": "Unblock contact",
|
||||
"unblockuser": "Unblock user",
|
||||
"unblockuserconfirm": "Are you sure you want to unblock {{$a}}?",
|
||||
"warningmessagenotsent": "Couldn't send message(s) to user {{user}}. {{error}}"
|
||||
}
|
|
@ -70,19 +70,30 @@ export class AddonMessagesProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Block a contact.
|
||||
* Block a user.
|
||||
*
|
||||
* @param {number} userId User ID of the person to block.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
*/
|
||||
blockContact(userId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const params = {
|
||||
userids: [ userId ]
|
||||
};
|
||||
let promise;
|
||||
if (site.wsAvailable('core_message_block_user')) {
|
||||
// Since Moodle 3.6
|
||||
const params = {
|
||||
userid: site.getUserId(),
|
||||
blockeduserid: userId,
|
||||
};
|
||||
promise = site.write('core_message_block_user', params);
|
||||
} else {
|
||||
const params = {
|
||||
userids: [userId]
|
||||
};
|
||||
promise = site.write('core_message_block_contacts', params);
|
||||
}
|
||||
|
||||
return site.write('core_message_block_contacts', params).then(() => {
|
||||
return promise.then(() => {
|
||||
return this.invalidateAllContactsCache(site.getUserId(), site.getId());
|
||||
});
|
||||
});
|
||||
|
@ -1152,19 +1163,30 @@ export class AddonMessagesProvider {
|
|||
* Unblock a user.
|
||||
*
|
||||
* @param {number} userId User ID of the person to unblock.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
*/
|
||||
unblockContact(userId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const params = {
|
||||
userids: [ userId ]
|
||||
},
|
||||
preSets = {
|
||||
let promise;
|
||||
if (site.wsAvailable('core_message_unblock_user')) {
|
||||
// Since Moodle 3.6
|
||||
const params = {
|
||||
userid: site.getUserId(),
|
||||
unblockeduserid: userId,
|
||||
};
|
||||
promise = site.write('core_message_unblock_user', params);
|
||||
} else {
|
||||
const params = {
|
||||
userids: [userId]
|
||||
};
|
||||
const preSets = {
|
||||
responseExpected: false
|
||||
};
|
||||
promise = site.write('core_message_unblock_contacts', params, preSets);
|
||||
}
|
||||
|
||||
return site.write('core_message_unblock_contacts', params, preSets).then(() => {
|
||||
return promise.then(() => {
|
||||
return this.invalidateAllContactsCache(site.getUserId(), site.getId());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -96,12 +96,17 @@ export class AddonMessagesBlockContactUserHandler implements CoreUserProfileHand
|
|||
|
||||
this.messagesProvider.isBlocked(user.id).then((isBlocked) => {
|
||||
if (isBlocked) {
|
||||
return this.messagesProvider.unblockContact(user.id);
|
||||
} else {
|
||||
const template = this.translate.instant('addon.messages.blockcontactconfirm'),
|
||||
title = this.translate.instant('addon.messages.blockcontact');
|
||||
const template = this.translate.instant('addon.messages.unblockuserconfirm', {$a: user.fullname});
|
||||
const okText = this.translate.instant('addon.messages.unblockuser');
|
||||
|
||||
return this.domUtils.showConfirm(template, title, title).then(() => {
|
||||
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
|
||||
return this.messagesProvider.unblockContact(user.id);
|
||||
});
|
||||
} else {
|
||||
const template = this.translate.instant('addon.messages.blockuserconfirm', {$a: user.fullname});
|
||||
const okText = this.translate.instant('addon.messages.blockuser');
|
||||
|
||||
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
|
||||
return this.messagesProvider.blockContact(user.id);
|
||||
});
|
||||
}
|
||||
|
@ -129,7 +134,7 @@ export class AddonMessagesBlockContactUserHandler implements CoreUserProfileHand
|
|||
return this.messagesProvider.isBlocked(userId).then((isBlocked) => {
|
||||
if (isBlocked) {
|
||||
this.updateButton(userId, {
|
||||
title: 'addon.messages.unblockcontact',
|
||||
title: 'addon.messages.unblockuser',
|
||||
class: 'addon-messages-unblockcontact-handler',
|
||||
icon: 'checkmark-circle',
|
||||
hidden: false,
|
||||
|
@ -137,7 +142,7 @@ export class AddonMessagesBlockContactUserHandler implements CoreUserProfileHand
|
|||
});
|
||||
} else {
|
||||
this.updateButton(userId, {
|
||||
title: 'addon.messages.blockcontact',
|
||||
title: 'addon.messages.blockuser',
|
||||
class: 'addon-messages-blockcontact-handler',
|
||||
icon: 'close-circle',
|
||||
hidden: false,
|
||||
|
|
|
@ -148,9 +148,9 @@
|
|||
"addon.files.sitefiles": "Site files",
|
||||
"addon.messageoutput_airnotifier.processorsettingsdesc": "Configure devices",
|
||||
"addon.messages.addcontact": "Add contact",
|
||||
"addon.messages.blockcontact": "Block contact",
|
||||
"addon.messages.blockcontactconfirm": "You will no longer receive messages from this contact.",
|
||||
"addon.messages.blocknoncontacts": "Prevent non-contacts from messaging me",
|
||||
"addon.messages.blockuser": "Block user",
|
||||
"addon.messages.blockuserconfirm": "Are you sure you want to block {{$a}}?",
|
||||
"addon.messages.contactableprivacy": "Accept messages from:",
|
||||
"addon.messages.contactableprivacy_coursemember": "My contacts and anyone in my courses",
|
||||
"addon.messages.contactableprivacy_onlycontacts": "My contacts only",
|
||||
|
@ -179,7 +179,8 @@
|
|||
"addon.messages.type_online": "Online",
|
||||
"addon.messages.type_search": "Search results",
|
||||
"addon.messages.type_strangers": "Others",
|
||||
"addon.messages.unblockcontact": "Unblock contact",
|
||||
"addon.messages.unblockuser": "Unblock user",
|
||||
"addon.messages.unblockuserconfirm": "Are you sure you want to unblock {{$a}}?",
|
||||
"addon.messages.warningmessagenotsent": "Couldn't send message(s) to user {{user}}. {{error}}",
|
||||
"addon.mod_assign.acceptsubmissionstatement": "Please accept the submission statement.",
|
||||
"addon.mod_assign.addattempt": "Allow another attempt",
|
||||
|
|
Loading…
Reference in New Issue