diff --git a/src/addon/mod/forum/pages/discussion/discussion.ts b/src/addon/mod/forum/pages/discussion/discussion.ts index 0f076b58b..50bff42b8 100644 --- a/src/addon/mod/forum/pages/discussion/discussion.ts +++ b/src/addon/mod/forum/pages/discussion/discussion.ts @@ -351,12 +351,16 @@ export class AddonModForumDiscussionPage implements OnDestroy { this.ratingInfo = ratingInfo; }); }).then(() => { - // Use the canAddDiscussion WS to check if the user can pin discussions. - return this.forumProvider.canAddDiscussionToAll(this.forumId).then((response) => { - this.canPin = !!response.canpindiscussions; - }).catch(() => { + if (this.forumProvider.isSetPinStateAvailableForSite()) { + // Use the canAddDiscussion WS to check if the user can pin discussions. + return this.forumProvider.canAddDiscussionToAll(this.forumId).then((response) => { + this.canPin = !!response.canpindiscussions; + }).catch(() => { + this.canPin = false; + }); + } else { this.canPin = false; - }); + } }).then(() => { return this.ratingOffline.hasRatings('mod_forum', 'post', 'module', this.cmId, this.discussionId).then((hasRatings) => { this.hasOfflineRatings = hasRatings; diff --git a/src/addon/mod/forum/providers/forum.ts b/src/addon/mod/forum/providers/forum.ts index 91f1d2dad..6bd80e7bd 100644 --- a/src/addon/mod/forum/providers/forum.ts +++ b/src/addon/mod/forum/providers/forum.ts @@ -14,6 +14,7 @@ import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; +import { CoreSite } from '@classes/site'; import { CoreAppProvider } from '@providers/app'; import { CoreFilepoolProvider } from '@providers/filepool'; import { CoreGroupsProvider } from '@providers/groups'; @@ -784,6 +785,19 @@ export class AddonModForumProvider { }); } + /** + * Returns whether the set pin state WS is available. + * + * @param {CoreSite} [site] Site. If not defined, current site. + * @return {boolean} Whether it's available. + * @since 3.7 + */ + isSetPinStateAvailableForSite(site?: CoreSite): boolean { + site = site || this.sitesProvider.getCurrentSite(); + + return this.sitesProvider.wsAvailableInCurrentSite('mod_forum_set_pin_state'); + } + /** * Pin or unpin a discussion. *