By shoulders on Sunday, 19 February 2017
Posted in Technical Issues
Replies 18
Likes 0
Views 687
Votes 0
Hi,

I am planning my komento plugin for RSFeedback (unless anyone already has such a plugin) and reading the plugins already in komento other than cobolt none of them seem to be rigged up to delete komento entries on deletion of the article from the software the plugin represents.

Can you confirm if this is correct, that when an article in k2 or download jdownloads etc.., is deleted that the corresponding komento entries are not deleted? If they are deleted can you tell me which function is supposed to do this.

Thanks

shoulders
Hello Shoulders,

2) i prefer the inclusion of the deletion code in the plugin. it keeps it centralized and is more logical. Also for 3rd party developers who use other systems give them the opportunity to add something similar there whilst maintaining standards. Small time developers like myself can also see the extra functionality and add it. Lastly it allows this extra feature to be added to existing plugins with backward compatability.
-- When you mention plugin, did you refer to the Komento Plugins (../components/com_komento/komento_plugins/)? If yes, even if the function were added inside the plugin file, you still need to load the application in your component file to trigger the function. For instance, you were to trigger this function onBeforeLoad, you will need to do this:

$application = KT::loadApplication('com_content');
$continueRendering = $application->onBeforeLoad($eventTrigger, $context, $article, $params, $page, $options);

which, in my opinion, adding the function in your joomla plugin would be easier as you just need to include the Komento library and run this code:

KT::deleteComment('com_content', $article->id);



3) now to my proposed functions can you consider the following:
- deleteComments($component, $cid) - this will delete comments for one article
- deleteComments($component, $cid = array() ) - this will delete comments for all article(s) supplied
- deleteAllComments($component) - this will delete all comments for a component

-- I can add this in our library.


- checkOrphanedComments($component) - this will return a list/array or comments that do not belong to an article for that component. this is useful to find comments for deleted articles in the component caused by previous versions of komento which do not have the delete function.

-- This quite a neat function. It is good to keep the comment table clean.


- moveComments($component, $cid, $target_cid) - this function allows the component to move the comments to a new article (i will leave the merge logic to you). This function will only allow the moving of comments within the component. I dont know if a finer grain movement is required i.e. for individual comments

-- I will check the structure if this is easy to implement.
·
Monday, 06 March 2017 11:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello shoulders,

The deletion of the article is dependent on the plugin. When an article / object is deleted, the extension or it's plugin needs to delete the comments manually.

In your case, if an object from RSFeedback is deleted, then you could either write a plugin that hooks onto RSFeedback so that when it is deleted, it would also delete comments for that article.

Currently, Komento doesn't handle those deletions because most of the time, site owner's wouldn't want those comments to be deleted immediately.
·
Sunday, 19 February 2017 13:34
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

just a quick follow up.

1) I dont seem to get emails ever from your website, perhaps it is being classed as spam, adding a SPF record would fix the issue

2) The article in RSFeedback is deleted by RSFeedback. I want to get the corresponding comments in komento deleted when I delete this article, not the other way around. (have i read your answer wrong?)

3) In your API for Komento there is no delete option/function, can you clarify this is the case? If so, can you add one.

4) Komento does not have a orphaned comments deletion routine, perhaps add this to the scripts section. Like garbage collection the routine would check the article/thing still existed for each comment and if not would delete the comment(s), or going further would give you a table at the end and you could delete by component or individual items.

5) "Currently, Komento doesn't handle those deletions because most of the time, site owner's wouldn't want those comments to be deleted immediately. " Not sure about that as the can no longer be accessed because the article is gone.

6) so if i am correct that there is no API deletion option for comments in 3rd party software, how do the comments ever get deleted?

Thanks

shoulders
·
Sunday, 19 February 2017 23:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Currently we only have these event trigger available in Komento, you can refer on our event trigger infomation here https://stackideas.com/docs/komento/administrators/advance/triggers

For those delete article function is base on how the 3rd party component whether they allow 3rd party component to trigger it after delete that article.

Try check this component 'RSFeedback' how it delete function work, if those component allow 3rd party component to trigger, it should show following similar code from the delete article function code.


JPluginHelper::importPlugin('yourPluginComponentName');
$dispatcher = JDispatcher::getInstance();

// Trigger
$dispatcher->trigger('onAfterYourComponentDelete', array(&$this));


So you have to create a plugin to trigger this 'onAfterYourComponentDelete' then execute a SQL query to delete all the komento comment base on this article `cid`.


// Example code :
public function deleteArticleComments($component, $cid)
{
$query = 'DELETE FROM ' . $this->db->nameQuote('#__komento_comments');
$query .= ' WHERE ' . $this->db->nameQuote('component') . ' = ' . $this->db->quote($component);
$query .= ' AND ' . $this->db->nameQuote('cid') . ' = ' . $this->db->quote($cid);

$this->db->setQuery($query);
return $this->db->query();
}


