Example #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";
		return vB_Facebook::instance()->publishFeed($message, $title, $link, $body);
	}

	// if we failed the check, return false
	else
	{
		return false;
	}
}
Example #2
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;
    }
}
Example #3
0
	/**
	* Processes the global templates (header, footer, etc) and the variables they need.
	*/
	public function process_templates()
	{
		if ($this->called('template'))
		{
			return;
		}
		$this->called['template'] = true;

		$this->load_style();

		global $vbulletin, $show, $vbphrase, $style, $template_hook;

		$this->cache_templates($style['templatelist']);

		// #############################################################################
		// turn off popups if they are not available to this browser
		if ($vbulletin->options['usepopups'])
		{
			if ((is_browser('ie', 5) AND !is_browser('mac')) OR is_browser('mozilla') OR is_browser('firebird') OR is_browser('opera', 7) OR is_browser('webkit') OR is_browser('konqueror', 3.2))
			{
				// use popups
			}
			else
			{
				// don't use popups
				$vbulletin->options['usepopups'] = 0;
			}
		}

		global $vbcollapse;
		$vbcollapse = self::build_vbcollapse($vbulletin->GPC['vbulletin_collapse']);

		// #############################################################################
		// set up the vars for the private message area of the navbar
		global $pmbox;
		$pmbox = array(
			'lastvisitdate' => vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit'], 1),
			'lastvisittime' => vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit'])
		);

		if ($vbulletin->userinfo['userid'])
		{
			$pmunread_html = construct_phrase(($vbulletin->userinfo['pmunread'] ? $vbphrase['numeric_value_emphasized'] : $vbphrase['numeric_value']), $vbulletin->userinfo['pmunread']);
			$vbphrase['unread_x_nav_compiled'] = construct_phrase($vbphrase['unread_x_nav'], $pmunread_html);
			$vbphrase['total_x_nav_compiled'] = construct_phrase($vbphrase['total_x_nav'], $vbulletin->userinfo['pmtotal']);
		}

		// #############################################################################
		// Generate Language/Style Chooser Dropdowns
		if (empty($_POST['do']))
		{
			$languagecount = 0;
			$languagechooserbits = construct_language_options('--', true, $languagecount);
			$show['languagechooser'] = ($languagecount > 1 ? true : false);
		}
		else
		{
			$show['languagechooser'] = false;
		}

		if ($vbulletin->options['allowchangestyles'] AND empty($_POST['do']))
		{
			$stylecount = 0;
			$quickchooserbits = construct_style_options(-1, '--', true, true, $stylecount);
			$show['quickchooser'] = ($stylecount > 1 ? true : false);
		}
		else
		{
			$show['quickchooser'] = false;
		}

		// #############################################################################
		// do cron stuff - goes into footer
		if ($vbulletin->cron <= TIMENOW)
		{
			$cronimage = '<img src="' . create_full_url('cron.php?' . $vbulletin->session->vars['sessionurl'] . 'rand=' .  TIMENOW) . '" alt="" width="1" height="1" border="0" />';
		}
		else
		{
			$cronimage = '';
		}

		global $ad_location;

		// parse some global templates
		global $gobutton, $spacer_open, $spacer_close;
		$gobutton = vB_Template::create('gobutton')->render();
		$spacer_open = vB_Template::create('spacer_open')->render();
		$spacer_close = vB_Template::create('spacer_close')->render();

		// facebook templates
		if (is_facebookenabled())
		{
			$templater = vB_Template::create('facebook_opengraph');
			$templater->register('opengrapharray', get_fbopengrapharray());
			$facebook_opengraph = $templater->render();

			$templater = vB_Template::create('facebook_header');
			$templater->register('profileurl', get_fbprofileurl());
			$templater->register('squarepicurl', get_fbprofilepicurl());
			$facebook_header = $templater->render();

			$templater = vB_Template::create('facebook_footer');
			$templater->register('connected', (is_userfbconnected() ? 1 : 0));
			$templater->register('active', (is_userfbactive() ? 1 : 0));
			$facebook_footer = $templater->render();
		}

		($hook = vBulletinHook::fetch_hook('parse_templates')) ? eval($hook) : false;

		// parse headinclude, header & footer
		$admincpdir = $vbulletin->config['Misc']['admincpdir'];
		$modcpdir = $vbulletin->config['Misc']['modcpdir'];

		// advertising location setup
		$template = vB_Template::create('ad_navbar_below');
		$template->register('adsense_pub_id', $vbulletin->adsense_pub_id);
		$template->register('adsense_host_id', $vbulletin->adsense_host_id);
		$ad_location['ad_navbar_below'] = $template->render();

		$ad_location['global_header1'] = vB_Template::create('ad_global_header1')->render();
		$ad_location['global_header2'] = vB_Template::create('ad_global_header2')->render();
		$ad_location['global_below_navbar'] = vB_Template::create('ad_global_below_navbar')->render();
		$ad_location['global_above_footer'] = vB_Template::create('ad_global_above_footer')->render();

		$template = vB_Template::create('ad_footer_start');
		$template->register('adsense_pub_id', $vbulletin->adsense_pub_id);
		$template->register('adsense_host_id', $vbulletin->adsense_host_id);
		$ad_location['ad_footer_start'] = $template->render();

		// #############################################################################
		// handle notices
		global $notices;
		$notices = $this->build_notices();
		$show['notices'] = ($notices !== '');

		// #############################################################################
		// set up user notifications
		$notifications = $this->build_notifications();
		if ($notifications)
		{
			$show['notifications'] = true;
			global $notifications_menubits, $notifications_total;
			$notifications_menubits = $notifications['bits'];
			$notifications_total = $notifications['total'];
		}
		else
		{
			$notifications_menubits = '';
			$notifications_total = '';
			$show['notifications'] = false;
		}

		$newpm = $this->check_new_pm();

		// #############################################################################
		// page number is used in meta tags (sometimes)
		global $pagenumber, $headinclude, $headinclude_bottom, $header, $footer;
		global $threadinfo, $foruminfo;
		if ($pagenumber === NULL)
		{
			$pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT);
		}

		$templater = vB_Template::create('headinclude');
			$templater->register('foruminfo', $foruminfo);
			$templater->register('pagenumber', $pagenumber);
			$templater->register('style', $style);
			$templater->register('basepath', $vbulletin->input->fetch_basepath());
			$templater->register('this_script', THIS_SCRIPT);
			$templater->register('facebook_opengraph', $facebook_opengraph);
		$headinclude = $templater->render();

		$templater = vB_Template::create('headinclude_bottom');
			$templater->register('foruminfo', $foruminfo);
			$templater->register('pagenumber', $pagenumber);
			$templater->register('style', $style);
			$templater->register('basepath', $vbulletin->input->fetch_basepath());
		$headinclude_bottom = $templater->render();

		$templater = vB_Template::create('header');
			$templater->register('ad_location', $ad_location);
			$templater->register('pmbox', $pmbox);
			$templater->register('notifications_menubits', $notifications_menubits);
			$templater->register('notifications_total', $notifications_total);
			$templater->register('notices', $notices);
			$templater->register('facebook_header', $facebook_header);
		$header = $templater->render();

		$templater = vB_Template::create('footer');
			$templater->register('admincpdir', $admincpdir);
			$templater->register('ad_location', $ad_location);
			$templater->register('cronimage', $cronimage);
			$templater->register('languagechooserbits', $languagechooserbits);
			$templater->register('modcpdir', $modcpdir);
			$templater->register('quickchooserbits', $quickchooserbits);
			$templater->register('template_hook', $template_hook);
			$templater->register('facebook_footer', $facebook_footer);
		$footer = $templater->render();

		// #############################################################################
		// Check for pm popup
		if ($newpm)
		{
			if ($vbulletin->userinfo['pmunread'] == 1)
			{
				$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'] . "do=showpm&pmid=$newpm[pmid]";
			}
			else if (!empty($vbulletin->session->vars['sessionurl_js']))
			{
				$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'];
			}
			else
			{
				$pmpopupurl = 'private.php';
			}
			$templater = vB_Template::create('pm_popup_script');
				$templater->register('newpm', $newpm);
				$templater->register('pmpopupurl', $pmpopupurl);
			$footer .= $templater->render();
		}

		if (!$vbulletin->options['bbactive'] AND
			($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
		{
			// show the board disabled warning message so that admins don't leave the board turned off by accident
			$warning = vB_Template::create('board_inactive_warning')->render();
			$header = $warning . $header;
			$footer .= $warning;
		}

		($hook = vBulletinHook::fetch_hook('process_templates_complete')) ? eval($hook) : false;

		exec_headers();
	}