aboutsummaryrefslogtreecommitdiff
path: root/documentation/examples/actions
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-11-12 14:28:52 -0500
committercash <cash.costello@gmail.com>2011-11-12 14:28:52 -0500
commit76bea966f7f93e719ccbf6e2350f647636d4da2a (patch)
tree87b7b8851b4161be827af5ee9a194fc3553ff29a /documentation/examples/actions
parent88d597c63a9691c9714e9db4dbe676028e548be8 (diff)
downloadelgg-76bea966f7f93e719ccbf6e2350f647636d4da2a.tar.gz
elgg-76bea966f7f93e719ccbf6e2350f647636d4da2a.tar.bz2
added better plugin skeleton and added documentation to some of the examples
Diffstat (limited to 'documentation/examples/actions')
-rw-r--r--documentation/examples/actions/basic.php22
-rw-r--r--documentation/examples/actions/manual_tokens.php6
2 files changed, 22 insertions, 6 deletions
diff --git a/documentation/examples/actions/basic.php b/documentation/examples/actions/basic.php
new file mode 100644
index 000000000..926e11b79
--- /dev/null
+++ b/documentation/examples/actions/basic.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Demonstrates adding an annotation through an action
+ *
+ * This action adds a rating annotation to an entity. If this was coming from
+ * a five-star rating tool, the rating would be a number between 0 and 5. The
+ * GUID of the entity being rating is also submitted to the action.
+ */
+
+$rating = get_input('rating');
+$guid = get_input('guid');
+
+$entity = get_entity($guid);
+if (!$entity) {
+ register_error(elgg_echo('rating:failure'));
+ forward(REFERER);
+}
+
+$entity->annotate('rating', $rating);
+
+system_message(elgg_echo('rating:success'));
+forward(REFERER);
diff --git a/documentation/examples/actions/manual_tokens.php b/documentation/examples/actions/manual_tokens.php
deleted file mode 100644
index 8dcf61fb1..000000000
--- a/documentation/examples/actions/manual_tokens.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-$ts = time();
-$token = generate_action_token($ts);
-
-var_dump($ts, $token);