Esempio n. 1
0
 /**
  * @return array
  */
 private function getThemeAndLanguage()
 {
     static $sLanguage = false;
     static $sTheme = false;
     static $sSiteName = false;
     if (false === $sLanguage && false === $sTheme && false === $sSiteName) {
         $oSettings =& CApi::GetSettings();
         $sSiteName = $oSettings->GetConf('Common/SiteName');
         $sLanguage = $oSettings->GetConf('Common/DefaultLanguage');
         $sTheme = $oSettings->GetConf('WebMail/DefaultSkin');
         $oAccount = $this->getLogginedDefaultAccount();
         if ($oAccount) {
             $sSiteName = $oAccount->Domain->SiteName;
             $sTheme = $oAccount->User->DefaultSkin;
             $sLanguage = $oAccount->User->DefaultLanguage;
         } else {
             /* @var $oApiDomainsManager CApiDomainsManager */
             $oApiDomainsManager = CApi::Manager('domains');
             $oInput = new api_Http();
             $oDomain = $oApiDomainsManager->getDomainByUrl($oInput->GetHost());
             if ($oDomain) {
                 $sTheme = $oDomain->DefaultSkin;
                 $sLanguage = $this->getLoginLanguage();
                 if (empty($sLanguage)) {
                     $sLanguage = $this->getBrowserLanguage();
                 }
                 if (empty($sLanguage)) {
                     $sLanguage = $oDomain->DefaultLanguage;
                 }
                 $sSiteName = $oDomain->SiteName;
             }
         }
         $sLanguage = $this->validatedLanguageValue($sLanguage);
         $this->setLoginLanguage($sLanguage);
         // todo: sash
         $sTheme = $this->validatedThemeValue($sTheme);
     }
     /*** temporary fix to the problems in mobile version in rtl mode ***/
     /* @var $oApiIntegrator \CApiIntegratorManager */
     $oApiIntegrator = \CApi::Manager('integrator');
     /* @var $oApiCapability \CApiCapabilityManager */
     $oApiCapability = \CApi::Manager('capability');
     if (in_array($sLanguage, array('Arabic', 'Hebrew', 'Persian')) && $oApiIntegrator && $oApiCapability && $oApiCapability->isNotLite() && 1 === $oApiIntegrator->isMobile()) {
         $sLanguage = 'English';
     }
     /*** end of temporary fix to the problems in mobile version in rtl mode ***/
     return array($sLanguage, $sTheme, $sSiteName);
 }
Esempio n. 2
0
 public function PluginApiAppData(&$aAppData)
 {
     if (!empty(self::$sInviteEmail)) {
         $aAppData['ExternalInviteEmail'] = self::$sInviteEmail;
     }
     $oApiDomainsManager = \CApi::Manager('domains');
     $oInput = new api_Http();
     $oDomain = $oApiDomainsManager->GetDomainByUrl($oInput->GetHost());
     if ($oDomain && !$oDomain->IsDefaultDomain) {
         $this->sTenantHash = substr(md5($oDomain->IdTenant . CApi::$sSalt), 0, 8);
     }
     \CExternalServicesConnectors::Init($aAppData, $this->sTenantHash);
     $oTenant = CExternalServicesConnectors::GetTenantFromCookieOrHash($this->sTenantHash);
     if ($oTenant) {
         $aSocials = $oTenant->getSocials();
         $self = $this;
         // for PHP < 5.4
         array_walk($aSocials, function ($oSocial, $sKey) use($self) {
             if ($oSocial->SocialAllow && in_array($sKey, $self->aEnableConnectors)) {
                 $self->aConnectors[] = $oSocial->toArray();
             }
         });
     }
     if (!isset($aAppData['Plugins'])) {
         $aAppData['Plugins'] = array();
     }
     $aExternalServices = array();
     if (is_array($this->aConnectors)) {
         $aExternalServices['Connectors'] = $this->aConnectors;
     }
     $aAppData['Plugins']['ExternalServices'] = $aExternalServices;
     $oAccount = \api_Utils::GetDefaultAccount();
     if ($oAccount) {
         $oApiSocial = \CApi::Manager('social');
         $aSocials = $oApiSocial->getSocials($oAccount->IdAccount);
         $aUserServices = array();
         foreach ($aSocials as $oSocial) {
             if ($oSocial && $oSocial instanceof \CSocial) {
                 $aSocial = $oSocial->toArray();
                 $aSocial['ServiceName'] = '';
                 $aSocial['UserScopes'] = array();
                 if (in_array(strtolower($oSocial->TypeStr), $this->aEnableConnectors)) {
                     $aUserServices[strtolower($oSocial->TypeStr)] = $aSocial;
                 }
             }
         }
         $aResultUserServices = array();
         foreach ($this->aConnectors as $aConnector) {
             $sServiceType = strtolower($aConnector['Name']);
             if (!$aUserServices[$sServiceType]) {
                 $oSocial = new \CSocial();
                 $oSocial->TypeStr = $sServiceType;
                 $aSocial = $oSocial->toArray();
                 $aUserServices[$sServiceType] = $aSocial;
             }
             $aUserServices[$sServiceType]['ServiceName'] = $aConnector['Name'];
             $aUserServices[$sServiceType]['UserScopes'] = array();
             foreach ($aConnector['Scopes'] as $sScope) {
                 if (trim($sScope) !== '') {
                     $aUserServices[$sServiceType]['UserScopes'][$sScope] = in_array($sScope, $aUserServices[$sServiceType]['Scopes']);
                 }
             }
             $aResultUserServices[$sServiceType] = $aUserServices[$sServiceType];
         }
         $aAppData['Plugins']['ExternalServices']['Users'] = array_values($aResultUserServices);
     }
     $aAppData['AllowChangePassword'] = CApi::GetConf('plugins.external-services.allow-change-password', true);
 }
Esempio n. 3
0
 /**
  * @return array
  */
 private function getThemeAndLanguage()
 {
     static $sLanguage = false;
     static $sTheme = false;
     static $sSiteName = false;
     if (false === $sLanguage && false === $sTheme && false === $sSiteName) {
         $oSettings =& CApi::GetSettings();
         $sSiteName = $oSettings->GetConf('Common/SiteName');
         $sLanguage = $oSettings->GetConf('Common/DefaultLanguage');
         $sTheme = $oSettings->GetConf('WebMail/DefaultSkin');
         $oAccount = $this->GetLogginedDefaultAccount();
         if ($oAccount) {
             $sSiteName = $oAccount->Domain->SiteName;
             $sTheme = $oAccount->User->DefaultSkin;
             $sLanguage = $oAccount->User->DefaultLanguage;
         } else {
             /* @var $oApiDomainsManager CApiDomainsManager */
             $oApiDomainsManager = CApi::Manager('domains');
             $oInput = new api_Http();
             $oDomain = $oApiDomainsManager->GetDomainByUrl($oInput->GetHost());
             if ($oDomain) {
                 $sTheme = $oDomain->DefaultSkin;
                 $sLanguage = $this->GetLoginLanguage();
                 if (empty($sLanguage)) {
                     $sLanguage = $this->getBrowserLanguage();
                 }
                 if (empty($sLanguage)) {
                     $sLanguage = $oDomain->DefaultLanguage;
                 }
                 $sSiteName = $oDomain->SiteName;
             }
         }
         $sLanguage = $this->validatedLanguageValue($sLanguage);
         $sTheme = $this->validatedThemeValue($sTheme);
     }
     return array($sLanguage, $sTheme, $sSiteName);
 }