本文整理汇总了PHP中JFBCFactory::usermap方法的典型用法代码示例。如果您正苦于以下问题:PHP JFBCFactory::usermap方法的具体用法?PHP JFBCFactory::usermap怎么用?PHP JFBCFactory::usermap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFBCFactory
的用法示例。
在下文中一共展示了JFBCFactory::usermap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTagHtml
protected function getTagHtml()
{
$user = JFactory::getUser();
$buttonHtml = '';
$providers = $this->getSelectedProviders($this->getParamValue('providers'));
if ($user->guest) {
$buttonHtml = $this->getLoginButtons($providers);
} else {
$showReconnect = $this->getParamValueEx('show_reconnect', null, 'boolean', 'false');
$showLogoutButton = $this->getParamValueEx('logout', null, 'boolean', 'false');
$logoutUrl = $this->getParamValueEx('logout_url', null, null, JURI::root());
if ($showLogoutButton == 'true') {
$logoutUrl = base64_encode(JRoute::_($logoutUrl, false));
$logoutButtonId = $this->providerLoginInfo[$this->provider->name]->logoutButtonId;
$buttonHtml = '<input type="submit" name="Submit" id="' . $logoutButtonId . '" class="button btn btn-primary" value="' . JText::_('JLOGOUT') . "\" onclick=\"javascript:jfbc.login.logout('" . $logoutUrl . "')\" />";
}
if ($showReconnect == "true") {
// get all providers and check if mapping exists. Then, get the buttons for providers the user hasn't connected with
$mapProviders = array();
foreach ($providers as $provider) {
$userData = JFBCFactory::usermap()->getUser(JFactory::getUser()->id, $provider->systemName)->_data;
if (empty($userData->provider_user_id)) {
$mapProviders[] = $provider;
}
}
$buttonHtml = $this->getLoginButtons($mapProviders, ' reconnect');
}
}
return $buttonHtml;
}
示例2: getInput
function getInput()
{
$jid = $this->form->getValue('attribs.user_id');
if ($jid) {
$uid = JFBCFactory::usermap()->getProviderUserId($jid, 'linkedin');
if ($uid) {
$access_token = JFBCFactory::usermap()->getUserAccessToken($jid, 'linkedin');
$params['access_token'] = $access_token;
$liLibrary = JFBCFactory::provider('linkedin');
$liLibrary->client->setToken((array) $access_token);
$url = 'https://api.linkedin.com/v1/companies/?is-company-admin=true&start=0&count=20';
try {
$companies = $liLibrary->client->query($url);
if ($companies->code == '200') {
$this->companies = json_decode($companies->body);
}
return parent::getInput();
} catch (Exception $e) {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_LINKEDIN_PERM_TOKEN_EXPIRED_LABEL') . '</div>';
}
} else {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_LINKEDIN_PERM_USER_AUTH_ERROR_LABEL') . '</div>';
}
} else {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_SELECT_USER_ERROR_LABEL') . '</div>';
}
}
示例3: post
public function post()
{
$app = JFactory::getApplication();
//$type = $app->input->get('type','story','STRING');
$provider_nm = $app->input->get('provider', 'facebook', 'CMD');
$user_id = $app->input->get('user_id', 0, 'INT');
$tokan = $app->input->get('tokan', 0, 'RAW');
$email = $app->input->get('email', '', 'STRING');
$password = $app->input->get('password', '', 'STRING');
//$log_usr = $this->plugin->get('user')->id;
$provider = JFBCFactory::provider($provider_nm);
$provider->client->authenticate();
$loginRegisterModel = JFBCFactory::model('LoginRegister');
//$user = jFactory::getUser(161);
$provider->setSessionToken();
$provider->client->setExtendedAccessToken();
//$provider_obj->client->getUser();
$provider->onBeforeLogin();
$config = JFactory::getConfig();
$lifetime = $config->get('lifetime', 15);
setcookie('jfbconnect_autologin_disable', 1, time() + $lifetime * 60);
$providerUserId = $provider->getProviderUserId();
$userMapModel = JFBCFactory::usermap();
$jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
$jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($email);
//get temp id
if ($jUserEmailId) {
$providerUserId = $userMapModel->getProviderUserId($jUserEmailId, strtolower($provider->name));
$jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
} else {
if (!$jUserEmailId && JFBCFactory::config()->getSetting('automatic_registration')) {
//# User is not in system, should create their account automatically
//$jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($email);
if (!$jUserEmailId) {
$pdata = array();
$pdata['email'] = $email;
$pdata['password'] = $password;
$fbuser = $loginRegisterModel->createNewUser($provider);
}
if ($loginRegisterModel->autoCreateUser($providerUserId, $provider)) {
$jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
}
}
}
$jUser = JUser::getInstance($jUserId);
$loginSuccess = false;
// Try to log the user, but not if blocked and initial registration (then there will be a pretty message on how to activate)
if (!$provider->initialRegistration || $jUser->get('block') == 0 && $provider->initialRegistration) {
$options = array('silent' => 1, 'provider' => $provider, 'provider_user_id' => $providerUserId);
// Disable other authentication messages
// hack for J3.2.0 bug. Should remove after 3.2.1 is available.
$password = $provider->secretKey;
$loginSuccess = $app->login(array('username' => $provider->appId, 'password' => $password), $options);
}
$this->plugin->setResponse($jUser);
}
示例4: canPublish
public function canPublish($data)
{
$canPublish = false;
$jid = $data['attribs']['user_id'];
if ($jid) {
$uid = JFBCFactory::usermap()->getProviderUserId($jid, 'facebook');
if ($uid && isset($data['attribs']['page_id']) && $data['attribs']['page_id'] != '--' && JFBCFactory::provider('facebook')->hasScope($uid, 'manage_pages') && (JFBCFactory::provider('facebook')->hasScope($uid, 'publish_actions') || !$data['attribs']['allow_posts'])) {
$canPublish = true;
}
}
return $canPublish;
}
示例5: post
public function post(JRegistry $data)
{
$groupId = $this->options->get('group_id');
$message = $data->get('message', '');
$link = $data->get('link', '');
$params = array();
$params['access_token'] = JFBCFactory::usermap()->getUserAccessToken($this->options->get('user_id'), 'facebook');
$params['message'] = $message;
$params['link'] = $link;
$return = $this->provider->api($groupId . '/feed', $params);
if ($return !== false) {
return JText::_('COM_JFBCONNECT_CHANNELS_FACEBOOK_GROUP_POST_SUCCESS');
} else {
return false;
}
}
示例6: loginMap
public function loginMap()
{
JRequest::checkToken('post') or jexit(JText::_('JInvalid_Token'));
$app = JFactory::getApplication();
$provider = JFactory::getApplication()->input->getCmd('provider');
$provider = JFBCFactory::provider($provider);
SCSocialUtilities::setJFBCNewMappingEnabled();
$loginRegisterModel = $this->getModel('LoginRegister', 'JFBConnectModel');
$redirect = $loginRegisterModel->getLoginRedirect($provider);
$returnParam = '&return=' . base64_encode($redirect);
$providerUserId = $provider->getProviderUserId();
if (!$providerUserId) {
$app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . $provider->systemName . $returnParam, false));
}
// Populate the data array:
$data = array();
$data['username'] = JRequest::getVar('username', '', 'method', 'username');
$data['password'] = JRequest::getString('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
// Perform the log in.
$error = $app->login($data);
// Check if the log in succeeded.
if (JError::isError($error) || $error == false) {
$app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . $provider->systemName . $returnParam, false));
} else {
$jUser = JFactory::getUser();
if (JFBCFactory::usermap()->map($jUser->get('id'), $providerUserId, $provider->systemName, $provider->client->getToken())) {
JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
}
/* Don't import on just a mapping update, for now. Need to investigate.
$jUser = JFactory::getUser();
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $jfbcLibrary->getMappedFbUserId();
$args = array($jUser->get('id'), $fbUserId);
JPluginHelper::importPlugin('jfbcprofiles');
$app->triggerEvent('scProfilesImportProfile', $args);
JFBCFactory::log('Profile Imported!');*/
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/' . 'models');
$loginRegisterModel = JModelLegacy::getInstance('LoginRegister', 'JFBConnectModel');
$redirect = $loginRegisterModel->getLoginRedirect($provider);
$app->redirect($redirect);
}
}
示例7: onUserAfterSave
function onUserAfterSave($user, $isnew, $success, $msg)
{
if (!$isnew) {
return true;
}
$app = JFactory::getApplication();
if ($app->getUserState('com_jfbconnect.registration.alternateflow', false)) {
$provider = $app->getUserState('com_jfbconnect.registration.provider.name', null);
$providerUserId = $app->getUserState('com_jfbconnect.registration.provider.user_id', null);
if ($provider && $providerUserId) {
$provider = JFBCFactory::provider($provider);
if ($user['id'] && $provider->getProviderUserId() == $providerUserId) {
JFBCFactory::usermap()->map($user['id'], $providerUserId, $provider->systemName, $provider->client->getToken());
// If that worked, now call the originating plugin and tell it to finalize anything with the new user
$args = array($provider->name, $user['id'], $providerUserId);
$app->triggerEvent('socialProfilesOnNewUserSave', $args);
}
}
}
}
示例8: getInput
function getInput()
{
$jid = $this->form->getValue('attribs.user_id');
if ($jid) {
$uid = JFBCFactory::usermap()->getProviderUserId($jid, 'facebook');
if ($uid) {
if (!JFBCFactory::provider('facebook')->hasScope($uid, 'user_managed_groups')) {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_USER_GROUPS_ERROR_LABEL') . '</div>';
} else {
if (!JFBCFactory::provider('facebook')->hasScope($uid, 'publish_actions') && $this->form->getValue('attribs.allow_posts')) {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_PUBLISH_ACTIONS_ERROR_LABEL') . '</div>';
} else {
return parent::getInput();
}
}
} else {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_PAGE_USER_AUTH_ERROR_LABEL') . '</div>';
}
} else {
return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_SELECT_USER_ERROR_LABEL') . '</div>';
}
}
示例9: post
public function post(JRegistry $data)
{
$path = $this->provider->options->get('api.url') . 'statuses/update.json';
$message = $data->get('message', '');
$link = $data->get('link', '');
// t.co length. Should update this to use the help/configuration check to verify it hasn't grown.
$urlLength = 23;
// +1 for https
$status = substr($message, 0, 140 - $urlLength - 1) . " " . $link;
$user = $this->options->get('user_id');
$accessToken = JFBCFactory::usermap()->getUserAccessToken($user, 'twitter');
$params = array();
$params['oauth_token'] = $accessToken->key;
$this->provider->client->setToken((array) $accessToken);
$data = array();
$data['status'] = $status;
$return = $this->provider->client->oauthRequest($path, 'POST', $params, $data);
if ($return !== false) {
return JText::_('COM_JFBCONNECT_CHANNELS_TWITTER_STREAM_POST_SUCCESS');
} else {
return false;
}
}
示例10: display
function display($tpl = null)
{
$configModel = JFBCFactory::config();
$usermapModel = JFBCFactory::usermap();
$autotuneModel = JModelLegacy::getInstance('AutoTune', 'JFBConnectModel');
if (JFBCFactory::provider('facebook')->appId) {
$appConfig = JFBCFactory::config()->get('autotune_app_config', null);
if (!$appConfig || count($appConfig) == 0) {
JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MSG_RUN_AUTOTUNE', '<a href="index.php?option=com_jfbconnect&view=autotune">AutoTune</a>'), 'error');
}
}
$userCounts = array();
foreach (JFBCFactory::getAllProviders() as $p) {
if ($p->appId) {
$userCounts[$p->systemName] = $usermapModel->getTotalMappings($p->systemName);
}
}
$this->configModel = $configModel;
$this->autotuneModel = $autotuneModel;
$this->usermapModel = $usermapModel;
$this->userCounts = $userCounts;
$this->addToolbar();
parent::display($tpl);
}
示例11: post
public function post(JRegistry $data)
{
$user = $this->options->get('user_id');
$access_token = JFBCFactory::usermap()->getUserAccessToken($user, 'linkedin');
$this->provider->client->setToken((array) $access_token);
$companyId = $this->options->get('company_id');
$url = 'https://api.linkedin.com/v1/companies/' . $companyId . '/shares';
$vals = array();
$vals['visibility'] = array('code' => 'anyone');
$vals['comment'] = $data->get('message', '');
$vals['content'] = array('submitted-url' => $data->get('link', ''));
$vals = json_encode($vals);
$return = $this->provider->client->query($url, $vals, array(), 'post');
if ($return !== false) {
return JText::_('COM_JFBCONNECT_CHANNELS_LINKEDIN_STREAM_POST_SUCCESS');
} else {
return false;
}
}
示例12: getProviderAvatar
function getProviderAvatar($provider, $user)
{
$html = "";
$providerId = JFBCFactory::usermap()->getProviderUserId($user->get('id'), $provider->systemName);
if ($providerId) {
$params = new JRegistry();
$params->set('width', $this->params->get("profileWidth"));
$params->set('height', $this->params->get("profileHeight"));
$params->set('secure', JURI::getInstance()->getScheme() == 'https');
$avatarURL = $provider->profile->getAvatarUrl($providerId, false, $params);
$profileURL = $provider->profile->getProfileUrl($providerId);
$html = $this->getAvatarHtml($avatarURL, $profileURL, "_blank");
}
return $html;
}
示例13: autoCreateUser
function autoCreateUser($providerUserId, $provider)
{
$provider->setInitialRegistration();
$profile = $provider->profile->fetchProfile($providerUserId, array('first_name', 'last_name', 'email', 'full_name'));
if ($profile == null || $profile->get('email') == null) {
# not enough information returned to auto-create account
return false;
}
$newEmail = $profile->get('email');
$fullname = $profile->get('full_name');
$user['fullname'] = $fullname;
$user['email'] = $newEmail;
// Create random password for FB User Only, but save so we can email to the user on account creation
if (JFBCFactory::config()->getSetting('generate_random_password')) {
$this->_newUserPassword = JUserHelper::genRandomPassword();
$user['password_clear'] = $this->_newUserPassword;
// Check for Joomla 3.2.1's new hashPassword functions and use those, if exist
if (method_exists('JUserHelper', 'hashPassword')) {
$user['password'] = JUserHelper::hashPassword($this->_newUserPassword);
} else {
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($this->_newUserPassword, $salt);
$user['password'] = $crypt . ':' . $salt;
}
} else {
$user['password_clear'] = "";
$this->_newUserPassword = '';
}
$lang = JRequest::getVar(JApplication::getHash('language'), '', 'COOKIE');
$user['language'] = $lang;
$usernamePrefixFormat = JFBCFactory::config()->getSetting('auto_username_format');
$username = SCUserUtilities::getAutoUsername($profile->get('first_name'), $profile->get('last_name'), $profile->get('email'), $provider->usernamePrefix, $providerUserId, $usernamePrefixFormat);
$user['username'] = $username;
$useractivation = $this->getActivationMode();
$jUser = $this->getBlankUser($user, $useractivation);
if ($jUser && $jUser->get('id', null)) {
$this->onAfterRegister($provider, $jUser);
SCSocialUtilities::clearJFBCNewMappingEnabled();
if (JFBCFactory::usermap()->map($jUser->get('id'), $providerUserId, $provider->systemName, $provider->client->getToken())) {
JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
return true;
} else {
JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
}
}
return false;
// User creation failed for some reason
}
示例14: onAfterDispatch
/**
* Perform initialization of JFBConnect variables into the document. Currently adds:
* ** The (dynamic) login/logout redirects, used by jfbconnect.js
* ** The {scopengraphplaceholder} tag to be replaced/removed by the system plugin
* @return none
*/
function onAfterDispatch()
{
$doc = JFactory::getDocument();
if ($doc->getType() != 'html') {
return;
}
// Only insert javascript on HTML pages, not AJAX, RSS, etc
$app = JFactory::getApplication();
$state = $app->getUserState('users.login.form.data', null);
$return = null;
if (JRequest::getCmd('option') == 'com_users' && JRequest::getCmd('view') == 'login' && is_array($state) && isset($state['return'])) {
$return = urldecode($state['return']);
}
if (!$return) {
$return = urldecode(base64_decode($app->input->getBase64('return', '')));
}
if (!$return) {
$uri = JURI::getInstance();
$return = $uri->toString(array('path', 'query'));
if ($return == "") {
$return = 'index.php';
}
}
$requiredPerms = $this->profile->getRequiredScope();
$fbUserId = $this->getMappedUserId();
$logoutJoomlaOnly = $this->configModel->get('logout_joomla_only');
if ($fbUserId && !$logoutJoomlaOnly) {
$logoutFacebookJavascript = "jfbc.login.logout_facebook = true;";
} else {
$logoutFacebookJavascript = "jfbc.login.logout_facebook = false;";
}
$user = JFactory::getUser();
$showLoginModal = $this->configModel->get('facebook_login_show_modal');
if ($user->guest) {
setcookie('jfbconnect_permissions_granted', '', time() - 10000, "/");
}
// clear the granted permissions cookie
$debugCmd = $this->configModel->get('facebook_display_errors') ? "jfbc.debug.enable = '1';\n" : '';
$doc->addScript(JURI::base(true) . '/components/com_jfbconnect/includes/jfbconnect.js?v=6');
$doc->addCustomTag('<script type="text/javascript">' . $logoutFacebookJavascript . "\n" . "jfbc.base = '" . JURI::base() . "';\n" . "jfbc.return_url = '" . base64_encode($return) . "';\n" . "jfbc.login.scope = '" . $requiredPerms . "';\n" . "jfbc.login.show_modal = '" . $showLoginModal . "';\n" . "jfbc.login.use_popup = " . ($this->configModel->get('login_use_popup') ? 'true' : 'false') . ";\n" . "jfbc.login.auto = '" . $this->configModel->get('facebook_auto_login') . "';\n" . "jfbc.login.logged_in = " . (!$user->guest && JFBCFactory::usermap()->getProviderUserId($user->id, 'facebook') ? 'true' : 'false') . ";\n" . "jfbc.token = '" . JSession::getFormToken() . "';\n" . $debugCmd . "jfbc.init();\n" . "</script>");
$doc->addCustomTag('<SCOpenGraphPlaceholder />');
}
示例15: checkNewMapping
public function checkNewMapping()
{
$newMappingEnabled = JFactory::getApplication()->getUserState('com_jfbconnect.' . $this->systemName . '.checkForNewMapping', false);
if ($newMappingEnabled) {
$providerId = $this->getProviderUserId();
if ($providerId != null) {
JFBCFactory::usermap()->map(JFactory::getUser()->get('id'), $providerId, $this->systemName);
}
}
JFactory::getApplication()->setUserState('com_jfbconnect.' . $this->systemName . '.checkForNewMapping', null);
}