public function ajaxImportData($importStatus, $importAvatar) { $response = new JAXResponse(); $importStatus = (bool) $importStatus; $importAvatar = (bool) $importAvatar; $config = CFactory::getConfig(); // @rule: When administrator disables status imports, we should not allow user to import status if (!$config->get('fbconnectupdatestatus')) { $importStatus = false; } CFactory::load('libraries', 'facebook'); jimport('joomla.user.helper'); // Once they reach here, we assume that they are already logged into facebook. // Since CFacebook library handles the security we don't need to worry about any intercepts here. $facebook = new CFacebook(); $connectModel = CFactory::getModel('Connect'); $connectTable =& JTable::getInstance('Connect', 'CTable'); $mainframe =& JFactory::getApplication(); $config = CFactory::getConfig(); $userId = $facebook->getUser(); $connectTable->load($userId); $fields = array('first_name', 'last_name', 'birthday', 'current_location', 'status', 'pic', 'sex', 'name', 'pic_square', 'profile_url', 'pic_big', 'current_location'); $userInfo = $facebook->getUserInfo($fields, $userId); //@todo: configurable redirect for continue button $my = CFactory::getUser(); $redirect = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id, false); if (COwnerHelper::isCommunityAdmin($connectTable->userid)) { $tmpl = new CTemplate(); $content = $tmpl->fetch('facebook.link.notallowed'); $buttons = '<input type="button" value="' . JText::_('CC BUTTON CLOSE') . '" class="button" onclick="cWindowHide();" />'; $response->addScriptCall('cWindowActions', $buttons); $response->addAssign('cWindowContent', 'innerHTML', $content); $response->addScriptCall('cWindowResize', 150); return $response->sendResponse(); } if ($importAvatar) { $facebook->mapAvatar($userInfo['pic_big'], $my->id, $config->get('fbwatermark')); } if ($importStatus) { $facebook->mapStatus($my->id); } if (!JString::stristr($my->email, '@foo.bar')) { /** HTGMOD **/ // Start Hooked Modfication $device = JFactory::getSession()->get('device', ''); if ($device == 'ios') { JFactory::getSession()->set('device', ''); $db = JFactory::getDBO(); $query = "SELECT hash FROM #__api_keys WHERE user_id = " . $db->Quote($my->id); $db->setQuery($query); $apikey = $db->loadResult(); if (!$apikey) { jimport('joomla.application.component.model'); JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables'); JModel::addIncludePath(JPATH_SITE . '/components/com_api/models'); JLoader::register('ApiModel', JPATH_SITE . '/components/com_api/libraries/model.php'); $model = JModel::getInstance('Key', 'ApiModel'); $data = array('user_id' => $my->id, 'domain' => 'localhost', 'published' => 1); $key = $model->save($data); $apikey = $key->hash; } $redirect = 'hooked://' . $apikey; } // End Hooked modification /** END HTGMOD **/ $response->addScriptCall('cWindowHide();'); $response->addScriptCall('window.location.href = "' . $redirect . '";'); return $response->sendResponse(); } // Deprecated since 1.6.x // In older releases, connected users uses the email @foo.bar by default. // If it passes the above, the user definitely needs to edit the e-mail. $tmpl = new CTemplate(); $tmpl->set('my', $my); $content = $tmpl->fetch('facebook.emailupdate'); $buttons = '<form name="jsform-connect-ajaximportdata" method="post" action="' . $redirect . '" style="float:right;">'; $buttons .= '<input type="submit" value="' . JText::_('CC SKIP BUTTON') . '" class="button" name="Submit"/>'; $buttons .= '</form>'; $buttons .= '<input type="button" value="' . JText::_('CC UPDATE EMAIL BUTTON') . '" class="button" onclick="joms.connect.updateEmail();" />'; // Add invite button $response->addScriptCall('cWindowResize', 150); $response->addAssign('cWindowContent', 'innerHTML', $content); $response->addScriptCall('joms.jQuery("#cwin_logo").html("' . $config->get('sitename') . '");'); $response->addScriptCall('cWindowActions', $buttons); $response->sendResponse(); }
public function ajaxImportData($importStatus, $importAvatar) { $response = new JAXResponse(); $filter = JFilterInput::getInstance(); $importStatus = $filter->clean($importStatus, 'boolean'); $importAvatar = $filter->clean($importAvatar, 'boolean'); $config = CFactory::getConfig(); // @rule: When administrator disables status imports, we should not allow user to import status if (!$config->get('fbconnectupdatestatus')) { $importStatus = false; } CFactory::load('libraries', 'facebook'); jimport('joomla.user.helper'); // Once they reach here, we assume that they are already logged into facebook. // Since CFacebook library handles the security we don't need to worry about any intercepts here. $facebook = new CFacebook(); $connectModel = CFactory::getModel('Connect'); $connectTable =& JTable::getInstance('Connect', 'CTable'); $mainframe =& JFactory::getApplication(); $config = CFactory::getConfig(); $userId = $facebook->getUser(); $connectTable->load($userId); $fields = array('first_name', 'last_name', 'birthday_date', 'current_location', 'status', 'pic', 'sex', 'name', 'pic_square', 'profile_url', 'pic_big', 'current_location'); $userInfo = $facebook->getUserInfo($fields, $userId); $my = CFactory::getUser(); $redirect = CRoute::_('index.php?option=com_community&view=' . $config->get('redirect_login'), false); if (COwnerHelper::isCommunityAdmin($connectTable->userid)) { $tmpl = new CTemplate(); $content = $tmpl->fetch('facebook.link.notallowed'); $actions = '<input type="button" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '" class="button" onclick="cWindowHide();" />'; $response->addScriptCall('cWindowAddContent', $content, $actions); return $response->sendResponse(); } if ($importAvatar) { $facebook->mapAvatar($userInfo['pic_big'], $my->id, $config->get('fbwatermark')); } if ($importStatus) { $facebook->mapStatus($my->id); } if (!JString::stristr($my->email, '@foo.bar')) { $response->addScriptCall('cWindowHide();'); $response->addScriptCall('window.location.href = "' . $redirect . '";'); return $response->sendResponse(); } // Deprecated since 1.6.x // In older releases, connected users uses the email @foo.bar by default. // If it passes the above, the user definitely needs to edit the e-mail. $tmpl = new CTemplate(); $tmpl->set('my', $my); $content = $tmpl->fetch('facebook.emailupdate'); $actions = '<form name="jsform-connect-ajaximportdata" method="post" action="' . $redirect . '" style="float:right;">'; $actions .= '<input type="submit" value="' . JText::_('COM_COMMUNITY_SKIP_BUTTON') . '" class="button" name="Submit"/>'; $actions .= '</form>'; $actions .= '<input type="button" value="' . JText::_('COM_COMMUNITY_UPDATE_EMAIL_BUTTON') . '" class="button" onclick="joms.connect.updateEmail();" />'; // Add invite button $response->addAssign('cwin_logo', 'innerHTML', $config->get('sitename')); $response->addScriptCall('cWindowAddContent', $content, $actions); $response->sendResponse(); }