Skip to content

Commit

Permalink
check primary-key-field, if other than id in default-processors: getl…
Browse files Browse the repository at this point in the history
…ist and fields

Signed-off-by: Bruno Perner <b.perner@gmx.de>
  • Loading branch information
Bruno17 committed Sep 14, 2012
1 parent 4194c88 commit ad259f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
17 changes: 10 additions & 7 deletions core/components/migx/model/migx/migx.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1069,16 +1069,19 @@ function extractInputTvs($formtabs) {
$inputTvs = array();
if (is_array($formtabs)) {
foreach ($formtabs as $tab) {
$fields = is_array($tab['fields']) ? $tab['fields'] : $this->modx->fromJson($tab['fields']);
if (isset($tab['fields']) && is_array($fields)) {
foreach ($fields as $field) {
if (isset($field['inputTV']) && !empty($field['inputTV'])) {
$inputTvs[$field['field']] = $field;
} elseif (isset($field['inputTVtype']) && !empty($field['inputTVtype'])) {
$inputTvs[$field['field']] = $field;
if (isset($tab['fields'])) {
$fields = is_array($tab['fields']) ? $tab['fields'] : $this->modx->fromJson($tab['fields']);
if (is_array($fields)) {
foreach ($fields as $field) {
if (isset($field['inputTV']) && !empty($field['inputTV'])) {
$inputTvs[$field['field']] = $field;
} elseif (isset($field['inputTVtype']) && !empty($field['inputTVtype'])) {
$inputTvs[$field['field']] = $field;
}
}
}
}

}
}
return $inputTvs;
Expand Down
3 changes: 2 additions & 1 deletion core/components/migx/processors/mgr/default/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
$object->set('object_id', 'new');
} else {
$c = $modx->newQuery($classname, $scriptProperties['object_id']);
$pk = $modx->getPK($classname);
$c->select('
`' . $classname . '`.*,
`' . $classname . '`.`id` AS `object_id`
`' . $classname . '`.`'.$pk.'` AS `object_id`
');
if (!empty($joinalias)) {
$c->leftjoin($joinclass, $joinalias);
Expand Down
2 changes: 2 additions & 0 deletions core/components/migx/processors/mgr/default/getlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@
//$c->prepare();echo $c->toSql();
$rows = array();
if ($collection = $modx->getCollection($classname, $c)) {
$pk = $modx->getPK($classname);
foreach ($collection as $object) {
$row = $object->toArray();
$row['id'] = !isset($row['id']) ? $row[$pk] : $row['id'];
$rows[] = $row;
}
}

0 comments on commit ad259f0

Please sign in to comment.