Beispiel #1
0
 /**
  * @param string $sLogin
  *
  * @return CAccount
  */
 private function &getAccount($sLogin)
 {
     $mResult = null;
     if (!isset($this->aAccounts[$sLogin])) {
         $this->aAccounts[$sLogin] = $this->oApiUsersManager->getAccountByEmail($sLogin);
     }
     $mResult =& $this->aAccounts[$sLogin];
     if (30 < count($this->aAccounts[$sLogin])) {
         $this->aAccounts = array_slice($this->aAccounts, -30);
     }
     return $mResult;
 }
 /**
  * @param int $iIdUser
  * @param null $iGroupId = null
  * @param bool $bWatchShare = false
  * @param bool $bWatchShareAndUser = true
  * @param string $sTablePrefix = ''
  * @param bool $bAll = false
  *
  * @return string
  */
 protected function sharedItemsSqlHelper($iIdUser, $iGroupId = null, $bWatchShare = false, $bWatchShareAndUser = false, $sTablePrefix = '', $bAll = false)
 {
     if ($bAll) {
         $bWatchShare = true;
         $bWatchShareAndUser = true;
     }
     $aTypes[] = sprintf('%stype = %d', $sTablePrefix, EContactType::Personal);
     if ($iGroupId && 0 < $iGroupId) {
         $aTypes[] = sprintf('%stype = %d', $sTablePrefix, EContactType::Global_);
     }
     if ($bWatchShare && null !== $iIdUser) {
         $oAccount = null;
         if (isset($this->aAccountsCache[$iIdUser])) {
             $oAccount = $this->aAccountsCache[$iIdUser];
         }
         if (!$oAccount) {
             if (null === $this->oUsersManager) {
                 $this->oUsersManager = CApi::Manager('users');
             }
             $oAccount = $this->oUsersManager ? $this->oUsersManager->getDefaultAccount($iIdUser) : null;
             if ($oAccount) {
                 $this->aAccountsCache[$iIdUser] = $oAccount;
             }
         }
         if ($oAccount) {
             $sEnd = '1 = 0';
             if (EContactsGABVisibility::Off !== $oAccount->GlobalAddressBook) {
                 if (0 <= $oAccount->IdDomain && $oAccount->Domain) {
                     if (EContactsGABVisibility::DomainWide === $oAccount->GlobalAddressBook) {
                         $sEnd = sprintf('%sid_domain = %d', $sTablePrefix, $oAccount->IdDomain);
                     } else {
                         if (EContactsGABVisibility::TenantWide === $oAccount->GlobalAddressBook) {
                             $sEnd = sprintf('%sid_tenant = %d', $sTablePrefix, $oAccount->Domain->IdTenant);
                         } else {
                             if (EContactsGABVisibility::SystemWide === $oAccount->GlobalAddressBook) {
                                 $sEnd = '1 = 1';
                             }
                         }
                     }
                 }
             }
             if ($bAll) {
                 $aTypes[] = sprintf('%stype = %d', $sTablePrefix, EContactType::GlobalAccounts);
                 $aTypes[] = sprintf('%stype = %d', $sTablePrefix, EContactType::GlobalMailingList);
             }
             return '(' . '(' . implode(' OR ', $aTypes) . ') AND (' . sprintf('(%sshared_to_all = 1 AND %s)', $sTablePrefix, $sEnd) . ($bAll ? sprintf(' OR ((%stype = %d OR %stype = %d) AND %s)', $sTablePrefix, EContactType::GlobalAccounts, $sTablePrefix, EContactType::GlobalMailingList, $sEnd) : '') . ($bWatchShareAndUser ? sprintf(' OR (%sid_user = %d AND %sshared_to_all = 0)', $sTablePrefix, $iIdUser, $sTablePrefix) : '') . '))';
         }
     }
     return null !== $iIdUser ? sprintf('(%sid_user = %d AND %sshared_to_all = 0 AND (%s))', $sTablePrefix, $iIdUser, $sTablePrefix, implode(' OR ', $aTypes)) : '';
 }
Beispiel #3
0
	public function MinDownload()
	{
		$mData = $this->getParamValue('Result', false);

		if (isset($mData['AccountType']) && 'wm' !== $mData['AccountType'])
		{
			return true;
		}

		$oAccount = $this->oApiUsers->GetAccountById((int) $mData['Account']);

		$mResult = false;
		if ($oAccount && $this->oApiCapability->IsFilesSupported($oAccount))
		{
			$mResult = $this->oApiFilestorage->GetSharedFile($oAccount, $mData['Type'], $mData['Path'], $mData['Name']);
		}
		
		if (false !== $mResult)
		{
			if (is_resource($mResult))
			{
				$sFileName = $mData['Name'];
				$sContentType = (empty($sFileName)) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
				$sFileName = $this->clearFileName($sFileName, $sContentType);
				$this->RawOutputHeaders(true, $sContentType, $sFileName);

				\MailSo\Base\Utils::FpassthruWithTimeLimitReset($mResult);
				@fclose($mResult);
			}
		}
		
		return true;
	}