solved Block comments

alt=
@dim
6 years ago
167 posts
Hi guys,
Is it possible for a profile owner to be able to block comments on his profile for some users? An analogue of this is a block of private messages. Any ideas?
updated by @dim: 04/15/18 06:35:48PM
paul
@paul
6 years ago
4,326 posts
Create or clone a quota with the posting of comments disabled then switch these users to it.
Hth


--
Paul Asher - JR Developer and System Import Specialist
Strumelia
Strumelia
@strumelia
6 years ago
3,603 posts
I think Dim means that for instance user Mary wants to prevent user Jack from posting comments on her profile page comment wall, but Mary doesn't want to block everyone from posting on her comment wall.... just Jack. Meanwhile, Jack can continue posting as usual on other people's profile comment walls... just not on Mary's.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
michael
@michael
6 years ago
7,714 posts
currently no. Mary can not choose to block just Jack from posting comments on her profile page.

It would need a custom module to be built. Or it MIGHT be possible with a custom Form Field via the Form Designer added to profiles then some adjustments to the skins templates. Like if Mary entered a comma separated list of users to block, then the comment form on the profile checked for that before displaying the input box.... might work.
alt=
@dim
6 years ago
167 posts
@strumelia,
Thanks for your clarification. You correctly described my idea ;)

michael:
currently no. Mary can not choose to block just Jack from posting comments on her profile page.

It would need a custom module to be built. Or it MIGHT be possible with a custom Form Field via the Form Designer added to profiles then some adjustments to the skins templates. Like if Mary entered a comma separated list of users to block, then the comment form on the profile checked for that before displaying the input box.... might work.
I thought about it. It would be possible to show the comment form with a condition.
{if $item.user_name = $profile_BLOCK_USER}
comment form is not displayed
{else}
comment form is displayed
{/if}
But I'm not sure how to write the condition correctly....... $item.user_name is not correct variable. Any ideas?
michael
@michael
6 years ago
7,714 posts
Right.

You'd add a form field maybe 'profile_nocomment' to the Profile (site.com/profile/settings) form using the Form Designer

Docs: "Using the Form Designer"
https://www.jamroom.net/the-jamroom-network/documentation/getting-started/1275/using-the-form-designer

Then get your users to input comma separated values of the profiles they dont want to comment.

so $profile_nocomment would print out as '1,24,27,451,256', something like that depending on what they entered.

Then the code would be
{$blocked =  explode(',',$profile_nocomment)}
{if is_array($blocked) && !in_array($_user._user_id, $blocked)} 
// show the comment form
{/if}
alt=
@dim
6 years ago
167 posts
@michael
Great! But users are not able to know "user_id". So I used "$ _user._user_name" and it does not work.
{$blocked =  explode(',',$profile_nocomment)}
{if is_array($blocked) && !in_array($_user._user_name, $blocked)} 
// show the comment form
{/if}
Maybe you have more ideas? ;)
updated by @dim: 01/11/18 05:26:44AM
paul
@paul
6 years ago
4,326 posts
If users are entering profile names, try this instead -
{$blocked =  explode(',',$profile_nocomment)}
{if is_array($blocked) && !in_array($_user.profile_name, $blocked)} 
// show the comment form
{/if}
hth


