Пример #1
0
 public static function getIndexChar($string)
 {
     $char = '';
     if (!empty($string)) {
         if (function_exists('mb_substr')) {
             $char = strtoupper(mb_substr(\GO\Base\Fs\Base::stripInvalidChars($string), 0, 1, 'UTF-8'));
         } else {
             $char = strtoupper(substr(\GO\Base\Fs\Base::stripInvalidChars($string), 0, 1));
         }
     }
     return $char;
 }
Пример #2
0
 /**
  * The files module will use this function.
  */
 public function buildFilesPath()
 {
     return 'tasks/' . \GO\Base\Fs\Base::stripInvalidChars($this->tasklist->name) . '/' . date('Y', $this->due_time) . '/' . \GO\Base\Fs\Base::stripInvalidChars($this->name) . ' (' . $this->id . ')';
 }
Пример #3
0
 /**
  * The files module will use this function. To create a files folder.
  * Override it if you don't like the default path. Make sure this path is unique! Appending the (<id>) would be wise.
  */
 public function buildFilesPath()
 {
     return isset($this->name) ? $this->getModule() . '/' . \GO\Base\Fs\Base::stripInvalidChars($this->name) : false;
 }
Пример #4
0
 /**
  * The files module will use this function.
  */
 public function buildFilesPath()
 {
     return 'calendar/' . \GO\Base\Fs\Base::stripInvalidChars($this->calendar->name) . '/' . date('Y', $this->start_time) . '/' . \GO\Base\Fs\Base::stripInvalidChars($this->name) . ' (' . $this->id . ')';
 }
Пример #5
0
 /**
  * The files module will use this function.
  */
 public function buildFilesPath()
 {
     $new_folder_name = \GO\Base\Fs\Base::stripInvalidChars($this->name) . ' (' . $this->id . ')';
     $new_path = $this->addressbook->buildFilesPath() . '/companies';
     $char = \GO\Addressbook\Utils::getIndexChar($new_folder_name);
     $new_path .= '/' . $char . '/' . $new_folder_name;
     return $new_path;
 }
Пример #6
0
 /**
  * The files module will use this function.
  */
 public function buildFilesPath()
 {
     return 'notes/' . Base::stripInvalidChars($this->category->name) . '/' . date('Y', $this->ctime) . '/' . Base::stripInvalidChars($this->name) . ' (' . $this->id . ')';
 }
Пример #7
0
 /**
  * Compress the selected files and return as download
  * 
  * @param array $params
  * @return boolean
  * @throws \Exception
  */
 protected function actionCompressAndDownload($params)
 {
     if (!isset($params['archive_name'])) {
         throw new \Exception('No name for the archive given');
     }
     ini_set('max_execution_time', 600);
     ini_set('memory_limit', '512M');
     $sources = json_decode($params['sources'], true);
     $workingFolder = false;
     // Read the sources and create objects from them
     $sourceObjects = array();
     // The total filesize in bytes
     $totalFileSize = 0;
     // The maximum filesize that is allowed to zip (Default is 256MB)
     $maxFilesize = GO::config()->zip_max_file_size;
     for ($i = 0; $i < count($sources); $i++) {
         $path = \GO::config()->file_storage_path . $sources[$i];
         $sourceFile = \GO\Base\Fs\Base::createFromPath($path);
         // Increase the total filesize
         $totalFileSize += $sourceFile->size();
         if ($totalFileSize >= $maxFilesize) {
             throw new \Exception(sprintf(\GO::t('zipFilesizeTooBig', 'base'), \GO\Base\Util\Number::formatSize($maxFilesize, 2)));
         }
         // Set the workingFolder
         if (!$workingFolder) {
             $workingFolder = $sourceFile->parent();
         }
         $sourceObjects[] = $sourceFile;
     }
     // Create the zipped temp file object
     $archiveFile = \GO\Base\Fs\File::tempFile($params['archive_name'], 'zip');
     if ($archiveFile->exists()) {
         throw new \Exception(sprintf(\GO::t('filenameExists', 'files'), $archiveFile->stripFileStoragePath()));
     }
     // Create the zipfile
     if (\GO\Base\Fs\Zip::create($archiveFile, $workingFolder, $sourceObjects)) {
         // Output download headers
         //			\GO\Base\Util\Http::outputDownloadHeaders($archiveFile,false,true);
         //			$archiveFile->output();
         $response['archive'] = $archiveFile->stripTempPath();
         $response['success'] = true;
     } else {
         throw new \Exception("ZIP creation failed");
     }
     return $response;
 }
Пример #8
0
 /**
  * The files module will use this function.
  */
 public function buildFilesPath()
 {
     if (!$this->addressbook) {
         return false;
     }
     $new_folder_name = \GO\Base\Fs\Base::stripInvalidChars($this->name) . ' (' . $this->id . ')';
     $last_part = empty($this->last_name) ? '' : \GO\Addressbook\Utils::getIndexChar($this->last_name);
     $new_path = $this->addressbook->buildFilesPath() . '/contacts';
     if (!empty($last_part)) {
         $new_path .= '/' . $last_part;
     } else {
         $new_path .= '/0 no last name';
     }
     $new_path .= '/' . $new_folder_name;
     return $new_path;
 }