当前位置: 首页>>代码示例>>PHP>>正文


PHP Social::connectAccount方法代码示例

本文整理汇总了PHP中Social::connectAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::connectAccount方法的具体用法?PHP Social::connectAccount怎么用?PHP Social::connectAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Social的用法示例。


在下文中一共展示了Social::connectAccount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: socialConnectLogin

function socialConnectLogin($uid = false, $network_code = false)
{
    require_once _base_ . '/lib/lib.usermanager.php';
    $res = '';
    $lang = DoceboLanguage::createInstance('login');
    $user_manager = new UserManager();
    if (!empty($uid) && !empty($network_code)) {
        session_regenerate_id();
        $_SESSION['connect_social']['uid'] = $uid;
        $_SESSION['connect_social']['network_code'] = $network_code;
    }
    $can_connect = false;
    if (isset($_SESSION['connect_social']) && isset($_SESSION['connect_social']['uid']) && !empty($_SESSION['connect_social']['uid'])) {
        // read data from session, in case we are on the second step (login attempt)
        $uid = $_SESSION['connect_social']['uid'];
        $network_code = $_SESSION['connect_social']['network_code'];
        $can_connect = true;
    }
    // check form submission:
    if (isset($_POST['undo'])) {
        // go back to index
        Util::jump_to('index.php');
    } else {
        if (isset($_POST['login']) && !$can_connect) {
            // we don't have the social uid to be connected with user account..
            Util::jump_to('index.php?modname=login&op=social_connect_login&err=2');
        } else {
            if (isset($_POST['login'])) {
                // login and connect account
                $user = DoceboUser::createDoceboUserFromLogin(Get::pReq('login_userid', DOTY_STRING), Get::pReq('login_pwd', DOTY_STRING), 'public_area');
                if ($user) {
                    DoceboUser::setupUser($user);
                    $social = new Social();
                    $social->connectAccount($network_code, $uid);
                    unset($_SESSION['connect_social']);
                    Util::jump_to('index.php?r=lms/elearning/show');
                } else {
                    Util::jump_to('index.php?modname=login&op=social_connect_login&err=1');
                }
            }
        }
    }
    switch (Get::gReq('err', DOTY_INT, 0)) {
        case 1:
            $res .= UIFeedback::error(Lang::t('_NOACCESS', 'login'), true);
            break;
        case 2:
            $res .= UIFeedback::error(Lang::t('_NO_SOCIAL_ACCOUNT_TO_CONNECT', 'login') . '&nbsp;<a href="index.php">' . Lang::t('_TRY_AGAIN', 'login') . '</a>', true);
            break;
    }
    $GLOBALS['page']->add(getTitleArea($lang->def('_LOGIN'), 'login') . '<div class="std_block">' . getBackUi('index.php', $lang->def('_BACK')), 'content');
    if ($can_connect) {
        $res .= Get::img('social/' . $network_code . '-24.png') . '&nbsp;';
        $res .= str_replace('[network_code]', Lang::t($network_code, 'social'), Lang::t('_YOU_ARE_CONNECTING_SOCIAL_ACCOUNT', 'social')) . " <b>" . $uid . "</b>";
    }
    $res .= Form::openForm('scl_form', 'index.php?modname=login&amp;op=social_connect_login') . Form::openElementSpace() . Form::getTextfield(Lang::t('_USERNAME', 'login'), 'login_userid', 'login_userid', 255) . Form::getPassword(Lang::t('_PASSWORD', 'login'), 'login_pwd', 'login_pwd', 255) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('login', 'login', Lang::t('_LOGIN', 'login')) . Form::getButton('undo', 'undo', Lang::t('_UNDO', 'login')) . Form::closeButtonSpace() . Form::closeForm();
    $GLOBALS['page']->add($res, 'content');
    // std_block
    $GLOBALS['page']->add('</div>', 'content');
    // std_block
}
开发者ID:abhinay100,项目名称:forma_app,代码行数:61,代码来源:login.php

示例2: socialConnectLogin

            $user_data = $social->getGoogleUserInfo();
            if (!empty($user_data['email'])) {
                if (Docebo::user()->isAnonymous()) {
                    // sign in the user
                    $user = DoceboUser::createDoceboUserFromField('google_id', $user_data['email'], 'public_area');
                    if ($user) {
                        DoceboUser::setupUser($user);
                        Util::jump_to('index.php?r=lms/elearning/show');
                    } else {
                        //Util::jump_to('index.php?access_fail=2');
                        socialConnectLogin($user_data['email'], 'google');
                        return;
                    }
                } else {
                    // user is already logged in, so connect the account with user
                    $social->connectAccount('google', $user_data['email']);
                    Util::jump_to('index.php?r=lms/elearning/show');
                    die;
                }
                print_r($user_data);
            } else {
                Util::jump_to('index.php?access_fail=2');
            }
        } else {
            Util::jump_to('index.php?access_fail=3');
        }
        die;
    }
} catch (ErrorException $e) {
    echo $e->getMessage();
}
开发者ID:abhinay100,项目名称:forma_app,代码行数:31,代码来源:login.google.openid.php

