- Fix: Profile Markdown field files are not attached

- Chng: Don't restrict`humhub\modules\file\components\FileManager::attach()` to `humhub\components\ActiveRecord`
This commit is contained in:
buddh4 2019-03-14 20:06:45 +01:00
parent 008eb579a7
commit 89e680a015
7 changed files with 23 additions and 14 deletions

View File

@ -8,9 +8,12 @@
namespace humhub\compat;
use humhub\modules\content\widgets\richtext\RichText;
use humhub\modules\content\widgets\richtext\RichTextField;
use humhub\modules\file\components\FileManager;
use humhub\modules\ui\form\widgets\MultiSelect;
use humhub\modules\ui\form\widgets\Markdown;
use Yii;
use yii\helpers\Html;
/**
* HForm - Yii1 compatible form generator
@ -115,6 +118,8 @@ class HForm extends \yii\base\Component
$this->primaryModel->save();
}
(new FileManager(['record' => $this->primaryModel]))->attach(Yii::$app->request->post('fileList'));
foreach ($this->models as $model) {
if (!$model->save()) {
$hasErrors = true;
@ -302,13 +307,12 @@ class HForm extends \yii\base\Component
]);
case 'markdown':
$options['id'] = $name;
if (isset($options['readOnly'])) {
// Markdownfield's readyonly attribute is lower case
$options['readonly'] = $options['readOnly'];
unset($options['readOnly']);
if (isset($options['readOnly']) && $options['readOnly']) {
// TODO: Once the richtext supports readonly view remove this line
return RichText::output(Html::getAttributeValue($model, $name));
}
$returnField = $this->form->field($model, $name)->widget(Markdown::class, $options);
return $returnField;
return $this->form->field($model, $name)->widget(RichTextField::class, $options);;
default:
return "Field Type " . $definition['type'] . " not supported by Compat HForm";
}

View File

@ -5,6 +5,8 @@ HumHub Change Log
---------------------------
- Enh: Use of new Richtext for About section
- Chng: Force blank links in old markdown editor
- Fix: Profile Markdown field files are not attached
- Chng: Don't restrict`humhub\modules\file\components\FileManager::attach()` to `humhub\components\ActiveRecord`
1.3.11 (March 06, 2019)
---------------------------

View File

@ -66,7 +66,7 @@ class FileManager extends Component
}
$file->updateAttributes([
'object_model' => $this->record->className(),
'object_model' => get_class($this->record),
'object_id' => $this->record->getPrimaryKey(),
]);
}
@ -81,7 +81,7 @@ class FileManager extends Component
*/
public function find()
{
return File::find()->andWhere(['object_id' => $this->record->getPrimaryKey(), 'object_model' => $this->record->className()]);
return File::find()->andWhere(['object_id' => $this->record->getPrimaryKey(), 'object_model' => get_class($this->record)]);
}
/**

View File

@ -8,7 +8,7 @@
namespace humhub\modules\file\models;
use humhub\components\ActiveRecord;
use yii\db\ActiveRecord;
use Yii;
use yii\helpers\Url;
use humhub\modules\content\components\ContentActiveRecord;
@ -77,7 +77,7 @@ class File extends FileCompat
return [
[
'class' => \humhub\components\behaviors\PolymorphicRelation::class,
'mustBeInstanceOf' => [\humhub\components\ActiveRecord::class],
'mustBeInstanceOf' => [ActiveRecord::class],
],
[
'class' => \humhub\components\behaviors\GUID::class,
@ -191,6 +191,7 @@ class File extends FileCompat
* Returns the StorageManager
*
* @return \humhub\modules\file\components\StorageManager
* @throws \yii\base\InvalidConfigException
*/
public function getStore()
{

View File

@ -8,6 +8,7 @@
namespace humhub\modules\user\models\fieldtype;
use humhub\modules\user\models\Profile;
use Yii;
/**
@ -38,8 +39,8 @@ class MarkdownEditor extends BaseType
public function save()
{
$columnName = $this->profileField->internal_name;
if (!\humhub\modules\user\models\Profile::columnExists($columnName)) {
$query = Yii::$app->db->getQueryBuilder()->addColumn(\humhub\modules\user\models\Profile::tableName(), $columnName, 'TEXT');
if (!Profile::columnExists($columnName)) {
$query = Yii::$app->db->getQueryBuilder()->addColumn(Profile::tableName(), $columnName, 'TEXT');
Yii::$app->db->createCommand($query)->execute();
}

View File

@ -208,6 +208,7 @@
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
border-top-width: 1px !important;
min-height: 100px;
}
.ProseMirror-menu-group {

File diff suppressed because one or more lines are too long