locked
How to filter obscene/bad words in sharepoint 2010 blog

    Pregunta

  • How to filter obscene/bad words in sharepoint 2010 blog ? Any customization is required? or by modifying  blog.xsl ..

    jueves, 12 de mayo de 2011 5:26

Respuestas

  • Sure. Here are the steps in detail:
    1. open your blog site in SPD
    2. click List workflow from the ribbon and scroll down to the Posts list and select it
    3. give your workflow a name and (optionally) a description. The workflow opens in edit mode with a default empty step (step 1)
    4. Click Local Variables from the variables ribbon group and add a variable of type String (call it BadWords)
    5. click the first step (see where the orange bar is blinking) and select Action from the ribbon insert group, then select Set Workflow Variable (from core actions)
    6. click the blue link "Workflow variable" and pick your variable (BadWords)
    7. click Value (blue link), then click the ... and type your words in the string builder window in this format: word1 || word2 || word3 ...)
    8. add a new step (insert group)
    9. click Condition from the Insert group and select (from common conditions): if current item field equal value
    10. for field, select Body and then click Equals and select "Contains (ignoring case)" from the drop down.
    11. click Value, then click the Fx and change Current Item to Workflow variables and parameters (in data source). In field from source, select your variable (BadWords) and leave Return field as: String
    12. click the next line (blinking bar), insert action / list actions: update list item
    13. click This List, keep current item, then Add. Select Published from first drop down. Click the ... from the value box and click Specific date radio, then set it to a date in future (say a year from now)
    14. click under your last line (same indentation) and add another action: core actions: send e-mail
    15. click These Users. You can hard code the To field or just click the address book icon and select the user who created current item (and cc another user if you want)
    16. in the subject, put something like: Bad Blog Entry: [%Current Item:Title%] using the string builder and lookup
    17. in the message, you can write what you want and can also link the entry so it opens from a hyperlink. use the link icon for that. For example, to link title to edit item form, in the Text to display, use [%Current Item:Title%] and in the Address, use
      http://blog-address/_layouts/listform.aspx?PageType=6&ListId=\\{list-guid\\}&ID=[%Current Item:ID%]
      substitute for blog-address and list guid (this is the string of letters and numbers and - from your list, just hover over a title in the Posts list and it'll show in the status bar)
    18. check your wf for errors (Save group), go to WF settings (manage group) and set it to fire upon creation and change).
    19. Save and publish. Then test.

    Hope this is helpful!
    AK

    • Marcado como respuesta Paranoid123 viernes, 13 de mayo de 2011 11:05
    viernes, 13 de mayo de 2011 7:41
  • In the event receiver you can do whatever you want (set a custom hidden metadata for the comment that tells admins that the post/comment is not valid, sent an email to the admin, add a task in a tasks list linked to the current item). You should however try to avoid doing complex and long operations in event receivers.

    If you don't need to block the creation/update of the item, you can even use a shceduled job (a SharePoint timer job) that regularly scans the site for posts/comments with obscene words and then performs all the actions. The timer job solution is more adapted for long running and complex operations.


    Florin DUCA
    MCITP Enterprise Admin, MCSE 2003 +Sec, MCITP/MCPD SP 2010, MCTS conf/dev WSS3/MOSS, MCPD ASP.Net 3.5, MCTS ISA 2006
    Logica Business Consulting, France
    • Marcado como respuesta Paranoid123 jueves, 12 de mayo de 2011 12:21
    jueves, 12 de mayo de 2011 10:33