示例3: socialConnectLogin

             Util::jump_to(Get::rel_path('base') . '/index.php?modname=login&op=register');
             die;
         }
         if (Docebo::user()->isAnonymous()) {
             // sign in the user
             $user = DoceboUser::createDoceboUserFromField('facebook_id', $objUserInfo["id"], 'public_area');
             if ($user) {
                 DoceboUser::setupUser($user);
                 Util::jump_to('index.php?r=lms/elearning/show');
             } else {
                 socialConnectLogin($objUserInfo["id"], 'facebook');
                 return;
             }
         } else {
             // user is already logged in, so connect the account with user
             $res = $social->connectAccount('facebook', $objUserInfo["id"]);
             if ($res == true) {
                 Util::jump_to(_folder_lms_ . '/index.php?' . 'feedback_code=_SOCIALCONNECTOK&feedback_type=inf&feedback_extra=' . $objUserInfo["id"]);
             } else {
                 Util::jump_to(_folder_lms_ . '/index.php?' . 'feedback_code=_SOCIALCONNECTKO&feedback_type=err&feedback_extra=' . $objUserInfo["id"]);
             }
         }
     } else {
         // no mail in fields
         Util::jump_to('index.php?access_fail=4');
     }
     break;
     // 3. $_REQUEST['error'] -> RETURN CANCEL FROM FACEBOOK AUTH
 // 3. $_REQUEST['error'] -> RETURN CANCEL FROM FACEBOOK AUTH
 case isset($_REQUEST['error_code']) && $_REQUEST['error_code'] == '4201':
     // error_message contiene la risposta User canceled the Dialog flow
开发者ID:abhinay100,项目名称:forma_app,代码行数:31,代码来源:login.facebook.oauth2.php

