예제 #1
0
파일: File.php 프로젝트: ajaboa/crmpuan
 public function checkWritePermission($delete = false)
 {
     $fsFile = new \GO\Base\Fs\File($this->path);
     $this->folder = \GO\Files\Model\Folder::model()->findByPath($fsFile->parent()->stripFileStoragePath());
     if (!\GO\Base\Model\Acl::hasPermission($this->folder->getPermissionLevel(), \GO\Base\Model\Acl::WRITE_PERMISSION)) {
         throw new Sabre\DAV\Exception\Forbidden("DAV: User " . \GO::user()->username . " doesn't have write permission for file '" . $this->relpath . '"');
     }
 }
예제 #2
0
 /**
  * This will copy a file in the files module to a public accessable folder
  * 
  * @param array $params
  * - stromg src: path the the file relative the the sites public storage folder.
  * @return the rsult of the thumb action on the core controller
  * @throws \GO\Base\Exception\AccessDenied when unable to create the folder?
  */
 protected function actionThumb($params)
 {
     $rootFolder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'site/' . \Site::model()->id);
     $file = new \GO\Base\Fs\File(\GO::config()->file_storage_path . 'site/' . \Site::model()->id . '/' . $params['src']);
     $folder = $file->parent();
     $ok = $folder->isSubFolderOf($rootFolder);
     if (!$ok) {
         throw new \GO\Base\Exception\AccessDenied();
     }
     $c = new \GO\Core\Controller\CoreController();
     return $c->run('thumb', $params, true, false);
 }
예제 #3
0
 private function _saveHeaders()
 {
     if (!$this->saved_headers) {
         $tempInFile = new \GO\Base\Fs\File(\GO::config()->tmpdir . "smime_tempin.txt");
         $tempInFile->parent()->create();
         $tempInFile->delete();
         $tempOutFile = new \GO\Base\Fs\File(\GO::config()->tmpdir . "smime_tempout.txt");
         $tempOutFile->delete();
         $this->tempin = $tempInFile->path();
         $this->tempout = $tempOutFile->path();
         /*
          * Store the headers of the current message because the PHP function
          * openssl_pkcs7_sign will rebuilt the MIME structure and will put the main
          * headers in a nested mimepart. We don't want that so we remove them now 
          * and add them to the new structure later.
          */
         $headers = $this->getHeaders();
         $headers->removeAll('MIME-Version');
         //		$headers->removeAll('Content-Type');
         $this->saved_headers = array();
         //$headers->toString();
         $ignored_headers = array('Content-Transfer-Encoding', 'Content-Type');
         $h = $headers->getAll();
         foreach ($h as $header) {
             $name = $header->getFieldName();
             if (!in_array($name, $ignored_headers)) {
                 $this->saved_headers[$name] = $header->getFieldBody();
                 $headers->removeAll($name);
             }
         }
         /*
          * This class will stream the MIME structure to the tempin text file in 
          * a memory efficient way.
          */
         $fbs = new \Swift_ByteStream_FileByteStream($this->tempin, true);
         parent::toByteStream($fbs);
         if (!file_exists($this->tempin)) {
             throw new \Exception('Could not write temporary message for signing');
         }
     }
 }
예제 #4
0
 /**
  * Saves the report to a file
  * output path and filename should be set before calling this function
  * @param \GO\Projects2\Model\Project $project the project object
  * @return \GO\Files\Model\File
  */
 public function save()
 {
     $file = new \GO\Base\Fs\File($this->_outputPath . '/' . $this->filename . '.' . $this->fileExtension());
     $file->appendNumberToNameIfExists();
     $this->_outputPath = $file->path();
     $str = $this->render(true);
     if (!isset($this->_fp)) {
         $this->_fp = fopen($this->_outputPath, 'w+');
     }
     fputs($this->_fp, $str);
     $folder = \GO\Files\Model\Folder::model()->findByPath($file->parent()->stripFileStoragePath());
     $fileModel = $folder->addFile($file->name());
     return $fileModel;
 }