Example #1
0
<?php

/**
 * Recommend view
 */
$project = $vars['project'];
$num_diggs = count_annotations($project->guid, "object", "plugin_project", "plugin_digg");
?>

<div id="plugins_recommend">
	<div id="num_recommend">
		<p><?php 
echo $num_diggs;
?>
</p>
	</div>
	<div class="clearfloat"></div>
	<div id="recommend_action">
<?php 
if (!plugins_is_dugg($project) && isloggedin()) {
    $url = "{$vars['url']}action/plugins/digg?guid={$project->guid}";
    $url = elgg_add_action_tokens_to_url($url);
    echo "<a href=\"{$url}\">Recommend</a>";
} else {
    ?>
		<p>Recommendations</p>
<?php 
}
?>
	</div>
</div>
Example #2
0
<?php

/**
 * Add recommendation action
 */
// Get input
$project_guid = (int) get_input('guid');
// Get the project
$plugin_project = get_entity($project_guid);
// Let's see if we can get an entity with the specified GUID
if ($plugin_project) {
    //double check to see if the user has already dugg the plugin
    if (plugins_is_dugg($plugin_project)) {
        system_message(elgg_echo("plugins:alreadydugg"));
    } else {
        //$digg_num = $plugin_project->digg + 1;
        //$plugin_project->digg = (int) $digg_num;
        if ($plugin_project->annotate('plugin_digg', 1, $plugin_project->access_id, get_loggedin_userid())) {
            //create a relationship between user and plugin project so they can only digg once
            add_entity_relationship(get_loggedin_userid(), 'has_dugg', $plugin_project->guid);
            system_message(elgg_echo("plugins:diggit"));
        }
    }
} else {
    system_message(elgg_echo("ratings:notfound"));
}
// Forward to the plugin
$url = $plugin_project->getURL();
forward($url);