<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>ConversationCode</web>
<name>Actions</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1357027200000</creationDate>
<date>1357027200000</date>
<contentUpdateDate>1357027200000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}
## check token
#if("$!request.action" != "" &amp;&amp; !$services.csrf.isTokenValid("$!request.form_token"))
  $response.sendRedirect($services.csrf.getResubmissionURL())
#else
  #if("$!request.action" == "addtopic")
    #if("$!request.title.trim()" != '')
      #if("$!request.space" != '')
        #set($newTopicName = $request.page)
        #set($topicTitle = "$!request.title.trim()")
        #set($topicDoc = $xwiki.getDocument($newTopicName))
        #if($topicDoc.hasAccessLevel('edit'))
          ## Add the TopicClass object
          #set($discard = $topicDoc.updateObjectFromRequest('ConversationCode.TopicClass'))
          $topicDoc.setTitle($topicTitle)
          $topicDoc.setParent("$!request.parent")
          #set($discard = $topicDoc.saveWithProgrammingRights())
          #if("$!request.xredirect" != "")
            $response.sendRedirect("$!request.xredirect")
          #end
        #else
          $response.setStatus(403)
          {{warning}}$msg.get("conversations.create.error.topic.norights"){{/warning}}
        #end
      #else
        {{warning}}$msg.get('conversations.create.error.missingmetadata'){{/warning}}
      #end
    #else
      $response.setStatus(403)
      {{warning}}$msg.get('conversations.create.error.missingtitle'){{/warning}}
    #end  
  #elseif("$!request.action" == "addconversation")
    #set($spaceName = "$!request.space")
    #set($topicName = "$!request.page")
    #if($spaceName != '' &amp;&amp; $topicName != '')
      #set($newAnswerName = $topicName)
      ## Make sure that the doc name is not oversized (it should be safe because topic name should be short, but we take an extra measure in case the doc is not created with the default creation form located in a topic page)
      ##if($newAnswerName.length() &gt; 250)
      ##set($newAnswerName = $newAnswerName.substring(0, 250))
      ##end
      ##set($newAnswerDocName = "${spaceName}.${newAnswerName}")
      #set($newAnswerDocName = $topicName)
      #set($newAnswerDoc = $xwiki.getDocument($newAnswerDocName))
      #if($newAnswerDoc.hasAccessLevel('edit')) 
          $newAnswerDoc.setParent("${request.parent}")
          #set($discard = $newAnswerDoc.updateObjectFromRequest('ConversationCode.AnswerClass'))
          #set($discard = $newAnswerDoc.saveWithProgrammingRights())
          #if("$!request.xredirect" != "")
            $response.sendRedirect("$!request.xredirect")
          #end
      #else
        $response.setStatus(403)
        {{warning}}$msg.get('conversations.create.error.answer.norights')
${spaceName}.${newAnswerName}
{{/warning}}
      #end    
    #else
      {{warning}}Not enough parameters.{{/warning}}
    #end
  #elseif ("$!request.action" == "deleteconversation" || "$!request.action" == "deletecomment")
    #set($isDeleteComment = "$!request.action" == "deletecomment")
    #set($conversationDoc = $xwiki.getDocument("$!request.conversationdoc"))
    #set($conversationObj = $conversationDoc.getObject('ConversationCode.AnswerClass'))
    #set($topicObj = $conversationDoc.getObject('ConversationCode.TopicClass'))
    #if ($isDeleteComment)
      #set($commentNumber = $util.parseInt("$!request.commentnumber"))
      #set($commentObj = $conversationDoc.getObject('XWiki.XWikiComments', $commentNumber))
    #end
    #if (!$conversationDoc.isNew() &amp;&amp; ($conversationObj||$topicObj) &amp;&amp; (!$isDeleteComment || $commentObj))
      ## check rights
      #set($requiredRight = 'edit')
      #if (!$isDeleteComment)
        #set($requiredRight = 'delete')
      #end
      #if($conversationDoc.hasAccessLevel($requiredRight))
        ## do the action then send a mail
        ## 0. collect some data we need after
        ## get a representation of the deleted item
        #set($itemRepresentation = "")
        #if ($isDeleteComment)
          #set($itemRepresentation = $commentObj.getProperty('comment').value)
        #else
          #set($itemRepresentation = $conversationDoc.displayTitle)
        #end
        ## get the item author to send mail after
        #set($itemAuthor = '')
        #if ($isDeleteComment)
          #set($itemAuthor = $commentObj.getProperty('author').value)
        #else
          #set($itemAuthor = $conversationDoc.creator)
        #end
        ## 1. do the action
        #if($isDeleteComment)<commit_msg>CURRIKI-6292 Creator of topic (A member) unable delete an answer posted by another member or group leader.<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>ConversationCode</web>
