Add plain/raw descriptions

This commit is contained in:
Dennis Eichhorn 2017-12-18 20:22:00 +01:00
parent 3c5b81efde
commit ffd2a6b6cf
4 changed files with 20 additions and 3 deletions

View File

@ -48,7 +48,8 @@ class Installer extends InstallerAbstract
`group_id` int(11) NOT NULL AUTO_INCREMENT,
`group_name` varchar(50) NOT NULL,
`group_status` int(3) NOT NULL,
`group_desc` varchar(255) DEFAULT NULL,
`group_desc` text DEFAULT NULL,
`group_desc_raw` text DEFAULT NULL,
`group_created` datetime DEFAULT NULL,
PRIMARY KEY (`group_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'

View File

@ -31,6 +31,7 @@ use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\System\MimeType;
use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Views\View;
use phpOMS\Message\Http\RequestStatusCode;
@ -491,7 +492,8 @@ class Controller extends ModuleAbstract implements WebInterface
$group = GroupMapper::get((int) $request->getData('id'));
$group->setName((string) ($request->getData('name') ?? $group->getName()));
$group->setDescription((string) ($request->getData('description') ?? $group->getDescription()));
$group->setDescription(Markdown::parse((string) ($request->getData('description') ?? $group->getDescription())));
$group->setDescriptionRaw((string) ($request->getData('description') ?? $group->getDescriptionRaw()));
GroupMapper::update($group);
@ -565,7 +567,8 @@ class Controller extends ModuleAbstract implements WebInterface
$group->setCreatedBy($request->getHeader()->getAccount());
$group->setName((string) ($request->getData('name') ?? ''));
$group->setStatus((int) ($request->getData('status') ?? GroupStatus::INACTIVE));
$group->setDescription((string) ($request->getData('description') ?? ''));
$group->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
$group->setDescriptionRaw((string) ($request->getData('description') ?? ''));
return $group;
}

View File

@ -41,6 +41,8 @@ class Group extends \phpOMS\Account\Group
*/
protected $createdBy = 0;
protected $descriptionRaw = '';
/**
* Constructor
*
@ -81,4 +83,14 @@ class Group extends \phpOMS\Account\Group
{
$this->createdBy = $createdBy;
}
public function setDescriptionRaw(string $description) /* : void */
{
$this->descriptionRaw = $description;
}
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
}

View File

@ -31,6 +31,7 @@ class GroupMapper extends DataMapperAbstract
'group_name' => ['name' => 'group_name', 'type' => 'string', 'internal' => 'name'],
'group_status' => ['name' => 'group_status', 'type' => 'int', 'internal' => 'status'],
'group_desc' => ['name' => 'group_desc', 'type' => 'string', 'internal' => 'description'],
'group_desc_raw' => ['name' => 'group_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'group_created' => ['name' => 'group_created', 'type' => 'DateTime', 'internal' => 'createdAt'],
];