From 3266adcc309486d61e5096a582cf9daeca9106cd Mon Sep 17 00:00:00 2001 From: Nikolay Lanets Date: Tue, 6 Aug 2013 10:11:34 -0700 Subject: [PATCH] setFieldDefaults() bugfix. Default properties overwriting. --- .../modx/processors/resource/create.class.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/model/modx/processors/resource/create.class.php b/core/model/modx/processors/resource/create.class.php index 7245fe883ee..cdd88bbfd44 100644 --- a/core/model/modx/processors/resource/create.class.php +++ b/core/model/modx/processors/resource/create.class.php @@ -202,12 +202,18 @@ public function setFieldDefaults() { $scriptProperties['searchable'] = !isset($scriptProperties['searchable']) ? (integer) $this->workingContext->getOption('search_default', 1) : (empty($scriptProperties['searchable']) ? 0 : 1); $scriptProperties['content_type'] = !isset($scriptProperties['content_type']) ? (integer) $this->workingContext->getOption('default_content_type',1) : (integer)$scriptProperties['content_type']; $scriptProperties['syncsite'] = empty($scriptProperties['syncsite']) ? 0 : 1; - $scriptProperties['createdon'] = strftime('%Y-%m-%d %H:%M:%S'); - $scriptProperties['createdby'] = $this->modx->user->get('id'); $scriptProperties['menuindex'] = empty($scriptProperties['menuindex']) ? 0 : $scriptProperties['menuindex']; $scriptProperties['deleted'] = empty($scriptProperties['deleted']) ? 0 : 1; $scriptProperties['uri_override'] = empty($scriptProperties['uri_override']) ? 0 : 1; - + + if(empty($scriptProperties['createdon'])){ + $scriptProperties['createdon'] = strftime('%Y-%m-%d %H:%M:%S'); + } + + if(empty($scriptProperties['createdby'])){ + $scriptProperties['createdby'] = $this->modx->user->get('id'); + } + /* publish and unpublish dates */ $now = time(); if (isset($scriptProperties['pub_date'])) { @@ -247,7 +253,7 @@ public function setFieldDefaults() { } else { $scriptProperties['publishedon'] = strtotime($scriptProperties['publishedon']); } - $scriptProperties['publishedby'] = $scriptProperties['published'] ? $this->modx->user->get('id') : 0; + $scriptProperties['publishedby'] = $scriptProperties['published'] ? !empty($scriptProperties['publishedby']) ? $scriptProperties['publishedby'] : $this->modx->user->get('id') : 0; } $this->setProperties($scriptProperties); @@ -617,4 +623,4 @@ public function clearCache() { return $clear; } } -return 'modResourceCreateProcessor'; \ No newline at end of file +return 'modResourceCreateProcessor';