<name>Actions</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1357027200000</creationDate>
<date>1357027200000</date>
<contentUpdateDate>1357027200000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}
## check token
#if("$!request.action" != "" &amp;&amp; !$services.csrf.isTokenValid("$!request.form_token"))
  $response.sendRedirect($services.csrf.getResubmissionURL())
#else
  #if("$!request.action" == "addtopic")
    #if("$!request.title.trim()" != '')
      #if("$!request.space" != '')
        #set($newTopicName = $request.page)
        #set($topicTitle = "$!request.title.trim()")
        #set($topicDoc = $xwiki.getDocument($newTopicName))
        #if($topicDoc.hasAccessLevel('edit'))
          ## Add the TopicClass object
          #set($discard = $topicDoc.updateObjectFromRequest('ConversationCode.TopicClass'))
          $topicDoc.setTitle($topicTitle)
          $topicDoc.setParent("$!request.parent")
          #set($discard = $topicDoc.saveWithProgrammingRights())
          #if("$!request.xredirect" != "")
            $response.sendRedirect("$!request.xredirect")
          #end
        #else
          $response.setStatus(403)
          {{warning}}$msg.get("conversations.create.error.topic.norights"){{/warning}}
        #end
      #else
        {{warning}}$msg.get('conversations.create.error.missingmetadata'){{/warning}}
      #end
    #else
      $response.setStatus(403)
      {{warning}}$msg.get('conversations.create.error.missingtitle'){{/warning}}
    #end  
  #elseif("$!request.action" == "addconversation")
    #set($spaceName = "$!request.space")
    #set($topicName = "$!request.page")
    #if($spaceName != '' &amp;&amp; $topicName != '')
      #set($newAnswerName = $topicName)
      ## Make sure that the doc name is not oversized (it should be safe because topic name should be short, but we take an extra measure in case the doc is not created with the default creation form located in a topic page)
      ##if($newAnswerName.length() &gt; 250)
      ##set($newAnswerName = $newAnswerName.substring(0, 250))
      ##end
      ##set($newAnswerDocName = "${spaceName}.${newAnswerName}")
      #set($newAnswerDocName = $topicName)
      #set($newAnswerDoc = $xwiki.getDocument($newAnswerDocName))
      #if($newAnswerDoc.hasAccessLevel('edit')) 
          $newAnswerDoc.setParent("${request.parent}")
          #set($discard = $newAnswerDoc.updateObjectFromRequest('ConversationCode.AnswerClass'))
          #set($discard = $newAnswerDoc.saveWithProgrammingRights())
          #if("$!request.xredirect" != "")
            $response.sendRedirect("$!request.xredirect")
          #end
      #else
        $response.setStatus(403)
        {{warning}}$msg.get('conversations.create.error.answer.norights')
${spaceName}.${newAnswerName}
{{/warning}}
      #end    
    #else
      {{warning}}Not enough parameters.{{/warning}}
    #end
  #elseif ("$!request.action" == "deleteconversation" || "$!request.action" == "deletecomment")
    #set($isDeleteComment = "$!request.action" == "deletecomment")
    #set($conversationDoc = $xwiki.getDocument("$!request.conversationdoc"))
    #set($conversationObj = $conversationDoc.getObject('ConversationCode.AnswerClass'))
    #set($topicObj = $conversationDoc.getObject('ConversationCode.TopicClass'))
    #if ($isDeleteComment)
      #set($commentNumber = $util.parseInt("$!request.commentnumber"))
      #set($commentObj = $conversationDoc.getObject('XWiki.XWikiComments', $commentNumber))
    #end
    #if (!$conversationDoc.isNew() &amp;&amp; ($conversationObj||$topicObj) &amp;&amp; (!$isDeleteComment || $commentObj))
      ## check rights
      #set($requiredRight = 'edit')
      #if (!$isDeleteComment)
        #set($requiredRight = 'delete')
      #end
      #set($topicDoc = $xwiki.getDocument($conversationDoc.parent))
      #if($conversationDoc.hasAccessLevel($requiredRight)||$topicDoc.hasAccessLevel($requiredRight))
        ## do the action then send a mail
        ## 0. collect some data we need after
        ## get a representation of the deleted item
        #set($itemRepresentation = "")
        #if ($isDeleteComment)
          #set($itemRepresentation = $commentObj.getProperty('comment').value)
        #else
          #set($itemRepresentation = $conversationDoc.displayTitle)
        #end
        ## get the item author to send mail after
        #set($itemAuthor = '')
        #if ($isDeleteComment)
          #set($itemAuthor = $commentObj.getProperty('author').value)
        #else
          #set($itemAuthor = $conversationDoc.creator)
        #end
        ## 1. do the action
        #if($isDeleteComment)
{'fraction_non_alphanumeric': 0.16736239200077663, 'fraction_numerical': 0.013008445781962917, 'mean_word_length': 3.870921985815603, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 2, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081739', 'n_tokens_mistral': 3223, 'n_tokens_neox': 3110, 'n_words': 509}