diff --git a/cache/lastCache.txt b/cache/lastCache.txt index 5c17eb9..89f551d 100644 --- a/cache/lastCache.txt +++ b/cache/lastCache.txt @@ -1 +1 @@ -1577899842 \ No newline at end of file +1578262565 \ No newline at end of file diff --git a/system/Controllers/MetaApiController.php b/system/Controllers/MetaApiController.php index 271d9a4..ef55b19 100644 --- a/system/Controllers/MetaApiController.php +++ b/system/Controllers/MetaApiController.php @@ -30,10 +30,13 @@ class MetaApiController extends ContentController # loop through all plugins foreach($this->settings['plugins'] as $name => $plugin) { - $pluginSettings = \Typemill\Settings::getObjectSettings('plugins', $name); - if($pluginSettings && isset($pluginSettings['metatabs'])) + if($plugin['active']) { - $metatabs = array_merge_recursive($metatabs, $pluginSettings['metatabs']); + $pluginSettings = \Typemill\Settings::getObjectSettings('plugins', $name); + if($pluginSettings && isset($pluginSettings['metatabs'])) + { + $metatabs = array_merge_recursive($metatabs, $pluginSettings['metatabs']); + } } } @@ -155,4 +158,6 @@ class MetaApiController extends ContentController # return with the new metadata return $response->withJson(array('metadata' => $metaData, 'errors' => false)); } -} \ No newline at end of file +} + +# check models -> writeYaml for getPageMeta and getPageMetaDefaults. \ No newline at end of file diff --git a/system/Controllers/SettingsController.php b/system/Controllers/SettingsController.php index d09a334..31eadc3 100644 --- a/system/Controllers/SettingsController.php +++ b/system/Controllers/SettingsController.php @@ -463,7 +463,7 @@ class SettingsController extends Controller if($validate->newUser($params, $userroles)) { - $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole'], 'password' => $params['password']); + $userdata = array('username' => $params['username'], 'firstname' => $params['firstname'], 'lastname' => $params['lastname'], 'email' => $params['email'], 'userrole' => $params['userrole'], 'password' => $params['password']); $user->createUser($userdata); @@ -511,7 +511,7 @@ class SettingsController extends Controller if($validate->existingUser($params, $userroles)) { - $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole']); + $userdata = array('username' => $params['username'], 'firstname' => $params['firstname'], 'lastname' => $params['lastname'], 'email' => $params['email'], 'userrole' => $params['userrole']); if(empty($params['password']) AND empty($params['newpassword'])) { diff --git a/system/Models/Field.php b/system/Models/Field.php index ad481c2..712a1ea 100644 --- a/system/Models/Field.php +++ b/system/Models/Field.php @@ -64,6 +64,7 @@ class Field 'id', 'autocomplete', 'placeholder', + 'maxlength', 'size', 'rows', 'cols', diff --git a/system/Models/User.php b/system/Models/User.php index ded5290..66be810 100644 --- a/system/Models/User.php +++ b/system/Models/User.php @@ -38,6 +38,15 @@ class User extends WriteYaml 'password' => $this->generatePassword($params['password']), 'userrole' => $params['userrole'] ); + + if(isset($params['firstname'])) + { + $userdata['firstname'] = $params['firstname']; + } + if(isset($params['lastname'])) + { + $userdata['lastname'] = $params['lastname']; + } if($this->updateYaml('settings/users', $userdata['username'] . '.yaml', $userdata)) { @@ -58,8 +67,20 @@ class User extends WriteYaml $update = array_merge($userdata, $params); $this->updateYaml('settings/users', $userdata['username'] . '.yaml', $update); + + $_SESSION['user'] = $update['username']; + $_SESSION['role'] = $update['userrole']; + + if(isset($update['firstname'])) + { + $_SESSION['firstname'] = $update['firstname']; + } + if(isset($update['lastname'])) + { + $_SESSION['lastname'] = $update['lastname']; + } - return $userdata['username']; + return $userdata['username']; } public function deleteUser($username) @@ -88,6 +109,15 @@ class User extends WriteYaml $_SESSION['user'] = $user['username']; $_SESSION['role'] = $user['userrole']; $_SESSION['login'] = $user['lastlogin']; + + if(isset($user['firstname'])) + { + $_SESSION['firstname'] = $user['firstname']; + } + if(isset($user['lastname'])) + { + $_SESSION['lastname'] = $user['lastname']; + } } } diff --git a/system/Models/Validation.php b/system/Models/Validation.php index 989fff9..5e0d8d9 100644 --- a/system/Models/Validation.php +++ b/system/Models/Validation.php @@ -124,6 +124,10 @@ class Validation $v->rule('lengthBetween', 'password', 5, 20)->message("Length between 5 - 20"); $v->rule('lengthBetween', 'username', 3, 20)->message("Length between 3 - 20"); $v->rule('userAvailable', 'username')->message("User already exists"); + $v->rule('noHTML', 'firstname')->message(" contains HTML"); + $v->rule('lengthBetween', 'firstname', 2, 40); + $v->rule('noHTML', 'lastname')->message(" contains HTML"); + $v->rule('lengthBetween', 'lastname', 2, 40); $v->rule('email', 'email')->message("e-mail is invalid"); $v->rule('in', 'userrole', $userroles); @@ -137,10 +141,14 @@ class Validation $v->rule('alphaNum', 'username')->message("invalid"); $v->rule('lengthBetween', 'username', 3, 20)->message("Length between 3 - 20"); $v->rule('userExists', 'username')->message("user does not exist"); + $v->rule('noHTML', 'firstname')->message(" contains HTML"); + $v->rule('lengthBetween', 'firstname', 2, 40); + $v->rule('noHTML', 'lastname')->message(" contains HTML"); + $v->rule('lengthBetween', 'lastname', 2, 40); $v->rule('email', 'email')->message("e-mail is invalid"); $v->rule('in', 'userrole', $userroles); - return $this->validationResult($v); + return $this->validationResult($v); } public function username($username) @@ -329,7 +337,23 @@ class Validation { $v->rule('required', $fieldName); } - + if(isset($fieldDefinitions['maxlength'])) + { + $v->rule('lengthMax', $fieldName, $fieldDefinitions['maxlength']); + } + if(isset($fieldDefinitions['max'])) + { + $v->rule('max', $fieldName, $fieldDefinitions['max']); + } + if(isset($fieldDefinitions['min'])) + { + $v->rule('min', $fieldName, $fieldDefinitions['min']); + } + if(isset($fieldDefinitions['pattern'])) + { + $v->rule('regex', $fieldName, '/^' . $fieldDefinitions['pattern'] . '$/'); + } + switch($fieldDefinitions['type']) { case "select": @@ -350,7 +374,7 @@ class Validation { $v->rule('in', $key, $options); } - break; + break; case "color": $v->rule('regex', $fieldName, '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/'); break; @@ -361,33 +385,35 @@ class Validation $v->rule('date', $fieldName); break; case "checkbox": - $v->rule('accepted', $fieldName); + if(isset($fieldDefinitions['required'])) + { + $v->rule('accepted', $fieldName); + } break; case "url": - $v->rule('lengthMax', $fieldName, 200); $v->rule('url', $fieldName); + $v->rule('lengthMax', $fieldName, 200); break; case "text": - $v->rule('lengthMax', $fieldName, 200); + $v->rule('noHTML', $fieldName); + $v->rule('lengthMax', $fieldName, 500); $v->rule('regex', $fieldName, '/^[\pL0-9_ \-\.\?\!\/\:]*$/u'); break; case "textarea": - $v->rule('lengthMax', $fieldName, 1000); $v->rule('noHTML', $fieldName); - // $v->rule('regex', $fieldName, '/<[^<]+>/'); + $v->rule('lengthMax', $fieldName, 1000); break; case "paragraph": - $v->rule('lengthMax', $fieldName, 1000); $v->rule('noHTML', $fieldName); + $v->rule('lengthMax', $fieldName, 1000); break; case "password": $v->rule('lengthMax', $fieldName, 100); break; default: $v->rule('lengthMax', $fieldName, 1000); - $v->rule('regex', $fieldName, '/^[\pL0-9_ \-]*$/u'); + $v->rule('regex', $fieldName, '/^[\pL0-9_ \-]*$/u'); } - return $this->validationResult($v, $objectName); } diff --git a/system/Models/WriteYaml.php b/system/Models/WriteYaml.php index 7364220..0254a2b 100644 --- a/system/Models/WriteYaml.php +++ b/system/Models/WriteYaml.php @@ -86,12 +86,27 @@ class WriteYaml extends Write $description = substr($description, 0, $lastSpace); } + $author = $settings['author']; + + if(isset($_SESSION)) + { + if(isset($_SESSION['firstname']) && $_SESSION['firstname'] !='' && isset($_SESSION['lastname']) && $_SESSION['lastname'] != '') + { + $author = $_SESSION['firstname'] . ' ' . $_SESSION['lastname']; + } + elseif(isset($_SESSION['user'])) + { + $author = $_SESSION['user']; + } + } + # create new meta-file $meta = [ 'meta' => [ 'title' => $title, 'description' => $description, - 'author' => $settings['author'], # change to session, extend userdata + 'author' => $author, + 'created' => date("Y-m-d"), ] ]; diff --git a/system/author/css/style.css b/system/author/css/style.css index 8d8027a..1d77906 100644 --- a/system/author/css/style.css +++ b/system/author/css/style.css @@ -1773,7 +1773,6 @@ button.format-item.close:hover{ top: 0; left: 0; transform: translate(-50%, -100%); - transition: 0.2s all; display: flex; justify-content: center; align-items: center; @@ -1809,7 +1808,7 @@ button.format-item.close:hover{ margin-right: 2px; } .urlinput{ - width: 80%; + width: 75%; min-height: auto; background: #555; color: #fff; diff --git a/system/author/editor/editor-raw.twig b/system/author/editor/editor-raw.twig index db69474..22a8d8d 100644 --- a/system/author/editor/editor-raw.twig +++ b/system/author/editor/editor-raw.twig @@ -5,6 +5,27 @@