예제 #1
0
 /**
  * The code that needs to be called when the cron is running
  * 
  * If $this->enableUserAndGroupSupport() returns TRUE then the run function 
  * will be called for each $user. (The $user parameter will be given)
  * 
  * If $this->enableUserAndGroupSupport() returns FALSE then the 
  * $user parameter is null and the run function will be called only once.
  * 
  * @param \GO\Base\Cron\CronJob $cronJob
  * @param \GO\Base\Model\User $user [OPTIONAL]
  */
 public function run(\GO\Base\Cron\CronJob $cronJob, \GO\Base\Model\User $user = null)
 {
     \GO::session()->runAsRoot();
     \GO::debug("Start updating public calendars.");
     $calendars = \GO\Calendar\Model\Calendar::model()->findByAttribute('public', true);
     foreach ($calendars as $calendar) {
         $file = new \GO\Base\Fs\File($calendar->getPublicIcsPath());
         if (!$file->exists()) {
             \GO::debug("Creating " . $file->path() . ".");
             $file->touch(true);
         }
         $file->putContents($calendar->toVObject());
         \GO::debug("Updating " . $calendar->name . " to " . $file->path() . ".");
     }
     \GO::debug("Finished updating public calendars.");
 }
예제 #2
0
파일: Config.php 프로젝트: ajaboa/crmpuan
 public function __construct(\GO\Site\Model\Site $siteModel)
 {
     $file = new \GO\Base\Fs\File($siteModel->getSiteModule()->moduleManager->path() . 'siteconfig.php');
     if ($file->exists()) {
         require $file->path();
     }
     if (isset($siteconfig)) {
         $this->_configOptions = $siteconfig;
     }
 }
예제 #3
0
 public function createTempFile()
 {
     if (!$this->hasTempFile()) {
         $tmpFile = new \GO\Base\Fs\File($this->getTempDir() . \GO\Base\Fs\File::stripInvalidChars($this->name));
         //			This fix for duplicate filenames in forwards caused screwed up attachment names!
         //			A possible new fix should be made in ImapMessage->getAttachments()
         //
         //			$file = new \GO\Base\Fs\File($this->name);
         //			$tmpFile = new \GO\Base\Fs\File($this->getTempDir().uniqid(time()).'.'.$file->extension());
         if (!$tmpFile->exists()) {
             $imap = $this->account->openImapConnection($this->mailbox);
             $imap->save_to_file($this->uid, $tmpFile->path(), $this->number, $this->encoding, true);
         }
         $this->setTempFile($tmpFile);
     }
     return $this->getTempFile();
 }
예제 #4
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');
         }
     }
 }
예제 #5
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;
 }
예제 #6
0
 /**
  * Returns the path to the viewfile based on the used template and module
  * It will search for a template first if not found look in the views/site/ folder
  * the default viewfile provided by the module
  * @param string $viewName name to the viewfile
  * @return string path of the viewfile
  */
 public function getViewFile($viewName)
 {
     $module = \Site::model()->getSiteModule();
     if (substr($viewName, 0, 1) != "/") {
         $classParts = explode('\\', get_class($this));
         $moduleId = strtolower($classParts[1]);
         $viewName = '/' . $moduleId . '/' . $viewName;
     }
     $file = new \GO\Base\Fs\File($module->moduleManager->path() . 'views/site/' . $viewName . '.php');
     if (!$file->exists()) {
         throw new \Exception("View '{$viewName}' not found!");
     }
     return $file->path();
 }
예제 #7
0
 protected function actionHandleUploads($params)
 {
     if (!isset(\GO::session()->values['files']['uploadqueue'])) {
         \GO::session()->values['files']['uploadqueue'] = array();
     }
     try {
         $chunkTmpFolder = new \GO\Base\Fs\Folder(\GO::config()->tmpdir . 'juploadqueue/chunks');
         $tmpFolder = new \GO\Base\Fs\Folder(\GO::config()->tmpdir . 'juploadqueue');
         $tmpFolder->create();
         $chunkTmpFolder->create();
         $count = 0;
         while ($uploadedFile = array_shift($_FILES)) {
             if (isset($params['jupart'])) {
                 $originalFileName = $uploadedFile['name'];
                 $uploadedFile['name'] = $uploadedFile['name'] . '.part' . $params['jupart'];
                 $chunkTmpFolder->create();
                 \GO\Base\Fs\File::moveUploadedFiles($uploadedFile, $chunkTmpFolder);
                 if (!empty($params['jufinal'])) {
                     $file = new \GO\Base\Fs\File($tmpFolder . '/' . $originalFileName);
                     $fp = fopen($file->path(), 'w+');
                     for ($i = 1; $i <= $params['jupart']; $i++) {
                         $part = new \GO\Base\Fs\File($chunkTmpFolder . '/' . $originalFileName . '.part' . $i);
                         fwrite($fp, $part->contents());
                         $part->delete();
                     }
                     fclose($fp);
                     $chunkTmpFolder->delete();
                 } else {
                     echo "SUCCESS\n";
                     return;
                 }
             } else {
                 $files = \GO\Base\Fs\File::moveUploadedFiles($uploadedFile, $tmpFolder);
                 if (!$files) {
                     throw new \Exception("No file received");
                 }
                 $file = $files[0];
             }
             $subdir = false;
             if (!empty($params['relpathinfo' . $count]) && !isset($params['jupart']) || !empty($params['relpathinfo' . $count]) && isset($params['jupart']) && !empty($params['jufinal'])) {
                 $fullpath = \GO::config()->tmpdir . 'juploadqueue' . '/' . str_replace('\\', '/', $params['relpathinfo' . $count]);
                 $dir = new \GO\Base\Fs\Folder($fullpath);
                 $dir->create();
                 $subdir = true;
                 $file->move($dir);
             }
             $count++;
             if ($subdir) {
                 $parent = $this->_findHighestParent($dir);
                 \GO::debug($parent);
                 if (!in_array($parent->path(), \GO::session()->values['files']['uploadqueue'])) {
                     \GO::session()->values['files']['uploadqueue'][] = $parent->path();
                 }
             } else {
                 \GO::session()->values['files']['uploadqueue'][] = $file->path();
             }
         }
     } catch (\Exception $e) {
         echo 'WARNING: ' . $e->getMessage() . "\n";
     }
     echo "SUCCESS\n";
 }