Merge branch '2016.11' into 2016.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 14 Feb 2017 17:57:16 +0000 (18:57 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 14 Feb 2017 17:57:16 +0000 (18:57 +0100)
Change-Id: I627221fb0298a34fc3b65256ecf8b7b2dfb652b6

1  2 
tests/tine20/Felamimail/Frontend/JsonTest.php
tine20/Addressbook/Controller/Contact.php
tine20/Tinebase/Core.php
tine20/Tinebase/Helper.php
tine20/composer.lock

Simple merge
@@@ -367,54 -367,4 +367,54 @@@ class Tinebase_Helpe
      {
          return preg_replace('/[^\x09\x0A\x0D\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', '', $string);
      }
-                 $client = new Zend_Http_Client($filenameOrUrl);
 +
 +    /**
 +     * fetches contents from file or uri
 +     *
 +     * @param string $source
 +     * @return string|null
 +     */
 +    public static function getFileOrUriContents($filenameOrUrl)
 +    {
 +        if (strpos($filenameOrUrl, 'http') === 0) {
 +            try {
++                $client = Tinebase_Core::getHttpClient($filenameOrUrl);
 +                // 0011054: Problems with ScheduledImport of external ics calendars
 +                // google shows a lot of trouble with gzip in Zend_Http_Response, so let's deny it
 +                $client->setHeaders('Accept-encoding', 'identity');
 +
 +                if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
 +                    . ' Fetching content from ' . $filenameOrUrl);
 +
 +                $requestBody = $client->request()->getBody();
 +            } catch (Exception $e) {
 +                Tinebase_Exception::log($e);
 +                $requestBody = null;
 +            }
 +            return $requestBody;
 +        } else if (file_exists($filenameOrUrl)) {
 +            return file_get_contents($filenameOrUrl);
 +        } else {
 +            if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . ' ' . __LINE__
 +                    . ' File not found');
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     * @param $content
 +     * @return null|string filename
 +     */
 +    public static function writeToTempFile($content)
 +    {
 +        $tempPath = Tinebase_TempFile::getTempPath();
 +        $file = fopen($tempPath);
 +        if ($file) {
 +            fwrite($file, $content);
 +            return $tempPath;
 +        }
 +
 +        return null;
 +    }
  }
Simple merge