/**
 * Handles voting on an entity
 * 
 * @param  integer  $guid  The entity guid being voted on
 * @param  integer  $vote The vote
 * @return string   A status message to be returned to the client
 */
function fivestar_vote($guid, $vote)
{
    $entity = get_entity($guid);
    $msg = null;
    if ($annotation = get_annotations($entity->guid, $entity->type, $entity->subtype, 'fivestar', '', $_SESSION['user']->guid, 1)) {
        if ($vote == 0 && (int) get_plugin_setting('change_cancel')) {
            delete_annotation($annotation[0]->id);
            $msg = elgg_echo('fivestar:deleted');
        } else {
            if (get_plugin_setting('change_cancel')) {
                update_annotation($annotation[0]->id, 'fivestar', $vote, 'integer', $_SESSION['user']->guid, 2);
                $msg = elgg_echo('fivestar:updated');
            } else {
                $msg = elgg_echo('fivestar:nodups');
            }
        }
    } else {
        if ($vote > 0) {
            $entity->annotate('fivestar', $vote, 2);
        } else {
            $msg = elgg_echo('fivestar:novote');
        }
    }
    return $msg;
}
 public function updateAnswerFromUser($event, $new_answer, $user_guid = null)
 {
     if (empty($user_guid)) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     if (($old_answer = $this->getAnswerFromUser($user_guid)) && get_user($user_guid)) {
         if (!empty($new_answer)) {
             update_annotation($old_answer->id, 'answer_to_event_registration', $new_answer, '', $user_guid, $event->access_id);
         } else {
             delete_annotation($old_answer->id);
         }
     } else {
         $this->annotate('answer_to_event_registration', $new_answer, $event->access_id, $user_guid);
     }
 }
Exemplo n.º 3
0
 /**
  * Delete a given site.
  */
 function delete()
 {
     return delete_annotation($this->id);
 }
<?php

/**
 * Profile Counter - Resets the counter
 * 
 * @package profile_counter
 * @author ColdTrick IT Solutions
 * @copyright Coldtrick IT Solutions 2009
 * @link http://www.coldtrick.com/
 */
gatekeeper();
// Make sure action is secure
action_gatekeeper();
$current_count = get_loggedin_user()->getAnnotations("profilecount");
if ($current_count) {
    delete_annotation($current_count[0]->id);
}
forward($_SERVER['HTTP_REFERER']);
Exemplo n.º 5
0
$current_day = 0;
$count = 0;
$annotations_removed = 0;
$annotations_stack = array();
foreach ($downloads as $download) {
    $day = (int) floor(($download->time_created - $start_date) / (3600 * 24));
    if ($current_day == $day) {
        $count++;
        $annotation_stack[] = $download;
    } else {
        // if this day is out of the ordinary, reduce to median
        if ($count > $cutoff) {
            if (!$preview) {
                while (count($annotation_stack) > $median) {
                    $annotation = array_pop($annotation_stack);
                    delete_annotation($annotation->id);
                }
            }
            $annotations_removed += $count - $median;
        }
        // reset to handle the next day
        $count = 1;
        $annotation_stack = array($download);
        $current_day = $day;
    }
}
if (!$preview) {
    system_message("Normalized downloads removing {$annotations_removed} annotations");
} else {
    system_message("Would have removed {$annotations_removed} annotations using a max of {$cutoff}");
}