Hi Guys,
I have a page that details some information on an object then also returns comments. I'm using a comments hook and not the default comments system.
within the foreach routine that grabs the comments - I'd like either the user that posted the comment or the admin to be able to delete the comment.
within each comment i have saved
$compost->owner_guid as well as a whole bunch of relevant info.
at the very end of the foreach routine as the particular $compost->info is grabbed - I'm not sure if I keep it as simple as something like;
if ( $vars['entity']->canEdit() ) {
$info .= elgg_view('input/button', array('commentGUID' => $compost->owner_guid, 'action'=>$compost->delete()));
}
OR
if i need to call an action in which the deletion happens...(and be more specific with the IF routine prior:
if $compost->owner_GUID == $_SESSION['user']->getGUID(); {
// and then an OR if is admin
$info .= elgg_view('input/button', array('commentGUID' => $compost->getGUID(), 'action'=> "{$CONFIG->url}mod/myplugin/actions/comments/delete.php"));
}
Any thoughts or suggestions - any help greatly appreciated.... :D
Regards,
Jimbo
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Okay *bump*
this is where I'm up to.
Within my page (object) I have all the comments ($compost) listed and during the foreach routine I have;
if ( $compost->canEdit() ) {
$info .= elgg_view('input/button', array('value' => elgg_echo('delete comment'), 'commentGUID' => $compost->getGUID(), 'action'=> "{$CONFIG->url}mod/myplugin/actions/comments/delete.php"));
}
When $compost is saved/added by a user previously - the following is stored (just for the record and if it helps)
$comment = new ElggObject();
$comment->subtype = "comment";
$comment->owner_guid = $_SESSION['user']->getGUID();
$comment->container_guid = $_SESSION['user']->getGUID();
$comment->access_id = 1; // logged in users
$comment->parent_guid = $entity_guid;
// more metadata/info/details etc
$comment->save();
Now, the action (mod/myplugin/actions/comments/delete.php) looks like as follows;
gatekeeper();
// Get input data
$guid = (int) get_input('commentGUID');
$comment = get_entity($commentGUID);
if ($comment->canEdit()) {
$comment->delete();
system_message(elgg_echo("generic_comment:deleted"));
forward($vars['entity'])->getURL();
// supposed to forward to the original object-page.
} else {
register_error(elgg_echo("generic_comment:notdeleted"));
}
The result is a button with 'delete comment' but I don't believe the action file I've created is pointing properly at what to delete as nothing happens when clicked. Any advise on where I've gone wrong?
Help appreciated as always :D thanks,
Jimbo
es para el riverdashboard ? como puedo hacer un botón para borrar directamente del riverdashboard
huh? (what?)
@James so, here is the deal. Some developers like mariano wants to be able to delete items off the riverdashboard. He wants a delete me button for every activity of the dashboard...
Rightio! - Sorry if there is confusion - What i'm seeking help & advice on isn't related to the riverdashboard, but my own plugin which has its own extended comments system (not the default). Although I wish it was and I had the answers re: river - I'm a borderline amatuer programmer...and just chasing direction for my previous
Cheers,
Jimbo
Is your own PlugIn published here so that the borderline professional programmers can take a quick 3 minute review, 2 min re-code/test, 1 min code patch ?
@Dhrup - It's based on the blod extended plugin by diago (i think) that you pointed me toward a while back.
...he had an extended comments system - but what i worked with (or am working with) is basicially half finished in that regard - hence the above detail of the delete functionality........?
Hey James,
As in your first post, you'll need to have an action file handle the delete.
Create the file: "yourplugin/actions/delete.php" then register the action in your start.php like so;
In the delete.php put something like this:
(This is a very simple example)
Then in your page listing the comments add something like this wherever you want to delete:
Gold - thanks, again Jeff :)
odd,
I'm actually getting an error;
Fatal error: Call to a member function delete() on a non-object in .../actions/comments/delete.php
...and despite the error msg page - if I go back to the proper page, the comment has been deleted.
any clues as to why? I've detailed how the comment object is saved above....*hrmmm*
- Previous
- 1
- 2
- Next
You must log in to post replies.