cancel
Showing results for 
Search instead for 
Did you mean: 

Users unable to add comment to a blog or discusison in site

lavanya
Champ in-the-making
Champ in-the-making
We created a site by using the admin privileges. Also created couple of users through alfresco web client. We are able to log on to the alfresco share application with those user ids as well. Then we invited couple of users to the site created by admin (with admin login). With admin user id, we also created a blog and a thread.
Then we logged in with these invited user ids and tried to add comments to blog and threads. But, when we click on read of a blog we don't see the comments text area. In fact there is nothing for the user to add a comment. We tried giving different prvileges (like contributor, collaborator etc) to the invited users, but we are not able to add comments to a blog or create a blog. Same thing with discussions.

Also the create blog and create topic(discussion) links are disabled for these users.

We tried to create the site with these user ids. The user who created the site is having these privileges. But the users that are invited to the site are not able to do the same.

Are we missing anything? It seems that we have missed some basic configuration as these are basic things. Can someone help us in resolving these issues?

Regards,
Lavanya
2 REPLIES 2

mrogers
Star Contributor
Star Contributor

nitis
Champ in-the-making
Champ in-the-making
Hi,

An easy solution, at least for 3.0 Community version is editing the file blog-posts.post.json.js, which is in the path <ALFERSCO_HOME/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.json.js, and looks like this:

<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/nodenameutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">

function ensureTagScope(node)
{
   if (! node.isTagScope)
   {
      node.isTagScope = true;
   }
  
   // also check the parent (the site!)
   if (! node.parent.isTagScope)
   {
      node.parent.isTagScope = true;
   }
}

/**
* Creates a blog post
*/
function createBlogPost(blogNode)
{
   // fetch the data required to create the post
   var title = "";
   if (json.has("title"))
   {
      title = json.get("title");
   }
   var content = "";
   if (json.has("content"))
   {
      content = json.get("content");
   }
   var tags = [];
   if (json.has("tags"))
   {
      // get the tags JSONArray and copy it into a real javascript array object
      var tmp = json.get("tags");
      for (var x=0; x < tmp.length(); x++)
      {
          tags.push(tmp.get(x));
      }
   }
  
   // get a unique name
   var nodeName = getUniqueChildName(blogNode, "post");
  
   // we simply create a new file inside the blog folder
   var postNode = blogNode.createNode(nodeName, "cm:content");

   // set values where supplied
   postNode.properties.title = title;
   postNode.mimetype = "text/html";
   postNode.content = content;
   postNode.tags = tags;
   postNode.save();
  
   // add the aspect and create the forum as well as the comments topic 
   postNode.addAspect("fm:discussable");
   var forumNode = postNode.createNode("Forum", "fm:forum", "fm:discussion");
   commentsFolder = forumNode.createNode(COMMENTS_TOPIC_NAME, "fm:topic", "cm:contains");
  
   // check whether it is in draft mode
   var isDraft = json.has("draft") && json.get("draft").toString() == "true";
   if (isDraft)
   {
      // disable permission inheritance. The result is that only
      // the creator will have access to the draft
      postNode.setInheritsPermissions(false);
   }
   else
   {
      setOrUpdateReleasedAndUpdatedDates(postNode);
   }

   return postNode;
}

function main()
{
   // get requested node
   var node = getRequestNode();
   if (status.getCode() != status.STATUS_OK)
   {
      return;
   }
  
   ensureTagScope(node);

   var post = createBlogPost(node);
   model.item = getBlogPostData(post);
   model.externalBlogConfig = hasExternalBlogConfiguration(node);
  
   if (json.has("site") && json.has("container") && json.has("page") && !model.item.isDraft)
   {
      var data =
      {
         title: model.item.node.properties.title,
         page: json.get("page") + "?postId=" + model.item.node.properties.name
      };
      activities.postActivity("org.alfresco.blog.post-created", json.get("site"), "blog", jsonUtils.toJSONString(data));
   }
}

main();

The lines

   // add the aspect and create the forum as well as the comments topic 
   postNode.addAspect("fm:discussable");
   var forumNode = postNode.createNode("Forum", "fm:forum", "fm:discussion");
   commentsFolder = forumNode.createNode(COMMENTS_TOPIC_NAME, "fm:topic", "cm:contains");


Simply will create, when you ar posting a blog entry, a node named Comments where members, without admin privilegs, will be able to post comments.

I hope It will be useful.

Bye