Your plugins path should be similar like this -> JoomlaFolder/plugins/rsfeedback/komento/komento.php

Hope this explanation will help.
·
Monday, 20 February 2017 17:49
·
0 Likes
·
0 Votes
·
0 Comments
·
1) thanks for the code - I should be able to use it.

2) on the integration page, the link (Trigger methods These are advance methods where you can use them to further extend Komento's feature or usability. Refer to the Trigger documentation for more information.) does not work.

3) can you get this as a feature request to add comment deletion into the plugin and Komento's API (and elsewhere)

4) from your response there is no programmatic way of deleting Komento Comments. This needs addressing and is quite a big issue. I dont think a lot of people will understand that when then delete and article or remove a component that all of the comments are still there. This potential could be a security threat. I can explain further if required.
·
Monday, 20 February 2017 18:55
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for your input, but currently that is no other way to add the comment deletion in Komento API

Because it still need to check whether those 3rd party component allow event trigger or not, if not Komento will not know when the user perform the delete action from 3rd party component.

Perhaps you have a better ideas of this so i can discuss this with our team.
·
Tuesday, 21 February 2017 13:24
·
0 Likes
·
0 Votes
·
0 Comments
·
1) thanks

2) not answered

3) not answered

4) Thanks

i) Add a new function called deleteComments($component, $cid) , in the KT:: class this would simpledelete all matching comments. This does nto need to be a mandatory function but at the very least should be in your sample plugin (which I have improved, it was missing lots of annotation).

ii) I would also add a function called deleteAllComponentComments($component) this can then be called on a component uninstall or if the administrator wants to purge the comments

iii) In komento there needs to be an orphan comments deletion script that when run find comments that no longer have an article they are links too. This list in the standard joomla article filtering scheme you can select which comments you want to delete. There will also be a delete all button. I would also like to see an option where you could re-assign the comments elesewhere rather than just deleting.

iv) if I was being thorough I would also have the functions orphanedComponentComments($component) - This would return all comments belonging to the component that do not have an article they belong to. This could be used within the component to sort comments there.
·
Tuesday, 21 February 2017 17:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

I'm one of the Komento's developers and I find this post very helpful in order to improve Komento Integration API. However, I am a bit lost about the Delete API.

Add a new function called deleteComments($component, $cid) , in the KT:: class

We can add this in our code but the component itself still need to include the Komento library and call this function. The way that I can think of to do this is:

- We will add new function in KT:: called deleteComment()
- In your component, after the item gets deleted, either trigger a joomla plugin to delete the comment or directly add the KT::deleteComment() code in the component.

1st approach (trigger joomla plugin):
We take Easyblog as example. When a blog post gets deleted, there will be a trigger called onAfterEasyBlogDelete. This trigger can be used by Komento (or any other component) to delete those associated comments by creating a plugin inside the Easyblog plugin folder: ..plugins/easyblog/komento/komento.php. The codes will look something like this:

public function onAfterEasyBlogDelete($blog)
{
$lib = JPATH_ADMINISTRATOR . '/components/com_komento/includes/komento.php';

if (!JFile::exists($lib)) {
return;
}

require_once($lib);

KT::deleteComment('com_easyblog', $blog->id);
}



2nd approach (Direct add delete codes):
In Easyblog, the file used to delete a blog post is administrator/components/com_easyblog/includes/post.php. This is the example of adding a code to delete associated comment:

