aboutsummaryrefslogtreecommitdiff
path: root/views/default/river/item/controls.php
blob: 50c1ae09efc412762d41ca70b1ac2d4174be638f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
 * Controls on an river item
 *
 *
 * @uses $vars['item']
 */

$object = $vars['item']->getObjectEntity();

if (elgg_is_logged_in()) {
	// comments and non-objects cannot be commented on or liked
	if ($vars['item']->annotation_id == 0) {
		// comments
		if ($object->canComment()) {
			elgg_register_menu_item('river', array(
				'name' => 'comment',
				'href' => "#comments-add-$object->guid",
				'text' => elgg_echo('generic_comments:text'),
				'class' => "elgg-toggler",
			));
		}

		// like this
		if ($object->canAnnotate(0, 'likes')) {
			if (!elgg_annotation_exists($object->getGUID(), 'likes')) {
				
				elgg_register_menu_item('river', array(
					'name' => 'likes',
					'href' => "action/likes/add?guid={$object->getGUID()}",
					'text' => elgg_echo('likes:likethis'),
					'is_action' => true,
				));
			} else {
				$likes = elgg_get_annotations(array(
					'guid' => $guid,
					'annotation_name' => 'likes',
					'owner_guid' => elgg_get_logged_in_user_guid()
				));

				elgg_register_menu_item('river', array(
					'href' => "action/likes/delete?annotation_id={$likes[0]->id}",
					'text' => elgg_echo('likes:remove'),
					'is_action' => true,
				));
			}
		}
	}

	echo elgg_view_menu('river', array('sort_by' => 'priority', 'item' => $vars['item']));
}