/** * File Settings */ public function actionFile() { $form = new \humhub\modules\admin\models\forms\FileSettingsForm(); $form->imageMagickPath = Setting::Get('imageMagickPath', 'file'); $form->maxFileSize = Setting::Get('maxFileSize', 'file') / 1024 / 1024; $form->maxPreviewImageWidth = Setting::Get('maxPreviewImageWidth', 'file'); $form->maxPreviewImageHeight = Setting::Get('maxPreviewImageHeight', 'file'); $form->hideImageFileInfo = Setting::Get('hideImageFileInfo', 'file'); $form->useXSendfile = Setting::Get('useXSendfile', 'file'); $form->allowedExtensions = Setting::GetText('allowedExtensions', 'file'); $form->showFilesWidgetBlacklist = Setting::GetText('showFilesWidgetBlacklist', 'file'); if ($form->load(Yii::$app->request->post()) && $form->validate()) { $new = $form->maxFileSize * 1024 * 1024; Setting::Set('imageMagickPath', $form->imageMagickPath, 'file'); Setting::Set('maxFileSize', $new, 'file'); Setting::Set('maxPreviewImageWidth', $form->maxPreviewImageWidth, 'file'); Setting::Set('maxPreviewImageHeight', $form->maxPreviewImageHeight, 'file'); Setting::Set('hideImageFileInfo', $form->hideImageFileInfo, 'file'); Setting::Set('useXSendfile', $form->useXSendfile, 'file'); Setting::SetText('allowedExtensions', strtolower($form->allowedExtensions), 'file'); Setting::SetText('showFilesWidgetBlacklist', $form->showFilesWidgetBlacklist, 'file'); // set flash message Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); return Yii::$app->response->redirect(Url::toRoute('/admin/setting/file')); } // Determine PHP Upload Max FileSize $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize')); if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) { $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size')); } $maxUploadSize = floor($maxUploadSize / 1024 / 1024); // Determine currently used ImageLibary $currentImageLibary = 'GD'; if (Setting::Get('imageMagickPath', 'file')) { $currentImageLibary = 'ImageMagick'; } return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary)); }
/** * File Settings */ public function actionFile() { $form = new \humhub\modules\admin\models\forms\FileSettingsForm(); if ($form->load(Yii::$app->request->post()) && $form->validate() && $form->save()) { Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); return $this->redirect(['/admin/setting/file']); } // Determine PHP Upload Max FileSize $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize')); if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) { $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size')); } $maxUploadSize = floor($maxUploadSize / 1024 / 1024); // Determine currently used ImageLibary $currentImageLibary = 'GD'; if (Yii::$app->getModule('file')->settings->get('imageMagickPath')) { $currentImageLibary = 'ImageMagick'; } return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary)); }