From bb28bdb1bfb09c54ce1871d6835e42ac7a810347 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 14 Sep 2013 18:41:13 +0300 Subject: [PATCH] admin: fix relations detection --- ipf/admin/model.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ipf/admin/model.php b/ipf/admin/model.php index c702c63..a52e190 100644 --- a/ipf/admin/model.php +++ b/ipf/admin/model.php @@ -645,8 +645,7 @@ class IPF_Admin_Model if ($perms === false || !in_array('view', $perms)) return new IPF_HTTP_Response_NotFound($request); - if ($request->method == 'POST') - { + if ($request->method == 'POST') { if (!in_array('change', $perms)) return new IPF_HTTP_Response_NotFound($request); @@ -655,8 +654,7 @@ class IPF_Admin_Model $form = $this->_getEditForm($o, $data, array('user_fields'=>$this->fields())); $this->_setupEditForm($form); $this->setInlines($o, $data); - if ( ($form->isValid()) && ($this->isValidInlines()) ) - { + if ( ($form->isValid()) && ($this->isValidInlines()) ) { $item = $form->save(); $this->saveInlines($item); AdminLog::logAction($request, $item, AdminLog::CHANGE); @@ -666,18 +664,13 @@ class IPF_Admin_Model $url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel)); return new IPF_HTTP_Response_Redirect($url); } - } - else - { + } else { $data = $o->getData(); - foreach ($o->getTable()->getRelations() as $rname=>$rel) - { + foreach ($o->getTable()->getRelations() as $rname => $rel) { $pk = $rel->getTable()->getIdentifier(); $fields = $this->fields(); - if ($fields && array_search($rname, $fields)) - { - if ($rel->getType()==IPF_ORM_Relation::MANY_AGGREGATE) - { + if (!$fields || in_array($rname, $fields)) { + if ($rel->getType() == IPF_ORM_Relation::MANY_AGGREGATE) { $data[$rname] = array(); foreach ($rel->fetchRelatedFor($o) as $ri) $data[$rname][] = $ri->$pk; -- 2.49.0