Example #1
0
 private function _tnefAttachment($params, Account $account)
 {
     $tmpFolder = \GO\Base\Fs\Folder::tempFolder(uniqid(time()));
     $tmpFile = $tmpFolder->createChild('winmail.dat');
     $imap = $account->openImapConnection($params['mailbox']);
     $success = $imap->save_to_file($params['uid'], $tmpFile->path(), $params['number'], $params['encoding']);
     if (!$success) {
         throw new \Exception("Could not save temp file for tnef extraction");
     }
     chdir($tmpFolder->path());
     exec(GO::config()->cmd_tnef . ' ' . $tmpFile->path(), $output, $retVar);
     if ($retVar != 0) {
         throw new \Exception("TNEF extraction failed: " . implode("\n", $output));
     }
     $tmpFile->delete();
     $items = $tmpFolder->ls();
     if (!count($items)) {
         $this->render("Plain", GO::t('winmailNoFiles', 'email'));
         exit;
     }
     exec(GO::config()->cmd_zip . ' -r "winmail.zip" *', $output, $retVar);
     if ($retVar != 0) {
         throw new \Exception("ZIP compression failed: " . implode("\n", $output));
     }
     $zipFile = $tmpFolder->child('winmail.zip');
     \GO\Base\Util\Http::outputDownloadHeaders($zipFile, false, true);
     $zipFile->output();
     $tmpFolder->delete();
 }
Example #2
0
 private function _getUsage(\GO\Email\Model\Account $account)
 {
     $usage = "";
     $quota = $account->openImapConnection()->get_quota();
     if (isset($quota['usage'])) {
         if (!empty($quota['limit'])) {
             $percentage = ceil($quota['usage'] * 100 / $quota['limit']);
             $usage = sprintf(\GO::t('usage_limit', 'email'), $percentage . '%', \GO\Base\Util\Number::formatSize($quota['limit'] * 1024));
             $round5 = floor($usage / 5) * 5;
             $usage = '<span class="em-usage-' . $round5 . '">' . $usage . '</span>';
         } else {
             $usage = sprintf(\GO::t('usage', 'email'), \GO\Base\Util\Number::formatSize($quota['usage'] * 1024));
         }
     }
     //var_dump($usage);
     return $usage;
 }