By Afshin Behnia on Saturday, 07 November 2015
Posted in General Issues
Replies 13
Likes 0
Views 1.1K
Votes 0
I have a site built in AWS Elastic Beanstalk so it's a scaling environment and local resources won't work. What trigger ( http://stackideas.com/docs/komento/administrators/advance/triggers ) can I build a plugin around so that I can access uploaded attachments details? I've tried onBeforeSaveComment, but I'm not seeing anything about attachments in the object. I really need to get these into S3
Hi Afshin,

Currently we do not pass around the attachment details when trigger the events from Komento. We only pass the comment object into the event trigger. However, what you can do is to call a method from this comment object to retrieve the attachment info. E.g.


$attachements = $comment->getAttachments();


This method will return you a list of attachments for the comment if there is any.

Hope this help and have a nice day!
Sam
·
Saturday, 07 November 2015 17:49
·
0 Likes
·
0 Votes
·
0 Comments
·
I'm getting a fatal error (Fatal error: Call to a member function getAttachments() on array), is there something I need to include first?


class plgKomentoS3 extends JPlugin {
public function onAfterSaveComment( $component, $cid, &$comment ) {
$attachements = $comment->getAttachments();
var_dump($attachements);
}
}
·
Sunday, 08 November 2015 06:19
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Afshin,

Urm, this is weird. Can you provide us your backend and FTP access so we can check on this issue? Also, can you tell us the exact file for this plugin? Please advise.
·
Monday, 09 November 2015 11:44
·
0 Likes
·
0 Votes
·
0 Comments
·
I've updated the ticket with the credentials you need to access the site. the file is located /var/www/html/plugins/Komento/notifications/notifications.php
·
Tuesday, 10 November 2015 05:09
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Afshin,

I'm sorry, we need your FTP access as well to have a look on the plugin file.
·
Wednesday, 11 November 2015 11:54
·
0 Likes
·
0 Votes
·
0 Comments
·
There is no FTP setup on that server. That's what the ssh access that I outlined in the Additional Message section is for. It gives access to the file system.
·
Wednesday, 11 November 2015 15:40
·
0 Likes
·
0 Votes
·
0 Comments
·
·
Wednesday, 11 November 2015 17:01
·
0 Likes
·
0 Votes
·
0 Comments
·
That's the Basic Auth that is protecting the front end. Username and password is also outlined in the Additional Message section.
·
Thursday, 12 November 2015 04:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Afshin,

The onAfterSaveComment is not the correct trigger because at the moment it gets triggered, attachments haven't gets uploaded yet. I've made a changes to your Komento files by adding additional trigger named, onAfterSaveAttachment. Can you please try again?

These are files that I've modified:
../components/com_komento/views/komento/view.ajax.php
../components/com_komento/komento_plugins/abstract.php
·
Thursday, 12 November 2015 11:40
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry, I might have accidentally overridden your changes as I wasn't expecting you to make any edits. Can you post the changes here as I'll also need to make these on our production site as well.

I appreciate all the help given.
·
Thursday, 12 November 2015 15:38
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Afshin,

Here are the files. Replace them in here:
../components/com_komento/views/komento/view.ajax.php
../components/com_komento/komento_plugins/abstract.php


And in your notification.php, you may change the function name to onAfterSaveAttachment:

public function onAfterSaveAttachment( $component, $cid, &$comment ) { }


Hope this helps.
·
Thursday, 12 November 2015 15:45
·
0 Likes
·
0 Votes
·
0 Comments
·
The new trigger works, but I get the same error when calling $attachements = $comment->getAttachments();
I ended up, adding some modifications to yours .

in view.ajax.php:
I added a call to $model->getAttachments( $commentObj->id ); and appending it to the comment object before calling the trigger. I now have all the information I need.
·
Saturday, 14 November 2015 03:34
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Afshin,

Thanks for updating. Glad that your issue has been resolved now.
·
Monday, 16 November 2015 13:29
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post