--
Paul Asher - JR Developer and System Import Specialist
alt=
@dim
6 years ago
167 posts
@paul
Unfortunately it does not work :(
paul
@paul
6 years ago
4,326 posts
The comma separated profile names entered in the nocomment field would need to be exactly right, case sensitive and with no leading or trailing spaces.


--
Paul Asher - JR Developer and System Import Specialist
alt=
@dim
6 years ago
167 posts
paul:
The comma separated profile names entered in the nocomment field would need to be exactly right, case sensitive and with no leading or trailing spaces.
That's exactly what I did.
Did you check your code? Does it work on your website?
I think that the variable "$ _user.profile_name" is not correct. The template uses a different variable - {jrUser_home_profile_key key="profile_name"} - How can I embed it in our code?
{if is_array($blocked) && !in_array($_user.profile_name, $blocked)}
paul
@paul
6 years ago
4,326 posts
OK - Try this mod to the jrComment comment_form.tpl template -
{jrCore_module_url module="jrComment" assign="curl"}
<a id="{$jrComment.unique_id}_cm_section"></a>
<a id="comment_section"></a>

{if isset($jrComment.comment_order_by)}
    {$dir = $jrComment.comment_order_by}
{else}
    {$dir = $_conf.jrComment_direction}
{/if}

<div id="{$jrComment.unique_id}_comments" class="comment_page_section">

    {* see if profile owners can delete *}
    {assign var="profile_owner_id" value=0}
    {if $_user.user_active_profile_id == $_item._profile_id && $_item.quota_jrComment_profile_delete == 'on'}
        {assign var="profile_owner_id" value=$_item._profile_id}
    {/if}

    {if $jrComment.pagebreak > 0}
        {jrCore_list module="jrComment" search="comment_item_ckey = `$jrComment.item_id`:`$jrComment.module`:i" order_by="_item_id `$dir`" profile_owner_id=$profile_owner_id pagebreak=$_conf.jrComment_pagebreak page=1 pager=true pager_template="comment_pager.tpl"}
    {else}
        {jrCore_list module="jrComment" search="comment_item_ckey = `$jrComment.item_id`:`$jrComment.module`:i" order_by="_item_id `$dir`" limit=500 profile_owner_id=$profile_owner_id}
    {/if}

</div>

{if jrUser_is_logged_in() && $_user.quota_jrComment_allowed == 'on'}

  {$_blocked =  explode(',', strtolower($jrComment['item']['profile_nocomment']))}
  {$pn = strtolower($_user['profile_name'])}
  {if is_array($_blocked) && !in_array($pn, $_blocked)} 

    <div id="comment_form_holder">
    <div id="comment_form_section">

        <div id="{$jrComment.unique_id}_cm_notice" class="item error" style="display:none;">
            {* any comment error loads here *}
        </div>

        {if $_conf.jrComment_threading == 'on' && $_conf.jrComment_editor == 'on'}
        <div id="comment_reply_to" class="item success" style="display:none;">
            {* small note about how you are replying to when editor is enabled *}
            {jrCore_lang module="jrComment" id=18 default="Your Reply To:"} <strong><span id="comment_reply_to_user"></span></strong>
        </div>
        {/if}

        <div class="item" style="display:table">
            <div style="display:table-row">
                <div class="p5" style="display:table-cell;width:5%;vertical-align:top;">
                    {jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$_user._user_id size="small" alt=$item.user_name class="action_item_user_img iloutline" _v=$_user.user_image_time}
                </div>
                <div class="p5" style="display:table-cell;width:95%;padding:5px 12px;">

                    <a id="cform"></a>
                    <form id="{$jrComment.unique_id}_form" action="{$jamroom_url}/{$curl}/comment_save" method="POST" onsubmit="jrPostComment('#{$jrComment.unique_id}', 'undefined', 500);return false">

                        <input type="hidden" id="{$jrComment.unique_id}_cm_module" name="comment_module" value="{$jrComment.module}">
                        <input type="hidden" id="{$jrComment.unique_id}_cm_profile_id" name="comment_profile_id" value="{$jrComment.profile_id}">
                        <input type="hidden" id="{$jrComment.unique_id}_cm_item_id" name="comment_item_id" value="{$jrComment.item_id}">
                        <input type="hidden" id="{$jrComment.unique_id}_cm_order_by" name="comment_order_by" value="{$dir}">
                        <input type="hidden" id="comment_parent_id" name="comment_parent_id" value="0">

                        {if isset($_conf.jrComment_editor) && $_conf.jrComment_editor == 'on' && !jrCore_is_mobile_device()}
                            {jrCore_editor_field name="comment_text"}
                        {else}
                            <textarea id="comment_text" name="comment_text" cols="40" rows="5" class="form_textarea {$jrComment.class}" style="height:64px;width:98%;{$jrComment.style}"></textarea><br>
                        {/if}
                        <div style="vertical-align:middle">
                            {jrCore_lang module="jrCore" id="73" default="working..." assign="working"}
                            {jrCore_image image="form_spinner.gif" id="`$jrComment.unique_id`_fsi" width="24" height="24" alt=$working style="margin:8px 8px 0px 8px;display:none"}<input id="{$jrComment.unique_id}_cm_submit" type="submit" value="{jrCore_lang module="jrComment" id="2" default="Save Comment"}" class="form_button {$jrComment.class}" style="margin-top:8px;{$jrComment.style}">
                        </div>

                        {if $_user.quota_jrComment_attachments == 'on'}
                        <div class="jrcomment_upload_attachment">
                            {jrCore_upload_button module="jrComment" field="comment_file" allowed="`$_user.quota_jrComment_allowed_file_types`" multiple="true"}
                        </div>
                        {/if}
                        <div style="clear:both"></div>

                    </form>

                </div>
            </div>
        </div>
    </div>
    </div>
    
  {/if}

{elseif jrUser_is_logged_in() === false}

    {jrCore_module_url module="jrUser" assign="url"}
    <div class="item"><div class="p5"><a href="{$jamroom_url}/{$url}/login">{jrCore_lang module="jrComment" id=16 default="You must be logged in to post a comment"}</a></div></div>

{/if}
See the added code lines 29-31 and line 88
Tested and working. The 'strtolower's make sure that profile name entries in the custom field are now not case sensitive, but no leading or trailing spaces are still a requirement.
hth


--
Paul Asher - JR Developer and System Import Specialist
alt=
@dim
6 years ago
167 posts
Thank you @paul
It really works now!

Tags