public function replaceOutput($renderer) { if (!Kwf_Config::getValue('fbAppData.siteId')) { throw new Kwf_Exception('fbAppData.siteId has to be set in config'); } $facebook = Kwf_Util_Facebook_Api::getInstance(); $userId = $facebook->getUser(); if (!$userId) { $signedRequest = $facebook->getSignedRequest(); if (!$signedRequest['page']['liked']) { $like = false; } else { $like = true; } } else { $like = false; $likes = $facebook->api('/' . $userId . '/likes'); $fanSiteId = trim(Kwf_Config::getValue('fbAppData.siteId')); foreach ($likes['data'] as $l) { if ($l['id'] == $fanSiteId) { $like = true; } } } if (!$like) { return '<script>top.location.href = "' . $this->_getRedirectPage() . '";</script>"'; } return false; }
public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
public function replaceOutput($renderer) { $facebook = Kwf_Util_Facebook_Api::getInstance(); //no redirect if cli, or address contains assets, admin or kwf if (PHP_SAPI != 'cli' && !preg_match('#^/admin|^/kwf|^/assets#', $_SERVER['REQUEST_URI'])) { if (!isset($_COOKIE[session_name()])) { Kwf_Session::start(); if (!isset($_COOKIE[session_name()])) { $serverDomain = 'http://' . Kwf_Config::getValue('server.domain'); return "<script>top.location.href=\"{$serverDomain}/home\";</script>"; } } } return false; }
public function replaceOutput($renderer) { if (!Kwf_Config::getValue('fbAppData.pageTabUrl')) { throw new Kwf_Exception('fbAppData.pageTabUrl has to be set in config'); } $facebook = Kwf_Util_Facebook_Api::getInstance(); $userId = $facebook->getUser(); $signedRequest = $facebook->getSignedRequest(); // check, if user is authed, or if we are on the right pagetab //(that information is provided by the signedRequest) if (isset($_REQUEST['request_ids'])) { echo '<script>top.location.href = "' . Kwf_Config::getValue('fbAppData.pageTabUrl') . '";</script>'; exit; } else { return false; } }