MOBILE-2989 forum: Check whether the set pin state WS is available
parent
8cdca2ebd9
commit
ad6d5019f1
|
@ -351,12 +351,16 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
this.ratingInfo = ratingInfo;
|
this.ratingInfo = ratingInfo;
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
if (this.forumProvider.isSetPinStateAvailableForSite()) {
|
||||||
// Use the canAddDiscussion WS to check if the user can pin discussions.
|
// Use the canAddDiscussion WS to check if the user can pin discussions.
|
||||||
return this.forumProvider.canAddDiscussionToAll(this.forumId).then((response) => {
|
return this.forumProvider.canAddDiscussionToAll(this.forumId).then((response) => {
|
||||||
this.canPin = !!response.canpindiscussions;
|
this.canPin = !!response.canpindiscussions;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.canPin = false;
|
this.canPin = false;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.canPin = false;
|
||||||
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.ratingOffline.hasRatings('mod_forum', 'post', 'module', this.cmId, this.discussionId).then((hasRatings) => {
|
return this.ratingOffline.hasRatings('mod_forum', 'post', 'module', this.cmId, this.discussionId).then((hasRatings) => {
|
||||||
this.hasOfflineRatings = hasRatings;
|
this.hasOfflineRatings = hasRatings;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { CoreSite } from '@classes/site';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||||
import { CoreGroupsProvider } from '@providers/groups';
|
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.
|
* Pin or unpin a discussion.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue