當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CApi::Location2方法代碼示例

本文整理匯總了PHP中CApi::Location2方法的典型用法代碼示例。如果您正苦於以下問題:PHP CApi::Location2方法的具體用法?PHP CApi::Location2怎麽用?PHP CApi::Location2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CApi的用法示例。


在下文中一共展示了CApi::Location2方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Process

 public static function Process($mResult)
 {
     $sExternalServicesRedirect = '';
     $sError = '';
     $sErrorMessage = '';
     if (isset($_COOKIE["external-services-redirect"])) {
         $sExternalServicesRedirect = $_COOKIE["external-services-redirect"];
         @setcookie('external-services-redirect', null);
     }
     if ($sExternalServicesRedirect === 'helpdesk') {
         self::SetValuesToCookie($mResult);
         $sTenantHash = self::GetTenantHashFromCookie();
         \CApi::Location($sTenantHash ? './?helpdesk=' . $sTenantHash : './?helpdesk');
     } else {
         $oApiUsers = \CApi::Manager('users');
         $oInviteAccount = null;
         if (isset($_COOKIE["external-services-invite-hash"])) {
             $oInviteAccount = $oApiUsers->getAccountById($_COOKIE["external-services-invite-hash"], true);
             @setcookie('external-services-invite-hash', null);
         }
         $sEmail = trim($mResult['email']);
         if (empty($sEmail) && $oInviteAccount) {
             $mResult['email'] = $oInviteAccount->Email;
         }
         $oApiSocial = \CApi::Manager('social');
         $oSocial = new \CSocial();
         $oSocial->TypeStr = $mResult['type'];
         $oSocial->AccessToken = isset($mResult['access_token']) ? $mResult['access_token'] : '';
         $oSocial->RefreshToken = isset($mResult['refresh_token']) ? $mResult['refresh_token'] : '';
         $oSocial->IdSocial = $mResult['id'];
         $oSocial->Name = $mResult['name'];
         $oSocial->Email = $mResult['email'];
         if ($sExternalServicesRedirect === 'login') {
             self::SetValuesToCookie($mResult);
             $oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
             if ($oSocialOld) {
                 if ($oInviteAccount && $oInviteAccount->IdAccount === $oSocialOld->IdAccount || !$oInviteAccount) {
                     if (!$oSocialOld->Disabled && $oSocialOld->issetScope('auth')) {
                         $oSocialOld->setScope('auth');
                         $oSocial->Scopes = $oSocialOld->Scopes;
                         $oApiSocial->updateSocial($oSocial);
                         $oInviteAccount = $oApiUsers->getAccountById($oSocialOld->IdAccount);
                     } else {
                         $bResult = false;
                         $sError = '?error=es-002';
                         if (!empty($mResult['email'])) {
                             $sError = $sError . '&email=' . $mResult['email'];
                         } else {
                             $sError = $sError . '&service=' . $mResult['type'];
                         }
                     }
                 } else {
                     $oInviteAccount = null;
                     $bResult = false;
                     $sError = '?error=es-003';
                 }
             } else {
                 $oInviteAccount = $oApiUsers->getAccountByEmail($mResult['email']);
                 if ($oInviteAccount) {
                     $oSocial->IdAccount = $oInviteAccount->IdAccount;
                     $oSocial->setScopes($mResult['scopes']);
                     $oApiSocial->createSocial($oSocial);
                 } else {
                     $sError = '?error=es-002';
                     if (!empty($mResult['email'])) {
                         $sError = $sError . '&email=' . $mResult['email'];
                     } else {
                         $sError = $sError . '&service=' . $mResult['type'];
                     }
                 }
             }
             if ($oInviteAccount) {
                 $oApiIntegrator = \CApi::Manager('integrator');
                 $oApiIntegrator->setAccountAsLoggedIn($oInviteAccount, true);
                 $oApiUsers->updateAccountLastLoginAndCount($oInviteAccount->IdUser);
             }
             \CApi::Location2('./' . $sError);
         } else {
             $oInviteAccount = \api_Utils::GetDefaultAccount();
             if ($oInviteAccount) {
                 $bResult = false;
                 $oSocial->IdAccount = $oInviteAccount->IdAccount;
                 $oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
                 if ($oSocialOld) {
                     if ($oSocialOld->IdAccount === $oSocial->IdAccount) {
                         if (in_array('null', $mResult['scopes']) || count($mResult['scopes']) === 0) {
                             $bResult = $oSocial->deleteSocial($oInviteAccount->IdAccount, $oSocial->TypeStr);
                         } else {
                             $oSocial->setScopes($mResult['scopes']);
                             $bResult = $oApiSocial->updateSocial($oSocial);
                         }
                     } else {
                         $bResult = false;
                         $oPlugin = \CApi::Plugin()->GetPluginByName('external-services');
                         if ($oPlugin) {
                             $sErrorMessage = $oPlugin->I18N('PLUGIN_EXTERNAL_SERVICES/INFO_ACCOUNT_ALREADY_ASSIGNED', $oInviteAccount);
                         }
                     }
                 } else {
                     if (!in_array('null', $mResult['scopes']) && count($mResult['scopes']) > 0) {
//.........這裏部分代碼省略.........
開發者ID:pkdevboxy,項目名稱:webmail-lite,代碼行數:101,代碼來源:index.php


注:本文中的CApi::Location2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。