Exemple #1
0
/**
* Publishes a message to users feed, given a phrase as the message
*
* @param	the name of the phrase to publish in the message
* @param	the title of the new thread
* @param	the body of the first post in the thread
* @param	the url to the first post in the thread
*
* @return	bool	true if the publish worked, false otherwise
*/
function publishtofacebook($phrasename, $title, $body, $link)
{
    global $vbphrase, $vbulletin;
    // check if  Facebook user is active and user wants to publish
    if (is_userfbconnected() and is_userfbactive() and check_fbpublishcheckbox()) {
        // get the preview text for the body
        $body = fetch_trimmed_title(strip_bbcode($body, true, false, true, true), 300);
        // if phrasename is not in the phrase array, simply use phrasename as the message
        $message = isset($vbphrase["{$phrasename}"]) ? construct_phrase($vbphrase["{$phrasename}"], $vbulletin->options['bbtitle']) : "{$phrasename}";
        ($hook = vBulletinHook::fetch_hook('fb_publish_message')) ? eval($hook) : false;
        $message = to_utf8($message, vB_Template_Runtime::fetchStyleVar('charset'));
        $title = to_utf8($title, vB_Template_Runtime::fetchStyleVar('charset'));
        $body = to_utf8($body, vB_Template_Runtime::fetchStyleVar('charset'));
        return vB_Facebook::instance()->publishFeed($message, $title, $link, $body);
    } else {
        return false;
    }
}
/**
* Publishes a message to users feed, given a phrase as the message
* 
* @param	the name of the phrase to publish in the message
* @param	the title of the new thread
* @param	the body of the first post in the thread
* @param	the url to the first post in the thread
* 
* @return	bool	true if the publish worked, false otherwise
*/
function publishtofacebook($phrasename, $title, $body, $link)
{
	global $vbphrase, $vbulletin;
	
	// check if  Facebook user is active and user wants to publish
	if (is_userfbconnected() AND is_userfbactive() AND check_fbpublishcheckbox())
	{
		// get the preview text for the body
		$body = fetch_trimmed_title(strip_bbcode($body, true, false, true, true), 300);

		// if phrasename is not in the phrase array, simply use phrasename as the message
		$message = isset($vbphrase[$phrasename]) ? construct_phrase($vbphrase[$phrasename], $vbulletin->options['bbtitle']): "$phrasename";
		return vB_Facebook::instance()->publishFeed($message, $title, $link, $body);
	}

	// if we failed the check, return false
	else
	{
		return false;
	}
}