Todas las respuestas

  • You could do simple validation against some words in the posts and comments lists or intercept the content before it is saved using javascript (ex. delete words that match bad list). You could also set a workflow to alert you if a post or comment has such term.
    AK
    jueves, 12 de mayo de 2011 7:00
  • Thanks for help..Any link to proceed with workflow or javascript for bad words in the posts and comments ? I have been working more on XSLT. Please provide any help.

     

    jueves, 12 de mayo de 2011 7:36
  • <SCRIPT LANGUAGE="JavaScript">

     

    <!-- Begin
    // Enter the words to be filtered in the line below:
    var swear_words_arr=new Array("bloody","war","terror");

    var swear_alert_arr=new Array;
    var swear_alert_count=0;
    function reset_alert_count()
    {
     swear_alert_count=0;
    }
    function validate_user_text()
    {
     reset_alert_count();
     var compare_text=document.form1.user_text.value;
     for(var i=0; i<swear_words_arr.length; i++)
     {
      for(var j=0; j<(compare_text.length); j++)
      {
       if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
       {
        swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
        swear_alert_count++;
       }
      }
     }
     var alert_text="";
     for(var k=1; k<=swear_alert_count; k++)
     {
      alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
     }
     if(swear_alert_count>0)
     {
      alert("The form cannot be submitted.\nThe following illegal words were found:\n_______________________________\n" + alert_text + "\n_______________________________");
      document.form1.user_text.select();
     }
     else
     {
      document.form1.submit();
     }
    }
    function select_area()
    {
     document.form1.user_text.select();
    }
    window.onload=reset_alert_count;
    //  End -->
    </script>

     

    <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

    <div align="center">
    <form name="form1">
    <textarea rows="3" cols="40" name="user_text" style="border:2 solid #808080; font-family:verdana,arial,helvetica; font-weight:normal; font-size:10pt" onclick="select_area()">Enter your text here...</textarea><br><br>
    <input type="button" style="background:#EFEFEF; border:2 solid #808080; width:25%; cursor:pointer" value="Submit" onclick="validate_user_text();">
    </form>

    <p>Try entering the words "bloody", "war", or "terror" in the text box above.</p>
    </div>
    <!-- Script Size: -->

     

    Is this right ? 

    jueves, 12 de mayo de 2011 7:52
  • How to apply JS for the post and comments list in SP2010 ? or any suggestions..
    jueves, 12 de mayo de 2011 7:54
  • You can add a CEWP to the NewPost.aspx page and enter your js then trigger it on PreSaveAction.
    AK
    jueves, 12 de mayo de 2011 8:09
  • It may be overkill for what you are trying to achieve but a possibility is Forefront for SharePoint (http://www.microsoft.com/forefront/protection-for-sharepoint/en/us/features.aspx).


    Florin DUCA
    MCITP Enterprise Admin, MCSE 2003 +Sec, MCITP/MCPD SP 2010, MCTS conf/dev WSS3/MOSS, MCPD ASP.Net 3.5, MCTS ISA 2006
    Logica Business Consulting, France
    jueves, 12 de mayo de 2011 8:36
  • Please be more specific . My problem is I want to filter  obscene/bad words in comments and posts sharepoint 2010 blog .

    Kindly suggest best solution . Is java script for validation is best way? Using JS is best solution ? Does ForeFront solves for  obscene/bad words in comments and posts or only for users from uploading or downloading documents containing malware, out-of-policy content, or sensitive information to SharePoint libraries.

     

     

    jueves, 12 de mayo de 2011 9:16
  • Sorry for my post, I was a litle quick. Forefront will manage only the files it will do nothing to the SharePoint lists so it can't be used to scan the comments.

    Here is another solution: an event receiver that performs the test for obscene words in ItemAdding and ItemUpdating and cancels the add/update if obscene words are found. An event receiver is simpler to deploy and attach to blog and comment lists (through a feature) than a javascript test. Also users cannot remove the javascript test (by using IE developper toolbar for example).

    Here is a howto for creating an event handler : http://msdn.microsoft.com/en-us/library/ms437502.aspx


    Florin DUCA
    MCITP Enterprise Admin, MCSE 2003 +Sec, MCITP/MCPD SP 2010, MCTS conf/dev WSS3/MOSS, MCPD ASP.Net 3.5, MCTS ISA 2006
    Logica Business Consulting, France
    jueves, 12 de mayo de 2011 9:41
  • Thanks for the solution. Along with event receiver is there any way to alert the admin to delete the comment or post  instead of cancelling the add /update.
    jueves, 12 de mayo de 2011 10:16
  • In the event receiver you can do whatever you want (set a custom hidden metadata for the comment that tells admins that the post/comment is not valid, sent an email to the admin, add a task in a tasks list linked to the current item). You should however try to avoid doing complex and long operations in event receivers.

    If you don't need to block the creation/update of the item, you can even use a shceduled job (a SharePoint timer job) that regularly scans the site for posts/comments with obscene words and then performs all the actions. The timer job solution is more adapted for long running and complex operations.


    Florin DUCA
    MCITP Enterprise Admin, MCSE 2003 +Sec, MCITP/MCPD SP 2010, MCTS conf/dev WSS3/MOSS, MCPD ASP.Net 3.5, MCTS ISA 2006
    Logica Business Consulting, France
    • Marcado como respuesta Paranoid123 jueves, 12 de mayo de 2011 12:21
    jueves, 12 de mayo de 2011 10:33
  • Of course, event receiver will do, but can it be done with no code?
    I managed to get a workflow to trigger based on the contents of the submitted entry and alert the submitter (can be any one ore more persons). Will update this reply with more details when done.
    AK
    Edit: the workflow scenario is now explained in a blog post
    • Editado AbedKhooli jueves, 12 de mayo de 2011 13:33 added link
    jueves, 12 de mayo de 2011 12:28
  • AbedKhooli , Can you elaborate more of workflow .. 

    jueves, 12 de mayo de 2011 12:48
  • Any solution without code ? Please do needful help..

    jueves, 12 de mayo de 2011 12:58
  •  See edited post above.
    AK
    jueves, 12 de mayo de 2011 13:34
  • Thanks alot AK :)Can you provide any demo of your workflow.


    viernes, 13 de mayo de 2011 4:14
  • Sure. Here are the steps in detail:
    1. open your blog site in SPD
    2. click List workflow from the ribbon and scroll down to the Posts list and select it
    3. give your workflow a name and (optionally) a description. The workflow opens in edit mode with a default empty step (step 1)
    4. Click Local Variables from the variables ribbon group and add a variable of type String (call it BadWords)
    5. click the first step (see where the orange bar is blinking) and select Action from the ribbon insert group, then select Set Workflow Variable (from core actions)
    6. click the blue link "Workflow variable" and pick your variable (BadWords)
    7. click Value (blue link), then click the ... and type your words in the string builder window in this format: word1 || word2 || word3 ...)
    8. add a new step (insert group)
    9. click Condition from the Insert group and select (from common conditions): if current item field equal value
    10. for field, select Body and then click Equals and select "Contains (ignoring case)" from the drop down.
    11. click Value, then click the Fx and change Current Item to Workflow variables and parameters (in data source). In field from source, select your variable (BadWords) and leave Return field as: String
    12. click the next line (blinking bar), insert action / list actions: update list item
    13. click This List, keep current item, then Add. Select Published from first drop down. Click the ... from the value box and click Specific date radio, then set it to a date in future (say a year from now)
    14. click under your last line (same indentation) and add another action: core actions: send e-mail
    15. click These Users. You can hard code the To field or just click the address book icon and select the user who created current item (and cc another user if you want)
    16. in the subject, put something like: Bad Blog Entry: [%Current Item:Title%] using the string builder and lookup
    17. in the message, you can write what you want and can also link the entry so it opens from a hyperlink. use the link icon for that. For example, to link title to edit item form, in the Text to display, use [%Current Item:Title%] and in the Address, use
      http://blog-address/_layouts/listform.aspx?PageType=6&ListId=\\{list-guid\\}&ID=[%Current Item:ID%]
      substitute for blog-address and list guid (this is the string of letters and numbers and - from your list, just hover over a title in the Posts list and it'll show in the status bar)
    18. check your wf for errors (Save group), go to WF settings (manage group) and set it to fire upon creation and change).
    19. Save and publish. Then test.

    Hope this is helpful!
    AK

    • Marcado como respuesta Paranoid123 viernes, 13 de mayo de 2011 11:05
    viernes, 13 de mayo de 2011 7:41
  • Thanks AK .. Your Solution is just to the point .Awesome without code :) . In Addition ,I have created custom list to store the bad words named as "obsceneWordList" need to compare ' body ' of  "Post" . I tired to use -->DefineWorflowLookup . Getting some error here .

    "obsceneWordList" contains one column as word (Single line of text)


    viernes, 13 de mayo de 2011 11:05
  • Thank you. Glad you found it helpful.
    If you are storing the list of words in a custom list column (one item) - ex. to add/remove words without going back to SPD, use the same format for word separation. In the lookup, your second part should reference a unique column (ex. ID) and for value, use the ID of the row that has the words (usually 1 if you only had one item). You wouldn't need the first step in this case.
    AK
    viernes, 13 de mayo de 2011 15:06
  •  Ak ,Is there any other way to alert the admin besides sending mail ?  Best way to report Admin .. Any suggestions?

    sábado, 14 de mayo de 2011 5:42
  • Do you mean something like SMS? You can set alerts on the posts list for either e-mail or sms if enabled and configure the alert to be sent if items in a view (ex. bad posts) change. For the view, create a bad posts view (ex. those you set published in future).
    AK
    sábado, 14 de mayo de 2011 7:32
  • Not sms or email.. For the Admin , CQWP showing all the Blogs (ex. out of 10 blogs 3 blogs that have obscene/bad words in posts /comments).

    same logic used in workflow can be used in xslt to filter?

    sábado, 14 de mayo de 2011 12:08
  • You can certainly use CQWP filtered based on how you flag bad posts (comments are a separate list and you need to handle in the same way). You won't get stats OOB from the CQWP, but a custom view could give the count.
    AK
    sábado, 14 de mayo de 2011 13:02
  • Using xslt i can filter the posts and comments having bad words. by comparing 2 lists? ..Please elaborate more..
    martes, 17 de mayo de 2011 5:12
  • In ItemStyle.xsl  , Need to create new template for filtering  blogs with bad words in comments and posts. Actually I want to compare "Body" of Post (list)

    with "Words" of WordControl(custom lists). Is it possible ?

    jueves, 19 de mayo de 2011 10:45
  • Any help?
    lunes, 23 de mayo de 2011 7:43
  • How to create linked source using SPD 2010?

     

     I cannot find , task pane>>data source library >> linked source  in SPD 2010 ?

     

    miércoles, 25 de mayo de 2011 3:45
  • In navigation, under site objects, click Data Sources. The ribbon should have one tab (in addition to File) called Data Sources. Linked Data Source is first from left.
    AK
    miércoles, 25 de mayo de 2011 5:08
  • Paranoid, your one-line question has turned into an entire book chapter.  AK has spent a ton of time helping you, but this has become a full consultation, which is not appropriate for the free forums.  Again, AK has done a commendable job, but you need to spend time searching and testing things instead of continually stacking question after question into the same thread.

    For example, creating a data source in SPD can be found with a quick Bing search.  I'm closing this thread, because it's already huge.  If you have more questions, create new threads for each one.

    Thanks!


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    miércoles, 25 de mayo de 2011 6:42