/**
  * Creates and inits a new TineSession.
  *
  * @return a new TineSession
  *
  */
 private static function createNewTineSession()
 {
     $tineSession = new TineSession(self::$backendUrl);
     if (defined('ACTIVATE_TINE_XDEBUG') && ACTIVATE_TINE_XDEBUG === true) {
         //'=== true' only for the sake of clarity
         $tineSession->setActivateTineXDebug(true);
     }
     $tineSession->setLocale('pt_BR');
     return $tineSession;
 }
 /**
  * Uploads raw data to Tine as a temp file that may be used as a message attachment.
  *
  * @param  TineSession $tineSession     The TineSession used to communicate with Tine.
  * @param  string      $rawData         The file raw content
  * @param  string      $fileDisplayName The file name
  * @param  string      $mimeType        The file's mimetype
  *
  * @return string The temp file information.
  */
 public static function uploadTempFile(TineSession $tineSession, $rawData, $fileDisplayName, $mimeType)
 {
     $req = new Request();
     $req->setUrl($tineSession->getTineUrl() . '?method=Tinebase.uploadTempFile&eid=' . sha1(mt_rand() . microtime()));
     $req->setCookieHandler($tineSession);
     //tineSession has the necessary cookies
     $req->setPostFields($rawData);
     $req->setHeaders(array('DNT: 1', 'User-Agent: ' . TineJsonRpc::DEFAULT_USERAGENT, 'X-File-Name: ' . $fileDisplayName, 'X-File-Size: 0', 'X-File-Type: ' . $mimeType, 'X-Requested-With: XMLHttpRequest', 'X-Tine20-Request-Type: HTTP'));
     return $req->send(REQUEST::POST);
 }