By default there is no remove button in comments list. You can add comment, edit it or reply comment. But you can not delete it.
Here is detail instruction how you can add this functionality.
To implement this you need access to change core Vtiger files.
You can also hide this button from users by disabling delete permissions in default roles permissions functionality.
First, let's add buttons to our template files:
layouts/v7/modules/Vtiger/Comment.tpl after 76
After this block:
{if $COMMENTS_MODULE_MODEL->isPermitted('EditView')}
{if $CHILDS_ROOT_PARENT_MODEL}
{assign var=CHILDS_ROOT_PARENT_ID value=$CHILDS_ROOT_PARENT_MODEL->getId()}
{/if}
<a href="javascript:void(0);" class="cursorPointer replyComment feedback" style="color: blue;">
{vtranslate('LBL_REPLY',$MODULE_NAME)}
</a>
{if $CURRENTUSER->getId() eq $COMMENT->get('userid')}
<a href="javascript:void(0);" class="cursorPointer editComment feedback" style="color: blue;">
{vtranslate('LBL_EDIT',$MODULE_NAME)}
</a>
{/if}
{/if}
Add this lines:
{if $COMMENTS_MODULE_MODEL->isPermitted('Delete')}
{if $CHILDS_ROOT_PARENT_MODEL}
{assign var=CHILDS_ROOT_PARENT_ID value=$CHILDS_ROOT_PARENT_MODEL->getId()}
{/if}
<a href="javascript:void(0);" class="cursorPointer deleteComment feedback" style="color: blue;">
{vtranslate('LBL_DELETE',$MODULE_NAME)}
</a>
{/if}
Then we need to add button in widgets block. Let's edit following file:
layouts/v7/modules/Vtiger/RecentComments.tpl after 163
Find this block:
{if $CURRENTUSER->getId() eq $COMMENT->get('userid') && $IS_EDITABLE}
{if $IS_CREATABLE} {/if}
<a href="javascript:void(0);" class="cursorPointer editComment feedback" style="color: blue;">
{vtranslate('LBL_EDIT',$MODULE_NAME)}
</a>
{/if}
Insert this lines:
{if $COMMENTS_MODULE_MODEL->isPermitted('Delete')}
{if $CHILDS_ROOT_PARENT_MODEL}
{assign var=CHILDS_ROOT_PARENT_ID value=$CHILDS_ROOT_PARENT_MODEL->getId()}
{/if}
<a href="javascript:void(0);" class="cursorPointer deleteComment feedback" style="color: blue;">
{vtranslate('LBL_DELETE',$MODULE_NAME)}
</a>
{/if}
Then we need to edit javascript file to make our button interactive. Let's change file:
layouts/v7/modules/Vtiger/resources/Detail.js after 2908
Find this block:
detailContentsHolder.on('click','.editComment', function(e){
self.removeCommentBlockIfExists();
var currentTarget = jQuery(e.currentTarget);
var commentInfoBlock = currentTarget.closest('.singleComment');
var commentInfoContent = commentInfoBlock.find('.commentInfoContent');
var commentReason = commentInfoBlock.find('[name="editReason"]');
var editCommentBlock = self.getEditCommentBlock();
var fullComment = commentInfoContent.data('fullcomment');
if (fullComment) {
fullComment = app.helper.getDecodedValue(fullComment);
} else {
fullComment = commentInfoContent.text();
}
editCommentBlock.find('.commentcontent').text(fullComment);
editCommentBlock.find('[name="reasonToEdit"]').val(commentReason.text());
editCommentBlock.find('[name="is_private"]').val(commentInfoBlock.find('[name="is_private"]').val());
/*commentInfoContent.hide();
commentInfoBlock.find('.commentActionsContainer').hide();*/
editCommentBlock.appendTo(commentInfoBlock).show();
});
Insert this lines:
detailContentsHolder.on('click','.deleteComment', function(e){
var currentTarget = jQuery(e.currentTarget);
var commentInfoBlock = currentTarget.closest('.singleComment');
var commentInfoHeader = commentInfoBlock.find('.commentInfoHeader');
var commentId = commentInfoHeader.data('commentid');
var params = {
'module': 'ModComments',
'action': 'Delete',
'crmid':commentId
};
app.helper.showProgress();
app.request.post({data: params}).then(
function(err, data) {
if (err === null) {
commentInfoBlock.remove();
app.helper.showSuccessNotification({message:'Comment Deleted Successfully'});
} else {
app.helper.showErrorNotification({message: err.message});
}
app.helper.hideProgress();
});
});
Then we need implement delete functionality in Comments delete model. Just rewrite following file:
modules/ModComments/actions/Delete.php
With this code:
<?php
class ModComments_Delete_Action extends Vtiger_Delete_Action {
function checkPermission(Vtiger_Request $request) {
//throw new AppException(vtranslate('LBL_PERMISSION_DENIED'));
parent::checkPermission($request);
}
public function process(Vtiger_Request $request) {
$moduleName = $request->getModule();
$recordId = $request->get('crmid');
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$moduleModel = $recordModel->getModule();
$recordModel->delete();
$response = new Vtiger_Response();
$response->setResult(array('success' => true));
return $response;
}
}