示例4: Social

 function _opt_in($options, $platform, $opt_link)
 {
     $social = new Social();
     $lang =& DoceboLanguage::createInstance('register', $platform);
     // Check for error
     $out = '';
     $error = $this->_checkField($_POST, $options, $platform, true);
     if ($error['error']) {
         $this->error = true;
         return '<div class="reg_err_data">' . $error['msg'] . '</div>';
     }
     // Insert temporary
     $random_code = md5($_POST['register']['userid'] . mt_rand() . mt_rand() . mt_rand());
     // register as temporary user and send mail
     $acl_man =& Docebo::user()->getAclManager();
     $iduser = $acl_man->registerTempUser($_POST['register']['userid'], $_POST['register']['firstname'], $_POST['register']['lastname'], $_POST['register']['pwd'], $_POST['register']['email'], $random_code);
     if ($iduser === false) {
         $out .= '<div class="reg_err_data">' . $lang->def('_OPERATION_FAILURE') . '</div>';
         $this->error = true;
         return $out;
     }
     // facebook register:
     if ($social->isActive('facebook')) {
         if (isset($_SESSION['fb_info']) && is_array($_SESSION['fb_info'])) {
             $social = new Social();
             $social->connectAccount('facebook', $_SESSION['fb_info']['id'], $iduser, true);
             unset($_SESSION['fb_info']);
         }
     }
     // ----
     // add base inscription policy
     $enrollrules = new EnrollrulesAlms();
     $enrollrules->newRules('_NEW_USER', array($iduser), Lang::get());
     // subscribe to groups -----------------------------------------
     if (isset($_POST['group_sel_implode'])) {
         $groups = explode(',', $_POST['group_sel_implode']);
         while (list(, $idst) = each($groups)) {
             $acl_man->addToGroup($idst, $iduser);
             // FORMA: added the inscription policy
             $enrollrules = new EnrollrulesAlms();
             $enrollrules->applyRulesMultiLang('_LOG_USERS_TO_GROUP', array((string) $iduser), false, (int) $idst, true);
             // END FORMA
         }
     }
     //if the user had enter a code we must check if there are folder related to it and add the folder's field
     $registration_code_type = Get::sett('registration_code_type', '0');
     $code_is_mandatory = Get::sett('mandatory_code', 'off') == 'on';
     $reg_code = Get::req('reg_code', DOTY_MIXED, '');
     if ($registration_code_type === 'custom') {
         $reg_code = 'change_by_custom_operation';
     }
     $array_folder = false;
     $uma = new UsermanagementAdm();
     $reg_code_res = $this->processRegistrationCode($acl_man, $uma, $iduser, $reg_code, $registration_code_type);
     if ($reg_code_res['success'] == false) {
         $acl_man->deleteTempUser($iduser);
         $this->error = true;
         return '<div class="reg_err_data">' . $reg_code_res['msg'] . '</div>';
     }
     // save language selected
     require_once _base_ . '/lib/lib.preference.php';
     $preference = new UserPreferences($iduser);
     $preference->setPreference('ui.language', Lang::get());
     // Save fields
     $extra_field = new FieldList();
     $extra_field->setFieldEntryTable($GLOBALS['prefix_fw'] . '_field_userentry');
     $extra_field->storeFieldsForUser($iduser);
     // Send mail
     $admin_mail = $options['mail_sender'];
     // FIX BUG 399
     //$link = str_replace('&amp;', '&', $opt_link.( strpos($opt_link, '?') === false ? '?' : '&' ).'random_code='.$random_code);
     $link = Get::sett('url', '') . 'index.php?modname=login&op=register_opt&random_code=' . $random_code;
     // END FIX BUG 399
     $text = $lang->def('_REG_MAIL_TEXT');
     $text = str_replace('[userid]', $_POST['register']['userid'], $text);
     $text = str_replace('[firstname]', $_POST['register']['firstname'], $text);
     $text = str_replace('[lastname]', $_POST['register']['lastname'], $text);
     $text = str_replace('[password]', $_POST['register']['pwd'], $text);
     $text = str_replace('[link]', '' . $link . '', $text);
     $text = str_replace('[hour]', $options['hour_request_limit'], $text);
     $text = stripslashes($text);
     //check register_type != self (include all previous cases except the new one "self without opt-in")
     if (strcmp($options['register_type'], 'self') != 0) {
         require_once _base_ . '/lib/lib.mailer.php';
         $mailer = DoceboMailer::getInstance();
         if (!$mailer->SendMail($admin_mail, $_POST['register']['email'], Lang::t('_MAIL_OBJECT', 'register'), $text, false, array(MAIL_REPLYTO => $admin_mail, MAIL_SENDER_ACLNAME => false))) {
             if ($registration_code_type == 'code_module') {
                 // ok, the registration has failed, let's remove the user association form the code
                 $code_manager = new CodeManager();
                 $code_manager->resetUserAssociation($code, $iduser);
             }
             $acl_man->deleteTempUser($iduser);
             $this->error = true;
             $out .= '<div class="reg_err_data">' . $lang->def('_OPERATION_FAILURE') . '</div>';
         } else {
             $out .= '<div class="reg_success">' . $lang->def('_REG_SUCCESS') . '</div>';
         }
     }
     //end
     $_GET['random_code'] = $random_code;
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:forma_app,代码行数:101,代码来源:lib.usermanager.php

示例5: socialConnectLogin

     $token = $googleService->requestAccessToken($_GET['code']);
     $objUserInfo = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
     if (!empty($objUserInfo["email"])) {
         if (Docebo::user()->isAnonymous()) {
             // sign in the user
             $user = DoceboUser::createDoceboUserFromField('google_id', $objUserInfo["email"], 'public_area');
             if ($user) {
                 DoceboUser::setupUser($user);
                 Util::jump_to('index.php?r=lms/elearning/show');
             } else {
                 socialConnectLogin($objUserInfo["email"], 'google');
                 return;
             }
         } else {
             // user is already logged in, so connect the account with user
             $res = $social->connectAccount('google', $objUserInfo["email"]);
             if ($res == true) {
                 Util::jump_to(_folder_lms_ . '/index.php?' . 'feedback_code=_SOCIALCONNECTOK&feedback_type=inf&feedback_extra=' . $objUserInfo["email"]);
             } else {
                 Util::jump_to(_folder_lms_ . '/index.php?' . 'feedback_code=_SOCIALCONNECTKO&feedback_type=err&feedback_extra=' . $objUserInfo["email"]);
             }
         }
     } else {
         // no mail in fields
         Util::jump_to('index.php?access_fail=4');
     }
     break;
     // 3. $_REQUEST['error'] -> RETURN CANCEL FROM GOOGLE AUTH
 // 3. $_REQUEST['error'] -> RETURN CANCEL FROM GOOGLE AUTH
 case isset($_REQUEST['error']) && $_REQUEST['error'] == 'access_denied':
     Util::jump_to('index.php?access_fail=6');
开发者ID:abhinay100,项目名称:forma_app,代码行数:31,代码来源:login.google.oauth2.php


注:本文中的Social::connectAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。