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}";
        ($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 #2
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();
	}
Example #3
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 #4
0
	/** Creates the publish editor at the top right of the edit section
	 *
	 * @return mixed
	 *
	 ****/
	public function getPublishEditor($submit_url, $formid, $showpreview = true, $showcomments = true,
		$publicpreview = false, $comments_enabled = false, $pagination_links = 1)
	{

		if ($this->canPublish())
		{
			$pub_view = new vB_View('vbcms_edit_publisher');
			$pub_view->formid = $formid;
			$pub_view->setpublish = $this->setpublish;

			// if this is an unpublished article then we display publish to facebook
			if (is_facebookenabled() AND vB::$vbulletin->options['fbfeednewarticle'] AND !$this->setpublish)
			{
				// only display box if user is connectected to facebook
				$pub_view->showfbpublishcheckbox = is_userfbconnected();
			}

			//Get date is a most annoying function for us. It takes a Unix time stamp
			// and converts it to server local time. We need to compensate for the difference between
			// server time (date('Z')) and usertime (vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo))
			$offset = vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo) - date('Z');

			if (intval($this->publishdate))
			{
				$pub_view->publishdate = $this->publishdate ;
			}
			else
			{
				// get the current date/time dependent on user locality
				$pub_view->publishdate = TIMENOW;
			}

			$then = getdate(intval($pub_view->publishdate) + $offset);

			$pub_view->hour = $then['hours'];
			$pub_view->minute = $then['minutes'];
			//we need to parse out the date and time

			//Are we using a 24 hour clock?
			if ((strpos(vB::$vbulletin->options['timeformat'], 'G') !== false) OR
				(strpos( vB::$vbulletin->options['timeformat'], 'H') !== false))
			{
				$pub_view->show24 = 1;

			}
			else
			{
				$pub_view->show24 = 0;
				$pub_view->offset = $pub_view->hour >= 12 ? 'PM' : 'AM';
				if ($pub_view->hour > 12)
				{
					$pub_view->hour -= 12;
				}
			}

			$pub_view->title = $this->title;
			$pub_view->html_title = $this->html_title;
			$pub_view->username = $this->username;
			$pub_view->dateformat = vB::$vbulletin->options['dateformat'];
			// get the appropriate date format string for the
			// publish date calendar based on user's locale
			$pub_view->calendardateformat = (!empty(vB::$vbulletin->userinfo['lang_dateoverride']) ? '%Y/%m/%d' : 'Y/m/d');
			$pub_view->groups = $this->getReaderGroups();
			$pub_view->parents = $this->getParentage();
			$pub_view->submit_url = $submit_url;
			$pub_view->sectiontypeid = vb_Types::instance()->getContentTypeID("vBCms_Section");
			$pub_view->parents = $this->getParentage();
			$pub_view->showtitle = $this->getShowTitle();
			$pub_view->showuser = $this->getShowUser();
			$pub_view->showpreviewonly = $this->getShowPreviewonly();
			$pub_view->showupdated = $this->getShowUpdated();
			$pub_view->showviewcount = $this->getShowViewcount();
			$pub_view->showpublishdate = $this->getShowPublishdate();
			$pub_view->settingsforboth = $this->getSettingsForboth();
			$pub_view->showall = $this->getShowall();
			$pub_view->includechildren = $this->getIncludeChildren();
			$pub_view->showrating = $this->getShowRating();
			$pub_view->hidden = $this->getHidden();
			$pub_view->pagination_links = $pagination_links;
			$pub_view->show_pagination_link =
				($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section") ) ? 1 : 0;
			$pub_view->shownav = $this->getShowNav();
			$pub_view->show_shownav =
				($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section") ) ? 0 : 1;
			$pub_view->nosearch = $this->getNoSearch();

			$sectionid = (1 == $this->nodeid) ? 1 : $this->parentnode;

			$pub_view->hours24 = vB::$vbulletin->options['dateformat'];
			if ($this->contenttypeid == $pub_view->sectiontypeid)
			{
				$pub_view->show_categories = 0;
				$pub_view->is_section = 1;
				$pub_view->show_showsettings = 0;
			}
			else
			{
				$pub_view->show_categories = 1;
				$pub_view->categories = $this->getThisCategories();
				$pub_view->show_showsettings = 1;
				$pub_view->is_section = 0;
				$pub_view->sectionid = $this->parentnode;
			}

			if ($pub_view->show_htmloption = (
				$this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Article")	// this is limited here to article but could be moved to any contenttype
					AND
				$this->canusehtml	// this is set by some of the member functions above...
			))
			{
				$pub_view->htmloption = $this->htmlstate;
			}
			$pub_view->show_categories = ($this->contenttypeid == $pub_view->sectiontypeid ? 0 : 1);

			//get the nodes
			$nodelist = vBCms_ContentManager::getSections(false);

			if (! isset(vB::$vbulletin->userinfo['permissions']['cms']) )
			{
				vBCMS_Permissions::getUserPerms();
			}

			foreach ($nodelist as $key => $node)
			{
				if (in_array(strval($node['permissionsfrom']), vB::$vbulletin->userinfo['permissions']['cms']['canpublish']))
				{
					$nodelist[$key]['selected'] = ($sectionid == $node['nodeid'] ? 'selected="selected"' : '');
				}
				else
				{
					unset($nodelist[$key]);
				}
			}

			$pub_view->nodelist = $nodelist;
			$pub_view->showpreview = $showpreview;
			$pub_view->showcomments = $showcomments;
			$pub_view->publicpreview = $publicpreview;
			$pub_view->hidden = $this->hidden;
			$pub_view->comments_enabled = $comments_enabled;
			$pub_view->show_sections = (1 != $this->nodeid);

			return $pub_view;
		}
	}