/** * 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 CronJob $cronJob * @param User $user [OPTIONAL] */ public function run(CronJob $cronJob, User $user = null) { GO::session()->runAsRoot(); $licenseFile = \GO::getLicenseFile(); $temporaryLicenseFile = new \GO\Base\Fs\File(GO::config()->file_storage_path . 'license/' . $licenseFile->name()); if ($temporaryLicenseFile->exists()) { if (!$temporaryLicenseFile->move($licenseFile)) { throw new \Exception("Could not move license file to Group-Office root!"); } else { if (!GO::scriptCanBeDecoded()) { GO\Base\Mail\AdminNotifier::sendMail("Group-Office license invalid", "You attempted to install a license but the license file you provided didn't work. Please contant Intermesh about this error."); } else { //add all users to the modules they have access too \GO\Professional\License::autoConfigureModulePermissions(); GO\Base\Mail\AdminNotifier::sendMail("Group-Office license installed successfully!", "Your license was installed and the new users were automatically added to the App permissions if necessary.\n\nThank you for using Group-Office!"); } } } }
public function actionPasteUploadTemporary($filename, $filetype) { $type = explode('/', $filetype); $extension = $type[1]; $_FILES['pastedFile']['name'] = $filename . '.' . $extension; $file = new GO\Base\Fs\File($_FILES['pastedFile']['tmp_name']); $file->move(GO::config()->getTempFolder(), $filename . '.' . $extension, true); $response = new \GO\Base\Data\JsonResponse(array('success' => true, 'data' => array('tmp_file' => $file->stripTempPath(), 'name' => $file->name(), 'size' => $file->size(), 'type' => $file->mimeType(), 'extension' => $file->extension(), 'human_size' => $file->humanSize(), 'from_file_storage' => false))); echo $response; }
/** * Replace filesystem file with given file. * * @param \GO\Base\Fs\File $fsFile */ public function replace(\GO\Base\Fs\File $fsFile, $isUploadedFile = false) { if ($this->isLocked()) { throw new \GO\Files\Exception\FileLocked(); } // for safety allow replace action // if(!File::checkQuota($fsFile->size()-$this->size)) // throw new \GO\Base\Exception\InsufficientDiskSpace(); if (!$this->isNew) { $this->log('edit'); } $this->saveVersion(); if (!$fsFile->move($this->folder->fsFolder, $this->name, $isUploadedFile)) { return false; } $fsFile->setDefaultPermissions(); $this->mtime = $fsFile->mtime(); $this->save(); $this->fireEvent('replace', array($this, $isUploadedFile)); return true; }
/** * Set new photo file. The file will be converted into JPEG and resized to fit * a 480x640 pixel box * * @param \GO\Base\Fs\File $file */ public function seOLDPhoto(\GO\Base\Fs\File $file) { if ($this->isNew) { throw new \Exception("Cannot save a photo on a new company that is not yet saved."); } $this->getPhotoFile()->delete(); $photoPath = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'company_photos/' . $this->addressbook_id . '/'); $photoPath->create(); // if(strtolower($file->extension())!='jpg'){ // $filename = $photoPath->path().'/'.$this->id.'.jpg'; // $img = new \GO\Base\Util\Image(); // if(!$img->load($file->path())){ // throw new \Exception(\GO::t('imageNotSupported','addressbook')); // } // // //resize it to small image so we don't get in trouble with sync clients // $img->fitBox(240,320); // // if(!$img->save($filename, IMAGETYPE_JPEG)){ // throw new \Exception("Could not save photo!"); // } // $file = new \GO\Base\Fs\File($filename); // }else // { $file->move($photoPath, $this->id . '.' . strtolower($file->extension())); // } $this->photo = $file->stripFileStoragePath(); }
/** * The savemailas module can send attachments along to be stored as files with * a note, task, event etc. * * @param type $response * @param type $model * @param type $params */ public function processAttachments(&$response, &$model, &$params) { //Does this belong in the controller? if (!empty($params['tmp_files'])) { $tmp_files = json_decode($params['tmp_files'], true); if (count($tmp_files)) { $folder_id = $this->checkModelFolder($model, true, true); $folder = \GO\Files\Model\Folder::model()->findByPk($folder_id); while ($tmp_file = array_shift($tmp_files)) { if (!empty($tmp_file['tmp_file'])) { $file = new \GO\Base\Fs\File(\GO::config()->tmpdir . $tmp_file['tmp_file']); $file->move(new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . $folder->path)); $folder->addFile($file->name()); } } } } }
/** * Add an uploaded file * * @param array $filesArrayItem Item from the $_FILES array * @return boolean */ public function addUploadedFile($filesArrayItem) { $fsFile = new \GO\Base\Fs\File($filesArrayItem['tmp_name']); $fsFile->move($this->fsFolder, $filesArrayItem['name'], true, true); return $this->addFile($fsFile->name()); }