aboutsummaryrefslogtreecommitdiff
path: root/documentation/examples/actions/basic.php
blob: 926e11b79b66b930b24c0f2e371107ef5e7eafeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);