Esempio n. 1
0
            log_insert('link_depublished', $link->link_id, $link->link_author);
            // Add the discard to log/event
            $user = new User();
            $user->id = $link->link_author;
            if ($user->read()) {
                $user->karma -= $globals['instant_karma_per_depublished'];
                echo "{$user->username}: {$user->karma}\n";
                $user->store();
                $annotation = new Annotation("karma-{$user->id}");
                $annotation->append(_('Retirada de portada') . ": -" . $globals['instant_karma_per_depublished'] . ", karma: {$user->karma}\n");
            }
            if ($globals['twitter_user'] || $globals['jaiku_user']) {
                if ($globals['url_shortener']) {
                    $short_url = $l->get_short_permalink();
                } else {
                    $short_url = fon_gs($l->get_permalink());
                }
                $text = _('Retirada de portada') . ': ';
                if ($globals['twitter_user'] && $globals['twitter_password']) {
                    twitter_post($text, $short_url);
                }
                if ($globals['jaiku_user'] && $globals['jaiku_key']) {
                    jaiku_post($text, $short_url);
                }
            }
        }
    }
}
punish_comments();
// Discard links
$negatives = $db->get_results("select SQL_NO_CACHE link_id, link_karma, link_votes, link_negatives, link_author from links where link_date > {$min_date} and link_status = 'queued' and link_karma < 0 and (link_date < {$max_date} or link_karma < -100) and (link_karma < -link_votes*2 or (link_negatives > 20 and link_negatives > link_votes/2)) and (link_negatives > 20 or (link_negatives > 4 and link_negatives > link_votes) )");
Esempio n. 2
0
function publish(&$link)
{
    global $globals, $db;
    global $users_karma_avg;
    // Calculate votes average
    // it's used to calculate and check future averages
    $votes_avg = (double) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id={$link->id} and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'");
    if ($votes_avg < $users_karma_avg) {
        $link->votes_avg = max($votes_avg, $users_karma_avg * 0.97);
    } else {
        $link->votes_avg = $votes_avg;
    }
    $link->status = 'published';
    $link->date = $link->published_date = time();
    $link->store_basic();
    // Increase user's karma
    $user = new User();
    $user->id = $link->author;
    if ($user->read()) {
        $user->karma = min(20, $user->karma + 1);
        $user->store();
        $annotation = new Annotation("karma-{$user->id}");
        $annotation->append(_('Noticia publicada') . ": +1, karma: {$user->karma}\n");
    }
    // Add the publish event/log
    log_insert('link_publish', $link->id, $link->author);
    $short_url = fon_gs($link->get_permalink());
    if ($globals['twitter_user'] && $globals['twitter_password']) {
        twitter_post($link, $short_url);
    }
    if ($globals['jaiku_user'] && $globals['jaiku_key']) {
        jaiku_post($link, $short_url);
    }
}
Esempio n. 3
0
function publish($link) {
	global $globals, $db, $client;

	//return;
	if (DEBUG) return;

	// Calculate votes average
	// it's used to calculate and check future averages
	$votes_avg = (float) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id=$link->id and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'");
	if ($votes_avg < $globals['users_karma_avg']) $link->votes_avg = max($votes_avg, $globals['users_karma_avg']*0.97);
	else $link->votes_avg = $votes_avg;

	$link->status = 'published';
	$link->date = $link->published_date=time();
	$db->query("update links set link_status='published', link_date=now(), link_votes_avg=$link->votes_avg where link_id=$link->id");

	// Increase user's karma
	$user = new User;
	$user->id = $link->author;
	if ($user->read()) {
		$user->karma = min(20, $user->karma + $globals['instant_karma_per_published']);
		$user->store();
		$annotation = new Annotation("karma-$user->id");
		$annotation->append(_('noticia publicada').": +". $globals['instant_karma_per_published'] .", karma: $user->karma\n");
	}

	// Add the publish event/log
	log_insert('link_publish', $link->id, $link->author);
	$link->annotation .= _('publicación'). "<br/>";
	$link->save_annotation('link-karma');

	if ($globals['url_shortener']) {
		$short_url = $link->get_short_permalink();
	} else {
		$short_url = fon_gs($link->get_permalink());
	}
	if ($globals['twitter_user'] && $globals['twitter_password']) {
		twitter_post($link->title, $short_url); 
	}
	if ($globals['jaiku_user'] && $globals['jaiku_key']) {
		jaiku_post($link->title, $short_url); 
	}
	if ($globals['pubsub']) {
		pubsub_post();
	}

  if ($link->start_date) {
    createEvent($client, $link->title, $link->content, $link->start_date, $link->end_date);
  }

}