diff --git a/assets/css/components/friends/ui.css b/assets/css/components/friends/ui.css
index f0c22cce..a2e22064 100644
--- a/assets/css/components/friends/ui.css
+++ b/assets/css/components/friends/ui.css
@@ -39,4 +39,8 @@
.personnal-friends-list .friend .friends-actions {
display: inline-block;
width: 250px;
+}
+
+.personnal-friends-list .friend .friends-actions .btn {
+ width: 100px;
}
\ No newline at end of file
diff --git a/assets/js/components/friends/interface.js b/assets/js/components/friends/interface.js
index 6b7e29b4..fc8ef494 100644
--- a/assets/js/components/friends/interface.js
+++ b/assets/js/components/friends/interface.js
@@ -65,6 +65,27 @@ ComunicWeb.components.friends.interface = {
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
},
+ /**
+ * Update the posts text authorization status of a friend
+ *
+ * @param {number} friendID The ID of the target friend
+ * @param {boolean} allow TRUE if the user can post texts / FALSE else
+ * @param {function} callback
+ */
+ set_can_post_texts: function(friendID, allow, callback){
+
+ //Prepare API request
+ var apiURI = "friends/set_can_post_texts";
+ var params = {
+ friendID: friendID,
+ allow: allow
+ };
+
+ //Perform API request
+ ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
+
+ },
+
/**
* Remove a user from the friend list
*
diff --git a/assets/js/components/friends/ui.js b/assets/js/components/friends/ui.js
index af60fa88..62b98c7d 100644
--- a/assets/js/components/friends/ui.js
+++ b/assets/js/components/friends/ui.js
@@ -142,13 +142,12 @@ ComunicWeb.components.friends.ui = {
followButton.setAttribute("data-set-following", "true");
}
else {
- followButton.innerHTML = "Following";
+ followButton.innerHTML = " Following";
followButton.setAttribute("data-set-following", "false");
}
add_space(actionsOnFriendArea);
- //Check if the user can post text on user page
followButton.onclick = function(){
//Check if the request is to follow or not the user
@@ -170,6 +169,40 @@ ComunicWeb.components.friends.ui = {
});
}
+
+ //Check if the user can post text on user page
+ var postTextsButton = createElem2({
+ appendTo: actionsOnFriendArea,
+ type: "button",
+ class: "btn btn-primary"
+ });
+
+ if(friend.canPostTexts){
+ postTextsButton.innerHTML = " Post Texts";
+ postTextsButton.setAttribute("data-allow-post-texts", "false");
+ }
+ else {
+ postTextsButton.innerHTML = "Post Texts";
+ postTextsButton.setAttribute("data-allow-post-texts", "true");
+ }
+
+ //Make the button lives
+ postTextsButton.onclick = function(){
+
+ //Check out if we have to allow or disallow texts post
+ var allow_post = this.getAttribute("data-allow-post-texts") == "true";
+
+ //Update the status
+ ComunicWeb.components.friends.interface.set_can_post_texts(friendID, allow_post, function(r){
+
+ if(r.error)
+ ComunicWeb.common.notificationSystem.showNotification("Could not update posts creation status !", "danger");
+
+ //Update friendship informations
+ ComunicWeb.components.friends.actions.refresh_single_personnal(friendID, friendContener);
+
+ });
+ }
}