Skip to content

Commit

Permalink
setFieldDefaults() bugfix. Default properties overwriting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Lanets committed Aug 6, 2013
1 parent 57408b4 commit 3266adc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions core/model/modx/processors/resource/create.class.php
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -617,4 +623,4 @@ public function clearCache() {
return $clear;
}
}
return 'modResourceCreateProcessor';
return 'modResourceCreateProcessor';

0 comments on commit 3266adc

Please sign in to comment.