Exemple #1
0
function do_posts($link)
{
    global $globals;
    syslog(LOG_INFO, "Meneame, posting {$link->uri}");
    // echo "Posting $link->uri: ".$globals['server_name']. "--".$globals["site_shortname"]."---". $globals['twitter_consumer_key'] ."\n"; die;
    $url = $link->get_permalink();
    if ($globals['url_shortener']) {
        $short_url = $link->get_short_permalink();
    } else {
        $short_url = $url;
    }
    if ($globals['twitter_token'] && $globals['twitter_token_secret']) {
        twitter_post($link->title, $url);
    }
    if ($globals['facebook_token']) {
        facebook_post($link);
    }
    if ($globals['jaiku_user'] && $globals['jaiku_key']) {
        jaiku_post($link->title, $short_url);
    }
    if ($globals['pubsub']) {
        pubsub_post();
    }
}
Exemple #2
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);
  }

}