/**
* Deletes a post from the site
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function delete()
{
// Load site's language file just in case the blog post was deleted from the back end
EB::loadLanguages();

// Load our own plugins
JPluginHelper::importPlugin('finder');
JPluginHelper::importPlugin('easyblog');
$dispatcher = JDispatcher::getInstance();

// Trigger
$dispatcher->trigger('onBeforeEasyBlogDelete', array(&$this));

// Delete the post from the db now
$state = $this->post->delete();

// Delete the associated comment

$lib = JPATH_ADMINISTRATOR . '/components/com_komento/includes/komento.php';

if (JFile::exists($lib)) {
require_once($lib);
KT::deleteComment('com_easyblog', $this->id);
}

// Trigger
$dispatcher->trigger('onAfterEasyBlogDelete', array(&$this));

// Delete from finder.
$dispatcher->trigger('onFinderAfterDelete', array('easyblog.blog', $this->post));




Move to your other question.
2) on the integration page, the link (Trigger methods These are advance methods where you can use them to further extend Komento's feature or usability. Refer to the Trigger documentation for more information.) does not work.

May I know which trigger that you are referring here and how you call this trigger? Perhaps, you can attach your plugin file for us to see if there is anything wrong that causing the issue.
·
Wednesday, 22 February 2017 15:54
·
0 Likes
·
0 Votes
·
0 Comments
·
I will go through your notes above when I am a little more awake so I can examine it better.

in regards to question (2)

on the page https://stackideas.com/docs/komento/administrators/advance/creating-own-integration-files

The link in the sentence "Refer to the Trigger documentation for more information." does not work. I think it should point to

https://stackideas.com/docs/komento/administrators/advance/triggers

I appreciate the feedback and I will be in touch
·
Wednesday, 22 February 2017 18:06
·
0 Likes
·
0 Votes
·
0 Comments
·
in regards to question (2)

on the page https://stackideas.com/docs/komento/administrators/advance/creating-own-integration-files

The link in the sentence "Refer to the Trigger documentation for more information." does not work. I think it should point to

https://stackideas.com/docs/komento/administrators/advance/triggers

Thanks for reported, I will update to our documentation administrator regarding this.
·
Thursday, 23 February 2017 12:08
·
0 Likes
·
0 Votes
·
0 Comments
·
@ Nik

sorry for the late reply, I finished doing my integration plugin and the documentation and discovered I was a little burnt out

Let me just address the points as I see them

1) the component will have to trigger the deletion calls - yes this is what I thought. Adding the code into the plugin give the component developers the opportunity to do this.

2) i prefer the inclusion of the deletion code in the plugin. it keeps it centralized and is more logical. Also for 3rd party developers who use other systems give them the opportunity to add something similar there whilst maintaining standards. Small time developers like myself can also see the extra functionality and add it. Lastly it allows this extra feature to be added to existing plugins with backward compatability.

3) now to my proposed functions can you consider the following:

deletion

- deleteComments($component, $cid) - this will delete comments for one article
- deleteComments($component, $cid = array() ) - this will delete comments for all article(s) supplied
- deleteAllComments($component) - this will delete all comments for a component

NB: These could all be combined into 1 function and when you want to delete all comments for a component $cid = 'ALL'. I thoought having the deleteAllComments separate was safer to prevent accidental global deletion but it does add an extra function on, i will leave this to you. 1 function is neater though.

orphaned comments

- checkOrphanedComments($component) - this will return a list/array or comments that do not belong to an article for that component. this is useful to find comments for deleted articles in the component caused by previous versions of komento which do not have the delete function.
- moveComments($component, $cid, $target_cid) - this function allows the component to move the comments to a new article (i will leave the merge logic to you). This function will only allow the moving of comments within the component. I dont know if a finer grain movement is required i.e. for individual comments

NB: I would like to see the ability to move comments to other components and articles via the komento admin, with the addition option to move the comment thread or all comments on that article. I know you can alter the article ID for a single comment but this is a bit limited. e.g. I have a knowledge base and blog. So when I have an article in my knowledge base and I decide I want to now put my article into my blog I want the ability to move my comments for that article along with it. I would imagine doing this via a batch/move function similar to joomla's feature.

NB: I would also like the ability to scan for orphaned articles within the komento admin. For this feature and the above feature I would see the use of a standard joomla 'articles panel', like how joomla rticles are displayed with all of the filtering options and batch/move buttons

I have added these suggestions here because they are heavily related.

If you need anymore follow ups please let me know as i am back to normal.

thanks

shoulders
·
Friday, 03 March 2017 18:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for your feedback, I will forward this to our developer on the week start.
·
Saturday, 04 March 2017 11:48
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Nick (NIK ?)

2) indeed i am on about the komento plugins (../components/com_komento/komento_plugins/ or ../components/com_rsfeedback/komento_plugin.php )

Adding the function KT::deleteComment('com_content', $article->id); into the komento_plugin.php is my suggested idea so developers know there is a delete function and it is easy to understand. all interaction should be done through the plugin.

Komento admin - did you see the ideas about the orphaned comments and moving comments from within komento admin. I can add another thread if needed.

thanks for the feedback.
·
Tuesday, 07 March 2017 01:08
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Shoulders,

Komento admin - did you see the ideas about the orphaned comments and moving comments from within komento admin. I can add another thread if needed.

- Yes, I did see that. But I will need to see the code/database structure whether this is easy to implement or not.
·
Tuesday, 07 March 2017 10:21
·
0 Likes
·
0 Votes
·
0 Comments
·
great i will leave this with you then. I understand it is not a 5 minute job.

And thanks for the in-depth response it makes the time spend writing this lot up worth it.
·
Wednesday, 08 March 2017 03:05
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for understanding. I will log this in our tracker.
·
Wednesday, 08 March 2017 10:23
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post