1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Fixes #4369 Reverted model multi-dimensional support for now. Added test for custom-fields scenario.

This commit is contained in:
Cameron
2021-02-02 07:34:36 -08:00
parent cb6ddff64b
commit ed94389451
2 changed files with 139 additions and 1 deletions

View File

@@ -2723,7 +2723,8 @@ class e_front_model extends e_model
{
if($this->isValidFieldKey($k))
{
$ret[$k] = is_array($v) ? $this->sanitize($v) : $this->sanitize($k, $v);
$ret[$k] = $this->sanitize($k, $v);
// $ret[$k] = is_array($v) ? $this->sanitize($v) : $this->sanitize($k, $v);
}
}
return $ret;

View File

@@ -134,6 +134,143 @@
}
public function testSanitizeCustomFields()
{
$dataFields = array ( 'chapter_id' => 'int', 'chapter_icon' => 'str', 'chapter_parent' => 'str', 'chapter_name' => 'str', 'chapter_template' => 'str', 'chapter_meta_description' => 'str', 'chapter_meta_keywords' => 'str', 'chapter_sef' => 'str', 'chapter_manager' => 'int', 'chapter_order' => 'str', 'chapter_visibility' => 'int', 'chapter_fields' => 'json', 'chapter_image' => 'str', );
$this->model->setDataFields($dataFields);
$posted = array ( 'lastname_74758209201093747' => '', 'e-token' => 'a51c3769f784b6d980bdb86a93e56998', 'chapter_icon' => '', 'mediameta_chapter_icon' => '', 'chapter_parent' => '1', 'chapter_name' => 'Custom Fields 10', 'chapter_template' => 'default', 'chapter_meta_description' => 'Chapter containing custom fields', 'chapter_meta_keywords' => '', 'chapter_sef' => 'customfields', 'chapter_manager' => '254', 'chapter_order' => '0', 'chapter_visibility' => '0', 'chapter_image' => '', 'mediameta_chapter_image' => '', '__e_customfields_tabs__' => 'Custom Fields 10', 'chapter_fields' => array ( '__tabs__' => array ( 'additional' => 'Custom Fields 10', ), 'mybbarea' => array ( 'title' => 'Rich Text', 'type' => 'bbarea', 'writeParms' => '{ "rows": "4" }', 'help' => '', ), 'myboolean' => array ( 'title' => 'Boolean', 'type' => 'boolean', 'writeParms' => '', 'help' => '', ), 'mycheckbox' => array ( 'title' => 'Checkbox', 'type' => 'checkbox', 'writeParms' => '', 'help' => '', ), 'mycountry' => array ( 'title' => 'Country', 'type' => 'country', 'writeParms' => '', 'help' => '', ), 'mydatestamp' => array ( 'title' => 'Date', 'type' => 'datestamp', 'writeParms' => '{ "format": "yyyy-mm-dd" }', 'help' => '', ), 'mydropdown' => array ( 'title' => 'Selection', 'type' => 'dropdown', 'writeParms' => '{ "optArray": { "blue": "Blue", "green": "Green", "red": "Red" }, "default": "blank" }', 'help' => '', ), 'myemail' => array ( 'title' => 'Email', 'type' => 'email', 'writeParms' => '', 'help' => '', ), 'myfile' => array ( 'title' => 'File', 'type' => 'file', 'writeParms' => '', 'help' => '', ), 'myicon' => array ( 'title' => 'Icon', 'type' => 'icon', 'writeParms' => '', 'help' => '', ), 'myimage' => array ( 'title' => 'Image', 'type' => 'image', 'writeParms' => '', 'help' => '', ), 'mylanguage' => array ( 'title' => 'Language', 'type' => 'language', 'writeParms' => '', 'help' => '', ), 'mynumber' => array ( 'title' => 'Number', 'type' => 'number', 'writeParms' => '', 'help' => '', ), 'myprogressbar' => array ( 'title' => 'Progress', 'type' => 'progressbar', 'writeParms' => '', 'help' => '', ), 'mytags' => array ( 'title' => 'Tags', 'type' => 'tags', 'writeParms' => '', 'help' => '', ), 'mytext' => array ( 'title' => 'Text', 'type' => 'text', 'writeParms' => '', 'help' => '', ), 'myurl' => array ( 'title' => 'URL', 'type' => 'url', 'writeParms' => '', 'help' => '', ), 'myvideo' => array ( 'title' => 'Video', 'type' => 'video', 'writeParms' => '', 'help' => '', ), ), 'etrigger_submit' => 'update', '__after_submit_action' => 'list', 'submit_value' => '9', );
$expected = array (
'chapter_icon' => '',
'chapter_parent' => '1',
'chapter_name' => 'Custom Fields 10',
'chapter_template' => 'default',
'chapter_meta_description' => 'Chapter containing custom fields',
'chapter_meta_keywords' => '',
'chapter_sef' => 'customfields',
'chapter_manager' => 254,
'chapter_order' => '0',
'chapter_visibility' => 0,
'chapter_image' => '',
'chapter_fields' => '{
"__tabs__": {
"additional": "Custom Fields 10"
},
"mybbarea": {
"title": "Rich Text",
"type": "bbarea",
"writeParms": "{ \\"rows\\": \\"4\\" }",
"help": ""
},
"myboolean": {
"title": "Boolean",
"type": "boolean",
"writeParms": "",
"help": ""
},
"mycheckbox": {
"title": "Checkbox",
"type": "checkbox",
"writeParms": "",
"help": ""
},
"mycountry": {
"title": "Country",
"type": "country",
"writeParms": "",
"help": ""
},
"mydatestamp": {
"title": "Date",
"type": "datestamp",
"writeParms": "{ \\"format\\": \\"yyyy-mm-dd\\" }",
"help": ""
},
"mydropdown": {
"title": "Selection",
"type": "dropdown",
"writeParms": "{ \\"optArray\\": { \\"blue\\": \\"Blue\\", \\"green\\": \\"Green\\", \\"red\\": \\"Red\\" }, \\"default\\": \\"blank\\" }",
"help": ""
},
"myemail": {
"title": "Email",
"type": "email",
"writeParms": "",
"help": ""
},
"myfile": {
"title": "File",
"type": "file",
"writeParms": "",
"help": ""
},
"myicon": {
"title": "Icon",
"type": "icon",
"writeParms": "",
"help": ""
},
"myimage": {
"title": "Image",
"type": "image",
"writeParms": "",
"help": ""
},
"mylanguage": {
"title": "Language",
"type": "language",
"writeParms": "",
"help": ""
},
"mynumber": {
"title": "Number",
"type": "number",
"writeParms": "",
"help": ""
},
"myprogressbar": {
"title": "Progress",
"type": "progressbar",
"writeParms": "",
"help": ""
},
"mytags": {
"title": "Tags",
"type": "tags",
"writeParms": "",
"help": ""
},
"mytext": {
"title": "Text",
"type": "text",
"writeParms": "",
"help": ""
},
"myurl": {
"title": "URL",
"type": "url",
"writeParms": "",
"help": ""
},
"myvideo": {
"title": "Video",
"type": "video",
"writeParms": "",
"help": ""
}
}',
);
$result = $this->model->sanitize($posted);
$this->assertSame($expected, $result);
}
/*
public function testAddValidationError()
{