diff options
Diffstat (limited to 'mod/guidtool')
-rw-r--r-- | mod/guidtool/actions/delete.php | 21 | ||||
-rw-r--r-- | mod/guidtool/languages/en.php | 3 | ||||
-rw-r--r-- | mod/guidtool/start.php | 4 | ||||
-rw-r--r-- | mod/guidtool/views/default/guidtool/listing.php | 11 |
4 files changed, 37 insertions, 2 deletions
diff --git a/mod/guidtool/actions/delete.php b/mod/guidtool/actions/delete.php new file mode 100644 index 000000000..36126ee10 --- /dev/null +++ b/mod/guidtool/actions/delete.php @@ -0,0 +1,21 @@ +<?php
+ global $CONFIG;
+
+ admin_gatekeeper();
+ action_gatekeeper();
+
+ $guid = (int)get_input('guid');
+ $entity = get_entity($guid);
+
+ if ($entity)
+ {
+ if ($entity->delete())
+ system_message(sprintf(elgg_echo('guidtool:deleted'), $guid));
+ else
+ register_error(sprintf(elgg_echo('guidtool:notdeleted'), $guid));
+ }
+ else
+ register_error(sprintf(elgg_echo('guidtool:notdeleted'), $guid));
+
+ forward($_SERVER['HTTP_REFERER']);
+?>
\ No newline at end of file diff --git a/mod/guidtool/languages/en.php b/mod/guidtool/languages/en.php index 6c7f9e383..5365deede 100644 --- a/mod/guidtool/languages/en.php +++ b/mod/guidtool/languages/en.php @@ -23,6 +23,9 @@ 'guidtool:pickformat' => 'Please select the format that you wish to import or export.', 'guidbrowser:export' => 'Export', + + 'guidtool:deleted' => 'GUID %d deleted', + 'guidtool:notdeleted' => 'GUID %d not deleted', ); add_translation("en",$english); diff --git a/mod/guidtool/start.php b/mod/guidtool/start.php index 5af18b904..0a416320b 100644 --- a/mod/guidtool/start.php +++ b/mod/guidtool/start.php @@ -27,6 +27,10 @@ // Register a page handler, so we can have nice URLs register_page_handler('guidtool','guidtool_page_handler'); + + // Register some actions + register_action("guidtool/delete",false, $CONFIG->pluginspath . "guidtool/actions/delete.php", true); + } /** diff --git a/mod/guidtool/views/default/guidtool/listing.php b/mod/guidtool/views/default/guidtool/listing.php index fed278568..d543b8e03 100644 --- a/mod/guidtool/views/default/guidtool/listing.php +++ b/mod/guidtool/views/default/guidtool/listing.php @@ -20,13 +20,20 @@ 'size' => 'small', ) ); - + + $ts = time(); + $token = generate_action_token($ts); + + $controllinks = "<a href=\"{$CONFIG->url}pg/guidtool/export/{$entity->guid}/\">".elgg_echo('export')."</a> "; + if ($entity->canEdit()) + $controllinks .= elgg_view('output/confirmlink', array('text' => elgg_echo('delete'), 'href' => "{$CONFIG->url}action/guidtool/delete?guid={$entity->guid}&__elgg_token=$token&__elgg_ts=$ts")); + $strap = $entity->title ? $entity->title : $entity->name; $info .= "<p><b><a href=\"{$CONFIG->url}pg/guidtool/view/{$entity->guid}/\">[GUID:{$entity->guid}] " . get_class($entity) . " " . get_subtype_from_id($entity->subtype) . "</a></b> $strap</p>"; $info .= "<div>"; if ($by) $info .= elgg_echo('by') . " <a href=\"".$by->getURL()."\">{$by->name}</a> "; - $info .= " " . friendly_time($entity->time_created )."</div>"; + $info .= " " . friendly_time($entity->time_created )." [$controllinks]</div>"; echo elgg_view_listing($icon, $info); ?>
\ No newline at end of file |