예제 #1
0
파일: functions.php 프로젝트: n8b/VMN
/**
 * Is the user exempt from throttling?
 * 
 * @param \ElggUser $user
 * @return boolean
 */
function is_exempt($user)
{
    if (!$user instanceof \ElggUser) {
        return false;
    }
    if (elgg_is_admin_logged_in()) {
        return true;
    }
    // trusted users are exempt
    if (elgg_is_active_plugin('trusted_users') && is_callable('trusted_users_is_trusted')) {
        return trusted_users_is_trusted($user);
    }
    return false;
}
예제 #2
0
function tu_spam_report_river_menu($hook, $type, $return, $params)
{
    if ($params['item']->type == 'object' && elgg_is_logged_in() && !$params['item']->annotation_id) {
        $user = elgg_get_logged_in_user_entity();
        $object = $params['item']->getObjectEntity();
        if (trusted_users_is_trusted($user) && !tu_spam_report_is_marked($object, $user)) {
            // we're a trusted user, give us a spam link
            $text = elgg_view_icon('attention');
            $href = elgg_add_action_tokens_to_url('action/report_spam?guid=' . $object->guid);
            $item = new ElggMenuItem('report_spam', $text, $href);
            $item->setTooltip(elgg_echo('tu_spam_report:mark'));
            $return[] = $item;
        }
    }
    return $return;
}
예제 #3
0
function tu_spam_report_init()
{
    if (trusted_users_is_trusted(elgg_get_logged_in_user_entity())) {
        // add spam report buttons to entity menus
        elgg_register_plugin_hook_handler('register', 'menu:entity', 'tu_spam_report_entity_menu');
        // run last to create a specific menu for admin
        elgg_register_plugin_hook_handler('register', 'menu:entity', 'tu_spam_report_reported_spam_menu', 1000);
        elgg_register_plugin_hook_handler('register', 'menu:river', 'tu_spam_report_river_menu');
        elgg_register_plugin_hook_handler('register', 'menu:entity', 'tu_spam_report_spammer_menu');
        elgg_register_action('report_spam', dirname(__FILE__) . '/actions/report_spam.php');
        elgg_register_action('reported_spam/delete', dirname(__FILE__) . '/actions/delete.php', 'admin');
        elgg_register_action('reported_spam/notspam', dirname(__FILE__) . '/actions/notspam.php', 'admin');
        elgg_register_action('reported_spam/notspammer', dirname(__FILE__) . '/actions/notspammer.php', 'admin');
        elgg_register_admin_menu_item('administer', 'reported_spam', 'administer_utilities');
        elgg_register_admin_menu_item('administer', 'spammers', 'users');
    }
}
<?php

$user = elgg_get_logged_in_user_entity();
$object = get_entity(get_input('guid'));
$forward = REFERER;
if (!elgg_instanceof($object) || !trusted_users_is_trusted($user)) {
    register_error(elgg_echo('tu_spam_report:error:permissions'));
    forward(REFERER);
}
$owner = $object->getOwnerEntity();
if (tu_spam_report_is_marked($object, $user)) {
    register_error(elgg_echo('tu_spam_report:error:marked'));
    forward(REFERER);
}
$ia = elgg_set_ignore_access(true);
// all good, lets mark it as spam
$object->annotate('tu_spam_report', 1);
// count how many reports there have been
$markcount = elgg_get_annotations(array('guid' => $object->guid, 'annotation_names' => array('tu_spam_report'), 'annotation_values' => array('1'), 'count' => true));
$marklimit = elgg_get_plugin_setting('trusted_users_flag_count', 'trusted_user_spam_report');
$userlimit = elgg_get_plugin_setting('user_spam_count', 'trusted_user_spam_report');
$user_strtotime = elgg_get_plugin_setting('user_spam_strtotime', 'trusted_user_spam_report');
if ($marklimit && $markcount >= $marklimit) {
    // this is enough to call it spam
    $object->disable('reported spam');
    $forward = 'activity';
    // record that the user had content disabled
    // if the user has too much content disabled we'll auto-ban them
    $owner->annotate('content_marked_spam', 1);
    $time_lower = strtotime($user_strtotime);
    if ($time_lower && $userlimit) {