From 58899ebe058dd80d8ec1389792321f2495b7e483 Mon Sep 17 00:00:00 2001 From: molong Date: Tue, 27 Jun 2017 12:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/User.php | 10 +++--- application/common/model/User.php | 2 +- application/user/controller/Content.php | 46 +++++++------------------ 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/application/common/controller/User.php b/application/common/controller/User.php index 41146a3e..43dcbd04 100644 --- a/application/common/controller/User.php +++ b/application/common/controller/User.php @@ -18,9 +18,9 @@ class User extends Fornt { $this->redirect('user/login/index');exit(); } elseif (is_login()) { $user = model('User')->getInfo(session('user_auth.uid')); - if (!$this->checkProfile($user) && $this->url !== 'user/profile/index') { - return $this->error('请补充完个人资料!', url('user/profile/index')); - } + // if (!$this->checkProfile($user) && $this->url !== 'user/profile/index') { + // return $this->error('请补充完个人资料!', url('user/profile/index')); + // } $this->assign('user', $user); //设置会员中心菜单 @@ -55,9 +55,7 @@ class User extends Fornt { protected function getContentMenu() { $list = array(); $map = array( - 'is_user_show' => 1, - 'status' => array('gt', 0), - 'extend' => array('gt', 0), + 'status' => array('gt', 0) ); $list = db('Model')->where($map)->field("name,id,title,icon,'' as 'style'")->select(); diff --git a/application/common/model/User.php b/application/common/model/User.php index d803fe7d..0321f44e 100644 --- a/application/common/model/User.php +++ b/application/common/model/User.php @@ -22,7 +22,7 @@ class User extends Base{ 'uid' => 'integer', 'reg_time' => 'integer' ); - protected $insert = array('salt', 'password', 'status', 'reg_time'); + protected $insert = array('status', 'reg_time'); protected $update = array(); public $editfield = array( diff --git a/application/user/controller/Content.php b/application/user/controller/Content.php index bd1a4c70..b9f7aeab 100644 --- a/application/user/controller/Content.php +++ b/application/user/controller/Content.php @@ -131,47 +131,27 @@ class Content extends User { } protected function getField() { - $field_group = parse_config_attr($this->modelInfo['field_group']); - $field_sort = json_decode($this->modelInfo['field_sort'], true); + $field_group = parse_config_attr($this->modelInfo['attribute_group']); - if ($this->modelInfo['extend'] > 1) { - $map['model_id'] = $this->modelInfo['id']; - } else { - $model_id[] = $this->modelInfo['id']; - $model_id[] = 1; - $map['model_id'] = array('IN', $model_id); - } - if (ACTION_NAME == 'add') { + $map['model_id'] = $this->modelInfo['id']; + if ($this->request->action() == 'add') { $map['is_show'] = array('in', array('1', '2')); - } elseif (ACTION_NAME == 'edit') { + } elseif ($this->request->action() == 'edit') { $map['is_show'] = array('in', array('1', '3')); } //获得数组的第一条数组 - $first_key = array_keys($field_group); - $fields = model('Attribute')->getFieldlist($map); - if (!empty($field_sort)) { - foreach ($field_sort as $key => $value) { - foreach ($value as $index) { - if (isset($fields[$index])) { - $groupfield[$key][] = $fields[$index]; - unset($fields[$index]); - } - } + $rows = model('Attribute')->getFieldlist($map, 'id'); + if (!empty($rows)) { + foreach ($rows as $key => $value) { + $list[$value['group_id']][] = $value; } - } - //未进行排序的放入第一组中 - $fields[] = array('name' => 'model_id', 'type' => 'hidden'); //加入模型ID值 - $fields[] = array('name' => 'id', 'type' => 'hidden'); //加入模型ID值 - foreach ($fields as $key => $value) { - $groupfield[$first_key[0]][] = $value; - } - - foreach ($field_group as $key => $value) { - if ($groupfield[$key]) { - $data[$value] = $groupfield[$key]; + foreach ($field_group as $key => $value) { + $fields[$value] = isset($list[$key]) ? $list[$key] : array(); } + }else{ + $fields = array(); } - return $data; + return $fields; } }